001: package org.wso2.esb.services.tos;
002:
003: import org.wso2.esb.ServiceBusConfiguration;
004:
005: /**
006: * Compute and Hold detailed server information
007: */
008: public class ServerData {
009:
010: private String javaRuntimeName;
011: private String javaVMVersion;
012: private String javaVMVendor;
013: private String javaHome;
014: private String javaVersion;
015: private String osName;
016: private String osVersion;
017: private String userHome;
018: private String userTimezone;
019: private String userName;
020: private String userCountry;
021: private String axis2Location;
022: private String serverName;
023: private String repoLocation;
024: private String wso2esbVersion;
025:
026: public ServerData(String serverName, String repoLocation) {
027: init();
028: this .serverName = serverName;
029: this .repoLocation = repoLocation;
030: }
031:
032: public ServerData() {
033: init();
034: }
035:
036: private void init() {
037: javaRuntimeName = System.getProperty("java.runtime.name");
038: javaVMVersion = System.getProperty("java.vm.version");
039: javaVMVendor = System.getProperty("java.vm.vendor");
040: userCountry = System.getProperty("user.country");
041: osName = System.getProperty("os.name");
042: osVersion = System.getProperty("os.version");
043: userHome = System.getProperty("user.home");
044: userTimezone = System.getProperty("user.timezone");
045: userName = System.getProperty("user.name");
046: javaHome = System.getProperty("java.home");
047: javaVersion = System.getProperty("java.version");
048: wso2esbVersion = ServiceBusConfiguration.getInstance()
049: .getFirstProperty("Version");
050: axis2Location = axis2Location();
051: }
052:
053: private String axis2Location() {
054: try {
055: Class clazz = Class
056: .forName("org.apache.axis2.engine.AxisEngine");
057: java.net.URL url = clazz.getProtectionDomain()
058: .getCodeSource().getLocation();
059: String location = url.toString();
060:
061: if (location.startsWith("jar")) {
062: url = ((java.net.JarURLConnection) url.openConnection())
063: .getJarFileURL();
064: location = url.toString();
065: }
066:
067: if (location.startsWith("file")) {
068: java.io.File file = new java.io.File(url.getFile());
069: return file.getAbsolutePath();
070:
071: } else {
072: return url.toString();
073: }
074:
075: } catch (Throwable t) {
076: return "An error occured while trying to determine Axis2 location";
077: }
078: }
079:
080: public String getJavaRuntimeName() {
081: return javaRuntimeName;
082: }
083:
084: public void setJavaRuntimeName(String javaRuntimeName) {
085: this .javaRuntimeName = javaRuntimeName;
086: }
087:
088: public String getJavaVMVersion() {
089: return javaVMVersion;
090: }
091:
092: public void setJavaVMVersion(String javaVMVersion) {
093: this .javaVMVersion = javaVMVersion;
094: }
095:
096: public String getUserCountry() {
097: return userCountry;
098: }
099:
100: public void setUserCountry(String userCountry) {
101: this .userCountry = userCountry;
102: }
103:
104: public String getJavaVMVendor() {
105: return javaVMVendor;
106: }
107:
108: public void setJavaVMVendor(String javaVMVendor) {
109: this .javaVMVendor = javaVMVendor;
110: }
111:
112: public String getOsName() {
113: return osName;
114: }
115:
116: public void setOsName(String osName) {
117: this .osName = osName;
118: }
119:
120: public String getOsVersion() {
121: return osVersion;
122: }
123:
124: public void setOsVersion(String osVersion) {
125: this .osVersion = osVersion;
126: }
127:
128: public String getUserHome() {
129: return userHome;
130: }
131:
132: public void setUserHome(String userHome) {
133: this .userHome = userHome;
134: }
135:
136: public String getUserName() {
137: return userName;
138: }
139:
140: public void setUserName(String userName) {
141: this .userName = userName;
142: }
143:
144: public String getUserTimezone() {
145: return userTimezone;
146: }
147:
148: public void setUserTimezone(String userTimezone) {
149: this .userTimezone = userTimezone;
150: }
151:
152: public String getJavaHome() {
153: return javaHome;
154: }
155:
156: public void setJavaHome(String javaHome) {
157: this .javaHome = javaHome;
158: }
159:
160: public String getJavaVersion() {
161: return javaVersion;
162: }
163:
164: public void setJavaVersion(String javaVersion) {
165: this .javaVersion = javaVersion;
166: }
167:
168: public String getAxis2Location() {
169: return axis2Location;
170: }
171:
172: public void setAxis2Location(String axis2Location) {
173: this .axis2Location = axis2Location;
174: }
175:
176: public String getServerName() {
177: return serverName;
178: }
179:
180: public void setServerName(String serverName) {
181: this .serverName = serverName;
182: }
183:
184: public String getRepoLocation() {
185: return repoLocation;
186: }
187:
188: public void setRepoLocation(String repoLocation) {
189: this .repoLocation = repoLocation;
190: }
191:
192: public String getWso2esbVersion() {
193: return wso2esbVersion;
194: }
195:
196: public void setWso2esbVersion(String wso2esbVersion) {
197: this.wso2esbVersion = wso2esbVersion;
198: }
199: }
|