01: /**
02: * EasyBeans
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: easybeans@ow2.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: Version.java 1970 2007-10-16 11:49:25Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.server;
25:
26: /**
27: * Sets the EasyBeans version.
28: * @author Florent Benoit
29: */
30: public final class Version {
31:
32: /**
33: * The Version number is read from the package.
34: * Default Version number of EasyBeans if package version not available.
35: */
36: private static final String DEFAULT_VERSION_NUMBER = "1.0.x";
37:
38: /**
39: * Version number.
40: */
41: private static String versionNumber = null;
42:
43: /**
44: * No public constructor. (utility class)
45: */
46: private Version() {
47:
48: }
49:
50: /**
51: * @return Returns the EasyBeans Version Number.
52: */
53: public static String getVersion() {
54: if (versionNumber == null) {
55: // Read version from the package
56: Package pkg = Version.class.getPackage();
57: if (pkg != null) {
58: String implVersion = pkg.getImplementationVersion();
59: if (implVersion != null) {
60: versionNumber = implVersion;
61: }
62: }
63: // not found, return default value
64: if (versionNumber == null) {
65: versionNumber = DEFAULT_VERSION_NUMBER;
66: }
67: }
68:
69: return versionNumber;
70: }
71:
72: /**
73: * Display the current EasyBeans version.
74: * @param args the given arguments
75: */
76: public static void main(final String[] args) {
77: System.out.println("Version is : " + getVersion());
78:
79: }
80:
81: }
|