KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > system > serverinfo > ServerConstants


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. 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 JavaDoc;
21
22 /**
23  * Information about this build of the server.
24  *
25  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
26  */

27 public class ServerConstants {
28     private static final String JavaDoc VERSION;
29     private static final String JavaDoc BUILD_DATE;
30     private static final String JavaDoc BUILD_TIME;
31     private static final String JavaDoc COPYRIGHT;
32
33     /**
34      * Gets the server version
35      * @return version of the server
36      */

37     public static String JavaDoc 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 JavaDoc 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 JavaDoc getBuildTime() {
54         return BUILD_TIME;
55     }
56
57     /**
58      * Gets the copyright message for the server
59      * @return
60      */

61     public static String JavaDoc 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 JavaDoc versionInfo = new Properties JavaDoc();
70         try {
71             java.io.InputStream JavaDoc input = ServerConstants.class.getClassLoader().getResourceAsStream("org/apache/geronimo/system/serverinfo/geronimo-version.properties");
72             if (input == null) {
73                 throw new Error JavaDoc("Missing geronimo-version.properties");
74             }
75             
76             versionInfo.load(input);
77         }
78         catch (java.io.IOException JavaDoc e) {
79             throw new Error JavaDoc("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 JavaDoc("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 JavaDoc("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 JavaDoc("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 JavaDoc("geronimo-version.properties does not contain a 'copyright' property");
100         }
101     }
102 }
103
Popular Tags