001 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
002 *
003 * Copyright 2000-2011, Michael Meyling <mime@qedeq.org>.
004 *
005 * "Hilbert II" is free software; you can redistribute
006 * it and/or modify it under the terms of the GNU General Public
007 * License as published by the Free Software Foundation; either
008 * version 2 of the License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013 * GNU General Public License for more details.
014 */
015
016 package org.qedeq.kernel.bo;
017
018 import java.net.URLConnection;
019
020 import org.qedeq.base.utility.YodaUtility;
021 import org.qedeq.kernel.bo.common.KernelProperties;
022
023
024 /**
025 * This class provides basic informations about the kernel.
026 *
027 * @author Michael Meyling
028 */
029 public final class BasicKernel implements KernelProperties {
030
031
032 /** Version of this kernel. */
033 private static final String KERNEL_VERSION = "0.04.04";
034
035 /** Version dependent directory of this kernel. */
036 private static final String KERNEL_VERSION_DIRECTORY = KERNEL_VERSION.replace('.', '_');
037
038 /** Version code . */
039 private static final String KERNEL_CODE_NAME = "gaffsie";
040
041 /** Kernel version dedication. */
042 private static final String KERNEL_DEDICATED
043 = "dedicated to the pearl of the northern seas: Amrum";
044
045 /** Descriptive version information of this kernel. */
046 private static final String DESCRIPTIVE_KERNEL_VERSION
047 = "Hilbert II - Version " + KERNEL_VERSION + " (" + KERNEL_CODE_NAME + ") ["
048 + getBuildIdFromManifest() + "] " + KERNEL_DEDICATED;
049
050 /** Maximal supported rule version of this kernel. */
051 private static final String MAXIMAL_RULE_VERSION = "1.01.00";
052
053 /**
054 * Constructor.
055 */
056 BasicKernel() {
057 }
058
059 /**
060 * Get build information from JAR manifest file. Is also non empty string if no manifest
061 * information is available.
062 *
063 * @return Implementation-version.
064 */
065 private static String getBuildIdFromManifest() {
066 String build = BasicKernel.class.getPackage().getImplementationVersion();
067 if (build == null) {
068 build = "no regular build";
069 }
070 return build;
071 }
072
073 public String getBuildId() {
074 return getBuildIdFromManifest();
075 }
076
077 public final String getKernelVersion() {
078 return KERNEL_VERSION;
079 }
080
081 public final String getKernelCodeName() {
082 return KERNEL_CODE_NAME;
083 }
084
085 public final String getKernelVersionDirectory() {
086 return KERNEL_VERSION_DIRECTORY;
087 }
088
089 public final String getDescriptiveKernelVersion() {
090 return DESCRIPTIVE_KERNEL_VERSION;
091 }
092
093 public final String getDedication() {
094 return KERNEL_DEDICATED;
095 }
096
097 public final String getMaximalRuleVersion() {
098 return MAXIMAL_RULE_VERSION;
099 }
100
101 public final boolean isRuleVersionSupported(final String ruleVersion) {
102 return MAXIMAL_RULE_VERSION.equals(ruleVersion);
103 }
104
105 /**
106 * This class ist just for solving the lazy loading problem thread save.
107 * see <a href="http://en.wikipedia.org/wiki/Initialization_on_demand_holder_idiom">
108 * Initialization_on_demand_holder_idiom</a>.
109 */
110 private static final class LazyHolderTimeoutMethods {
111
112 /** Lazy initialized constant that knows about the existence of the method
113 * <code>URLConnection.setConnectTimeout</code>. This depends on the currently running
114 * JVM. */
115 private static final boolean IS_SET_CONNECTION_TIMEOUT_SUPPORTED = YodaUtility.existsMethod(
116 URLConnection.class, "setConnectTimeout",
117 new Class[] {Integer.TYPE});
118
119 /** Lazy initialized constant that knows about the existence of the method
120 * <code>URLConnection.setReadTimeout</code>. This depends on the currently running
121 * JVM. */
122 private static final boolean IS_SET_READ_TIMEOUT_SUSPPORTED = YodaUtility.existsMethod(
123 URLConnection.class, "setReadTimeout",
124 new Class[] {Integer.TYPE});
125
126 /**
127 * Hidden constructor.
128 */
129 private LazyHolderTimeoutMethods() {
130 // nothing to do
131 }
132
133 }
134
135 public boolean isSetConnectionTimeOutSupported() {
136 return LazyHolderTimeoutMethods.IS_SET_CONNECTION_TIMEOUT_SUPPORTED;
137 }
138
139 public boolean isSetReadTimeoutSupported() {
140 return LazyHolderTimeoutMethods.IS_SET_READ_TIMEOUT_SUSPPORTED;
141 }
142
143 }
|