001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.system.serverinfo;
017:
018: import java.util.Properties;
019:
020: /**
021: * Information about this build of the server.
022: *
023: * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
024: */
025: public class ServerConstants {
026: private static final String VERSION;
027: private static final String BUILD_DATE;
028: private static final String BUILD_TIME;
029: private static final String COPYRIGHT;
030:
031: /**
032: * Gets the server version
033: * @return version of the server
034: */
035: public static String getVersion() {
036: return VERSION;
037: }
038:
039: /**
040: * Gets the date the server was built
041: * @return date of the server build
042: */
043: public static String getBuildDate() {
044: return BUILD_DATE;
045: }
046:
047: /**
048: * Gets the time the server was built
049: * @return time of the server build
050: */
051: public static String getBuildTime() {
052: return BUILD_TIME;
053: }
054:
055: /**
056: * Gets the copyright message for the server
057: * @return
058: */
059: public static String getCopyright() {
060: return COPYRIGHT;
061: }
062:
063: /**
064: * load all of the properties from the geronimo-version.properties file, which is generated during the build
065: */
066: static {
067: Properties versionInfo = new Properties();
068: try {
069: java.io.InputStream input = ServerConstants.class
070: .getClassLoader()
071: .getResourceAsStream(
072: "org/apache/geronimo/system/serverinfo/geronimo-version.properties");
073: if (input == null) {
074: throw new Error("Missing geronimo-version.properties");
075: }
076:
077: versionInfo.load(input);
078: } catch (java.io.IOException e) {
079: throw new Error(
080: "Could not load geronimo-version.properties", e);
081: }
082:
083: VERSION = versionInfo.getProperty("version");
084: if (VERSION == null || VERSION.length() == 0) {
085: throw new Error(
086: "geronimo-version.properties does not contain a 'version' property");
087: }
088:
089: BUILD_DATE = versionInfo.getProperty("build.date");
090: if (BUILD_DATE == null || BUILD_DATE.length() == 0) {
091: throw new Error(
092: "geronimo-version.properties does not contain a 'build.date' property");
093: }
094:
095: BUILD_TIME = versionInfo.getProperty("build.time");
096: if (BUILD_TIME == null || BUILD_TIME.length() == 0) {
097: throw new Error(
098: "geronimo-version.properties does not contain a 'build.time' property");
099: }
100:
101: COPYRIGHT = versionInfo.getProperty("copyright");
102: if (COPYRIGHT == null || COPYRIGHT.length() == 0) {
103: throw new Error(
104: "geronimo-version.properties does not contain a 'copyright' property");
105: }
106: }
107: }
|