View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
10   */
11  package psiprobe.model;
12  
13  import java.io.File;
14  import java.io.Serializable;
15  import java.util.Date;
16  import java.util.Map;
17  import java.util.Set;
18  
19  import org.apache.catalina.util.ServerInfo;
20  
21  /**
22   * POJO representing system information for "system infromation" tab.
23   */
24  public class SystemInformation implements Serializable {
25  
26    /** The Constant serialVersionUID. */
27    private static final long serialVersionUID = 1L;
28  
29    /** The app base. */
30    private String appBase;
31  
32    /** The config base. */
33    private String configBase;
34  
35    /** The system properties. */
36    private Map<String, String> systemProperties;
37  
38    /**
39     * Gets the max memory.
40     *
41     * @return the max memory
42     */
43    public long getMaxMemory() {
44      return Runtime.getRuntime().maxMemory();
45    }
46  
47    /**
48     * Gets the free memory.
49     *
50     * @return the free memory
51     */
52    public long getFreeMemory() {
53      return Runtime.getRuntime().freeMemory();
54    }
55  
56    /**
57     * Gets the total memory.
58     *
59     * @return the total memory
60     */
61    public long getTotalMemory() {
62      return Runtime.getRuntime().totalMemory();
63    }
64  
65    /**
66     * Gets the cpu count.
67     *
68     * @return the cpu count
69     */
70    public int getCpuCount() {
71      return Runtime.getRuntime().availableProcessors();
72    }
73  
74    /**
75     * Gets the date.
76     *
77     * @return the date
78     */
79    public Date getDate() {
80      return new Date();
81    }
82  
83    /**
84     * Gets the server info.
85     *
86     * @return the server info
87     */
88    public String getServerInfo() {
89      return ServerInfo.getServerInfo();
90    }
91  
92    /**
93     * Gets the working dir.
94     *
95     * @return the working dir
96     */
97    public String getWorkingDir() {
98      return new File("").getAbsolutePath();
99    }
100 
101   /**
102    * Gets the app base.
103    *
104    * @return the app base
105    */
106   public String getAppBase() {
107     return appBase;
108   }
109 
110   /**
111    * Sets the app base.
112    *
113    * @param appBase the new app base
114    */
115   public void setAppBase(String appBase) {
116     this.appBase = appBase;
117   }
118 
119   /**
120    * Gets the config base.
121    *
122    * @return the config base
123    */
124   public String getConfigBase() {
125     return configBase;
126   }
127 
128   /**
129    * Sets the config base.
130    *
131    * @param configBase the new config base
132    */
133   public void setConfigBase(String configBase) {
134     this.configBase = configBase;
135   }
136 
137   /**
138    * Gets the system properties.
139    *
140    * @return the system properties
141    */
142   public Map<String, String> getSystemProperties() {
143     return systemProperties;
144   }
145 
146   /**
147    * Sets the system properties.
148    *
149    * @param systemProperties the system properties
150    */
151   public void setSystemProperties(Map<String, String> systemProperties) {
152     this.systemProperties = systemProperties;
153   }
154 
155   /**
156    * Gets the system property set.
157    *
158    * @return the system property set
159    */
160   public Set<Map.Entry<String, String>> getSystemPropertySet() {
161     return systemProperties.entrySet();
162   }
163 
164 }