001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/framework/version/Version.java $
002 /*---------------- FILE HEADER ------------------------------------------
003
004 This file is part of deegree.
005 Copyright (C) 2001-2006 by:
006 EXSE, Department of Geography, University of Bonn
007 http://www.giub.uni-bonn.de/deegree/
008 lat/lon GmbH
009 http://www.lat-lon.de
010
011 This library is free software; you can redistribute it and/or
012 modify it under the terms of the GNU Lesser General Public
013 License as published by the Free Software Foundation; either
014 version 2.1 of the License, or (at your option) any later version.
015
016 This library is distributed in the hope that it will be useful,
017 but WITHOUT ANY WARRANTY; without even the implied warranty of
018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019 Lesser General Public License for more details.
020
021 You should have received a copy of the GNU Lesser General Public
022 License along with this library; if not, write to the Free Software
023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024
025 Contact:
026
027 Andreas Poth
028 lat/lon GmbH
029 Aennchenstr. 19
030 53115 Bonn
031 Germany
032 E-Mail: poth@lat-lon.de
033
034 Prof. Dr. Klaus Greve
035 Department of Geography
036 University of Bonn
037 Meckenheimer Allee 166
038 53115 Bonn
039 Germany
040 E-Mail: greve@giub.uni-bonn.de
041
042
043 ---------------------------------------------------------------------------*/
044 package org.deegree.framework.version;
045
046 import java.util.Properties;
047
048 import org.deegree.framework.util.BootLogger;
049
050 /**
051 * The version number is created by 3 parts, the first represents the version number, the second a
052 * essential update of a release, the third the build number. The version number could be numeric or
053 * alphanumeric, e.g. 'Foo2' or '2.0'.<BR>
054 * e.g.:<BR>
055 * 2.0alpha.142 - version no. 2, release 0 alpha, build 142<BR>
056 * 2.0beta.178 - version no. 2, release 0 beta, build 178 <BR>
057 * 2.0.198 - version no. 2, release 0, build 198 <BR>
058 *
059 * @author <a href="mailto:tfr@users.sourceforge.net">Torsten Friebe</A>
060 *
061 * @author last edited by: $Author: bezema $
062 *
063 * @version 3.0 . $Revision: 6259 $, $Date: 2007-03-20 10:15:15 +0100 (Di, 20 Mär 2007) $
064 */
065 public final class Version {
066
067 private static String BUILD_DATE;
068
069 private static String VERSION_NUMBER;
070
071 private static String BUILD_NUMBER;
072
073 private static String BUILD_BY;
074
075 /*
076 * Class loader to get version properties from resource file
077 */
078 static {
079 try {
080 // fetch version property
081 Properties versionProps = new Properties();
082 versionProps.load( Version.class.getResourceAsStream( "version.properties" ) );
083 VERSION_NUMBER = versionProps.getProperty( "version.number" );
084
085 // fetch build properties
086 Properties buildProps = new Properties();
087 buildProps.load( Version.class.getResourceAsStream( "buildId.properties" ) );
088 BUILD_DATE = buildProps.getProperty( "build.date" );
089 BUILD_NUMBER = buildProps.getProperty( "build.number" );
090 BUILD_BY = buildProps.getProperty( "build.by" );
091 } catch ( Exception ex ) {
092 BootLogger.logError( "Error fetching version / build properties: " + ex.getMessage(),
093 ex );
094 }
095 }
096
097 /**
098 * Don't let anyone instantiate this class.
099 */
100 private Version() {
101 }
102
103 /**
104 * Returns the version of the application. The version number is created by 3 parts, the first
105 * represents the version number, the second a essential update of a release, the third the
106 * build number. The version number could be numeric or alphanumeric, e.g. 'Foo2' or '2.0'.
107 * <P>
108 * e.g.:<BR>
109 * 1.0.42 - version no. 1, release 0, build 42<BR>
110 * 1.1.78 - version no. 1, release 1, build 78<BR>
111 * 2.0.98 - version no. 2, release 0, build 98<BR>
112 *
113 * @return the version string
114 */
115 public static String getVersion() {
116 final String s = getVersionNumber() + " (" + getBuildDate() + " build-" + getBuildNumber()
117 + "-" + getBuildBy() + ")";
118 return s;
119 }
120
121 /**
122 * Returns the version number.
123 *
124 * @return the version number
125 */
126 public static String getVersionNumber() {
127 return Version.VERSION_NUMBER;
128 }
129
130 /**
131 * Returns the current build number.
132 *
133 * @return the current build number
134 */
135 public static String getBuildNumber() {
136 return Version.BUILD_NUMBER;
137 }
138
139 /**
140 * Returns the date string when the current build was created.
141 *
142 * @return the date as String
143 */
144 public static String getBuildDate() {
145 return Version.BUILD_DATE;
146 }
147
148 /**
149 * Returns the name of the builder.
150 *
151 * @return the name of the builder
152 */
153 public static String getBuildBy() {
154 return Version.BUILD_BY;
155 }
156
157 public static void main( String[] args ) {
158 System.out.println( "deegree version: " + Version.getVersion() );
159 }
160 }
161
162 /***************************************************************************************************
163 * Changes to this class. What the people have been up to: $Log$
164 * Changes to this class. What the people have been up to: Revision 1.10 2006/08/02 13:23:33 mschneider
165 * Changes to this class. What the people have been up to: Fixed version string.
166 * Changes to this class. What the people have been up to: Revision 1.9
167 * 2006/07/27 16:20:14 mschneider Splitted former Version.properties into
168 * version.properties+buildId.properties.
169 *
170 * Revision 1.8 2006/07/12 14:46:19 poth comment footer added
171 *
172 **************************************************************************************************/