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     */
017    
018    package org.apache.geronimo.system.serverinfo;
019    
020    import java.util.Properties;
021    
022    /**
023     * Information about this build of the server.
024     *
025     * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $
026     */
027    public class ServerConstants {
028        private static final String VERSION;
029        private static final String BUILD_DATE;
030        private static final String BUILD_TIME;
031        private static final String COPYRIGHT;
032    
033        /**
034         * Gets the server version
035         * @return version of the server
036         */
037        public static String getVersion() {
038            return VERSION;
039        }
040    
041        /**
042         * Gets the date the server was built
043         * @return date of the server build
044         */
045        public static String getBuildDate() {
046            return BUILD_DATE;
047        }
048    
049        /**
050         * Gets the time the server was built
051         * @return time of the server build
052         */
053        public static String getBuildTime() {
054            return BUILD_TIME;
055        }
056    
057        /**
058         * Gets the copyright message for the server
059         * @return
060         */
061        public static String getCopyright() {
062            return COPYRIGHT;
063        }
064    
065        /**
066         * load all of the properties from the geronimo-version.properties file, which is generated during the build
067         */
068        static {
069            Properties versionInfo = new Properties();
070            try {
071                java.io.InputStream input = ServerConstants.class.getClassLoader().getResourceAsStream("org/apache/geronimo/system/serverinfo/geronimo-version.properties");
072                if (input == null) {
073                    throw new Error("Missing geronimo-version.properties");
074                }
075                
076                versionInfo.load(input);
077            }
078            catch (java.io.IOException e) {
079                throw new Error("Could not load geronimo-version.properties", e);
080            }
081            
082            VERSION = versionInfo.getProperty("version");
083            if (VERSION == null || VERSION.length() == 0) {
084                throw new Error("geronimo-version.properties does not contain a 'version' property");
085            }
086    
087            BUILD_DATE = versionInfo.getProperty("build.date");
088            if (BUILD_DATE == null || BUILD_DATE.length() == 0) {
089                throw new Error("geronimo-version.properties does not contain a 'build.date' property");
090            }
091    
092            BUILD_TIME = versionInfo.getProperty("build.time");
093            if (BUILD_TIME == null || BUILD_TIME.length() == 0) {
094                throw new Error("geronimo-version.properties does not contain a 'build.time' property");
095            }
096    
097            COPYRIGHT = versionInfo.getProperty("copyright");
098            if (COPYRIGHT == null || COPYRIGHT.length() == 0) {
099                throw new Error("geronimo-version.properties does not contain a 'copyright' property");
100            }
101        }
102    }