1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package com.mindtree.techworks.insight;
25
26 import java.io.IOException;
27 import java.util.Properties;
28
29
30
31
32
33
34
35 public class VersionUtil {
36
37
38
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
72 try {
73 tempProps.load(ClassLoader.getSystemResourceAsStream("insight-version.properties"));
74 } catch (IOException e) {
75
76 }
77 propsAggregator.putAll(tempProps);
78 tempProps = new Properties();
79
80
81 try {
82 tempProps.load(ClassLoader.getSystemResourceAsStream("remote-protocol-version.properties"));
83 } catch (IOException e) {
84
85 }
86
87 propsAggregator.putAll(tempProps);
88 versionProperties = propsAggregator;
89 }
90 }