1 /*
2 * $HeadURL: https://mindtreeinsight.svn.sourceforge.net/svnroot/mindtreeinsight/insight/insight-ui/trunk/src/main/java/com/mindtree/techworks/insight/VersionUtil.java $
3 * $Date: 2007-12-16 05:20:57 -0700 (Sun, 16 Dec 2007) $
4 * $Revision: 30 $
5 * $Author: bindul $
6 *
7 * Copyright (c) 2007 MindTree Consulting Ltd.
8 *
9 * This file is part of Insight.
10 *
11 * Insight is free software: you can redistribute it and/or modify it under the
12 * terms of the GNU General Public License as published by the Free Software
13 * Foundation, either version 3 of the License, or (at your option) any later
14 * version.
15 *
16 * Insight is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
19 * Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along with
22 * Insight. If not, see <http://www.gnu.org/licenses/>.
23 */
24 package com.mindtree.techworks.insight;
25
26 import java.io.IOException;
27 import java.util.Properties;
28
29 /**
30 * Version Utility to get Version Information
31 *
32 * @author <a href="mailto:bindul_bhowmik@mindtree.com">Bindul Bhowmik</a>
33 * @version $Revision: 30 $ $Date: 2007-12-16 05:20:57 -0700 (Sun, 16 Dec 2007) $
34 */
35 public class VersionUtil {
36
37 /**
38 * The proerties holding all version information
39 */
40 private static Properties versionProperties = null;
41
42 public static String getRemoteProtocolVersion () {
43 return getProperty("insight.remoteprotocol.version");
44 }
45
46 public static String getRemoteProtocolBuild () {
47 return getProperty("insight.remoteprotocol.build");
48 }
49
50 public static String getInsightVersion() {
51 return getProperty("insight.version");
52 }
53
54 public static String getInsightBuild() {
55 return getProperty("insight.build");
56 }
57
58 protected static String getProperty(String propertyKey) {
59 if (null == versionProperties) {
60 initialize();
61 }
62
63 return (null != versionProperties) ? versionProperties.getProperty(
64 propertyKey, "UNKNOWN") : "UNKNOWN";
65 }
66
67 private static void initialize() {
68 Properties tempProps = new Properties();
69 Properties propsAggregator = new Properties();
70
71 // Insight Properties
72 try {
73 tempProps.load(ClassLoader.getSystemResourceAsStream("insight-version.properties"));
74 } catch (IOException e) {
75 // Ignore
76 }
77 propsAggregator.putAll(tempProps);
78 tempProps = new Properties();
79
80 // Remote Protocol Properties
81 try {
82 tempProps.load(ClassLoader.getSystemResourceAsStream("remote-protocol-version.properties"));
83 } catch (IOException e) {
84 // Ignore
85 }
86
87 propsAggregator.putAll(tempProps);
88 versionProperties = propsAggregator;
89 }
90 }