Source Code Cross Referenced for Version.java in  » EJB-Server-JBoss-4.2.1 » system » org » jboss » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server JBoss 4.2.1 » system » org.jboss 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jboss;
023:
024:        import java.io.IOException;
025:        import java.io.InputStream;
026:
027:        import java.util.Collections;
028:        import java.util.Map;
029:        import java.util.Properties;
030:
031:        /**
032:         * Provides access to JBoss version (and build) properties.
033:         *
034:         * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
035:         * @author Scott.Stark@jboss.org
036:         * @author <a href="mailto:dimitris@jboss.org">Dimitris Andreadis</a>
037:         * @version $Revision: 59329 $
038:         */
039:        public final class Version {
040:            public final static String VERSION_MAJOR = "version.major";
041:            public final static String VERSION_MINOR = "version.minor";
042:            public final static String VERSION_REVISION = "version.revision";
043:            public final static String VERSION_TAG = "version.tag";
044:            public final static String VERSION_NAME = "version.name";
045:            public final static String VERSION_CVSTAG = "version.cvstag";
046:
047:            public final static String BUILD_NUMBER = "build.number";
048:            public final static String BUILD_ID = "build.id";
049:            public final static String BUILD_DATE = "build.day";
050:            public final static String BUILD_JVM_VERSION = "java.vm.version";
051:            public final static String BUILD_JVM_VENDOR = "java.vendor";
052:            public final static String BUILD_OS = "os.name";
053:            public final static String BUILD_OS_ARCH = "os.arch";
054:            public final static String BUILD_OS_VERSION = "os.version";
055:
056:            /**
057:             * The single instance.
058:             */
059:            private static Version instance = null;
060:
061:            /**
062:             * The version properties.
063:             */
064:            private Properties props;
065:
066:            /**
067:             * Do not allow direct public construction.
068:             */
069:            private Version() {
070:                props = loadProperties();
071:            }
072:
073:            /**
074:             * Get the single <tt>Version</tt> instance.
075:             *
076:             * @return The single <tt>Version</tt> instance.
077:             */
078:            public static Version getInstance() {
079:                if (instance == null) {
080:                    instance = new Version();
081:                }
082:                return instance;
083:            }
084:
085:            /**
086:             * Returns an unmodifiable map of version properties.
087:             *
088:             * @return An unmodifiable map of version properties.
089:             */
090:            public Map getProperties() {
091:                return Collections.unmodifiableMap(props);
092:            }
093:
094:            /**
095:             * Returns the value for the given property name.
096:             *
097:             * @param name - The name of the property.
098:             * @return The property value or null if the property is not set.
099:             */
100:            public String getProperty(final String name) {
101:                return props.getProperty(name);
102:            }
103:
104:            /**
105:             * Returns the major number of the version.
106:             *
107:             * @return The major number of the version.
108:             */
109:            public int getMajor() {
110:                return getIntProperty(VERSION_MAJOR);
111:            }
112:
113:            /**
114:             * Returns the minor number of the version.
115:             *
116:             * @return The minor number of the version.
117:             */
118:            public int getMinor() {
119:                return getIntProperty(VERSION_MINOR);
120:            }
121:
122:            /**
123:             * Returns the revision number of the version.
124:             *
125:             * @return The revision number of the version.
126:             */
127:            public int getRevision() {
128:                return getIntProperty(VERSION_REVISION);
129:            }
130:
131:            /**
132:             * Returns the tag of the version.
133:             *
134:             * @return The tag of the version.
135:             */
136:            public String getTag() {
137:                return props.getProperty(VERSION_TAG);
138:            }
139:
140:            /**
141:             * Returns the CVS tag of the version.
142:             *
143:             * @return The CVS tag of the version.
144:             */
145:            public String getCvsTag() {
146:                return props.getProperty(VERSION_CVSTAG);
147:            }
148:
149:            /**
150:             * Returns the name number of the version.
151:             *
152:             * @return The name of the version.
153:             */
154:            public String getName() {
155:                return props.getProperty(VERSION_NAME);
156:            }
157:
158:            /**
159:             * Returns the build identifier for this version.
160:             *
161:             * @return The build identifier for this version.
162:             */
163:            public String getBuildID() {
164:                return props.getProperty(BUILD_ID);
165:            }
166:
167:            /**
168:             * Returns the build number for this version.
169:             *
170:             * @return The build number for this version.
171:             */
172:            public String getBuildNumber() {
173:                return props.getProperty(BUILD_NUMBER);
174:            }
175:
176:            /**
177:             * Returns the build date for this version.
178:             *
179:             * @return The build date for this version.
180:             */
181:            public String getBuildDate() {
182:                return props.getProperty(BUILD_DATE);
183:            }
184:
185:            /** Returns the BUILD_JVM_VERSION (BUILD_JVM_VENDOR) which should look like:
186:             * 1.4.2_05-b04 (Sun Microsystems Inc.)
187:             * @return
188:             */
189:            public String getBuildJVM() {
190:                String vm = props.getProperty(BUILD_JVM_VERSION);
191:                String vendor = props.getProperty(BUILD_JVM_VENDOR);
192:                return vm + '(' + vendor + ')';
193:            }
194:
195:            /** Returns the BUILD_OS (BUILD_OS_ARCH,BUILD_OS_VERSION) which should look
196:             * like:
197:             * Windows XP (x86,5.1)
198:             * Linux (i386,2.4.21-4.ELsmp)
199:             * @return
200:             */
201:            public String getBuildOS() {
202:                String os = props.getProperty(BUILD_OS);
203:                String arch = props.getProperty(BUILD_OS_ARCH);
204:                String version = props.getProperty(BUILD_OS_VERSION);
205:                return os + '(' + arch + ',' + version + ')';
206:            }
207:
208:            /**
209:             * Returns the full version number, e.g. 5.0.0.GA
210:             * 
211:             * @return The full version number as string
212:             */
213:            public String getVersionNumber() {
214:                StringBuffer buff = new StringBuffer();
215:
216:                buff.append(getMajor()).append(".");
217:                buff.append(getMinor()).append(".");
218:                buff.append(getRevision()).append(".");
219:                buff.append(getTag());
220:
221:                return buff.toString();
222:            }
223:
224:            /**
225:             * Returns the version information as a string.
226:             *
227:             * @return Basic information as a string.
228:             */
229:            public String toString() {
230:                StringBuffer buff = new StringBuffer();
231:
232:                buff.append(getVersionNumber());
233:                buff.append(" (build: SVNTag=");
234:                buff.append(getCvsTag());
235:                buff.append(" date=");
236:                buff.append(getBuildID());
237:                buff.append(")");
238:
239:                return buff.toString();
240:            }
241:
242:            /**
243:             * Returns a property value as an int.
244:             *
245:             * @param name - The name of the property.
246:             * @return The property value, or -1 if there was a problem converting
247:             *         it to an int.
248:             */
249:            private int getIntProperty(final String name) {
250:                try {
251:                    return Integer.valueOf(props.getProperty(name)).intValue();
252:                } catch (Exception e) {
253:                    return -1;
254:                }
255:            }
256:
257:            /**
258:             * Load the version properties from a resource.
259:             */
260:            private Properties loadProperties() {
261:                props = new Properties();
262:
263:                try {
264:                    InputStream in = Version.class
265:                            .getResourceAsStream("/org/jboss/version.properties");
266:
267:                    props.load(in);
268:                    in.close();
269:                } catch (IOException e) {
270:                    throw new Error("Missing version.properties");
271:                }
272:
273:                return props;
274:            }
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.