1 /** 2 * 3 * Copyright 2003-2004 The Apache Software Foundation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.apache.geronimo.system.serverinfo; 19 20 import java.util.Properties; 21 22 /** 23 * Information about this build of the server. 24 * 25 * @version $Rev: 428888 $ $Date: 2006-08-04 14:21:54 -0700 (Fri, 04 Aug 2006) $ 26 */ 27 public class ServerConstants { 28 private static final String VERSION; 29 private static final String BUILD_DATE; 30 private static final String BUILD_TIME; 31 private static final String COPYRIGHT; 32 33 /** 34 * Gets the server version 35 * @return version of the server 36 */ 37 public static String getVersion() { 38 return VERSION; 39 } 40 41 /** 42 * Gets the date the server was built 43 * @return date of the server build 44 */ 45 public static String getBuildDate() { 46 return BUILD_DATE; 47 } 48 49 /** 50 * Gets the time the server was built 51 * @return time of the server build 52 */ 53 public static String getBuildTime() { 54 return BUILD_TIME; 55 } 56 57 /** 58 * Gets the copyright message for the server 59 * @return 60 */ 61 public static String getCopyright() { 62 return COPYRIGHT; 63 } 64 65 /** 66 * load all of the properties from the geronimo-version.properties file, which is generated during the build 67 */ 68 static { 69 Properties versionInfo = new Properties(); 70 try { 71 java.io.InputStream input = ServerConstants.class.getClassLoader().getResourceAsStream("org/apache/geronimo/system/serverinfo/geronimo-version.properties"); 72 if (input == null) { 73 throw new Error("Missing geronimo-version.properties"); 74 } 75 76 versionInfo.load(input); 77 } 78 catch (java.io.IOException e) { 79 throw new Error("Could not load geronimo-version.properties", e); 80 } 81 82 VERSION = versionInfo.getProperty("version"); 83 if (VERSION == null || VERSION.length() == 0) { 84 throw new Error("geronimo-version.properties does not contain a 'version' property"); 85 } 86 87 BUILD_DATE = versionInfo.getProperty("build.date"); 88 if (BUILD_DATE == null || BUILD_DATE.length() == 0) { 89 throw new Error("geronimo-version.properties does not contain a 'build.date' property"); 90 } 91 92 BUILD_TIME = versionInfo.getProperty("build.time"); 93 if (BUILD_TIME == null || BUILD_TIME.length() == 0) { 94 throw new Error("geronimo-version.properties does not contain a 'build.time' property"); 95 } 96 97 COPYRIGHT = versionInfo.getProperty("copyright"); 98 if (COPYRIGHT == null || COPYRIGHT.length() == 0) { 99 throw new Error("geronimo-version.properties does not contain a 'copyright' property"); 100 } 101 } 102 }