|
1 |
package eu.dnetlib.functionality.modular.ui;
|
|
2 |
|
|
3 |
import java.lang.management.ManagementFactory;
|
|
4 |
import java.lang.management.RuntimeMXBean;
|
|
5 |
import java.util.Map;
|
|
6 |
|
|
7 |
import javax.servlet.http.HttpServletRequest;
|
|
8 |
import javax.servlet.http.HttpServletResponse;
|
|
9 |
|
|
10 |
import org.springframework.beans.factory.annotation.Required;
|
|
11 |
import org.springframework.ui.ModelMap;
|
|
12 |
|
|
13 |
import com.google.common.collect.Maps;
|
|
14 |
|
|
15 |
import eu.dnetlib.miscutils.datetime.DateUtils;
|
|
16 |
import eu.dnetlib.miscutils.datetime.HumanTime;
|
|
17 |
|
|
18 |
public class InfoController extends ModuleEntryPoint {
|
|
19 |
|
|
20 |
private String hostname;
|
|
21 |
private String port;
|
|
22 |
private String context;
|
|
23 |
|
|
24 |
@Override
|
|
25 |
protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
|
|
26 |
RuntimeMXBean mxbean = ManagementFactory.getRuntimeMXBean();
|
|
27 |
|
|
28 |
final Map<String, Map<String, String>> info = Maps.newLinkedHashMap();
|
|
29 |
|
|
30 |
final Map<String, String> genInfo = Maps.newLinkedHashMap();
|
|
31 |
final Map<String, String> jvmInfo = Maps.newLinkedHashMap();
|
|
32 |
final Map<String, String> libInfo = Maps.newLinkedHashMap();
|
|
33 |
final Map<String, String> sysInfo = Maps.newLinkedHashMap();
|
|
34 |
|
|
35 |
info.put("General", genInfo);
|
|
36 |
info.put("JVM", jvmInfo);
|
|
37 |
info.put("Libraries and arguments", libInfo);
|
|
38 |
info.put("System properties", sysInfo);
|
|
39 |
|
|
40 |
genInfo.put("Hostname", hostname);
|
|
41 |
genInfo.put("Port", port);
|
|
42 |
genInfo.put("Context", context);
|
|
43 |
genInfo.put("Uptime", HumanTime.exactly(mxbean.getUptime()));
|
|
44 |
genInfo.put("Start Time", DateUtils.calculate_ISO8601(mxbean.getStartTime()));
|
|
45 |
|
|
46 |
jvmInfo.put("JVM Name", mxbean.getVmName());
|
|
47 |
jvmInfo.put("JVM Vendor", mxbean.getVmVendor());
|
|
48 |
jvmInfo.put("JVM Version", mxbean.getVmVersion());
|
|
49 |
jvmInfo.put("JVM Spec Name", mxbean.getSpecName());
|
|
50 |
jvmInfo.put("JVM Spec Vendor", mxbean.getSpecVendor());
|
|
51 |
jvmInfo.put("JVM Spec Version", mxbean.getSpecVersion());
|
|
52 |
jvmInfo.put("Running JVM Name", mxbean.getName());
|
|
53 |
jvmInfo.put("Management Spec Version", mxbean.getManagementSpecVersion());
|
|
54 |
|
|
55 |
libInfo.put("Classpath", mxbean.getClassPath().replaceAll(":", " : "));
|
|
56 |
libInfo.put("Boot ClassPath", mxbean.getBootClassPath().replaceAll(":", " : "));
|
|
57 |
libInfo.put("Input arguments", mxbean.getInputArguments().toString());
|
|
58 |
libInfo.put("Library Path", mxbean.getLibraryPath().replaceAll(":", " : "));
|
|
59 |
|
|
60 |
sysInfo.putAll(mxbean.getSystemProperties());
|
|
61 |
|
|
62 |
map.addAttribute("info", info);
|
|
63 |
}
|
|
64 |
|
|
65 |
public String getHostname() {
|
|
66 |
return hostname;
|
|
67 |
}
|
|
68 |
|
|
69 |
@Required
|
|
70 |
public void setHostname(final String hostname) {
|
|
71 |
this.hostname = hostname;
|
|
72 |
}
|
|
73 |
|
|
74 |
public String getPort() {
|
|
75 |
return port;
|
|
76 |
}
|
|
77 |
|
|
78 |
@Required
|
|
79 |
public void setPort(final String port) {
|
|
80 |
this.port = port;
|
|
81 |
}
|
|
82 |
|
|
83 |
public String getContext() {
|
|
84 |
return context;
|
|
85 |
}
|
|
86 |
|
|
87 |
@Required
|
|
88 |
public void setContext(final String context) {
|
|
89 |
this.context = context;
|
|
90 |
}
|
|
91 |
}
|
info page