Project

General

Profile

« Previous | Next » 

Revision 33317

info page

View differences:

modules/dnet-modular-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/InfoController.java
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
}
modules/dnet-modular-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/info.st
1
$common/master( header={}, onLoad={}, body={
2
	$info.keys:{title|
3
		<div class="well">
4
			<fieldset>
5
				<legend>$title$</legend>
6
				<table class="table table-striped table-condensed">
7
					$info.(title).keys:{k|
8
						<tr>
9
							<th class="col-xs-3">$k$</th>
10
							<td class="col-xs-9">$info.(title).(k)$</td>
11
						</tr>
12
					}$	
13
				</table>		
14
			</fieldset>
15
		</div>
16
	}$
17
})$
modules/dnet-modular-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/webContext-modular-ui.xml
57 57
		</property>
58 58
	</bean>
59 59
	
60
	<bean name="/ui/info.do"
61
		class="eu.dnetlib.functionality.modular.ui.InfoController"
62
		p:menu="Info" p:title="Info"
63
		p:description="Info" p:group="Configuration"
64
		p:order="15"
65
		p:groupOrder="99"
66
		p:hostname="${container.hostname}"
67
		p:port="${container.port}"
68
		p:context="${container.context}">
69
		<property name="permissionLevels">
70
			<set>
71
				<value>SUPER_ADMIN</value>
72
			</set>
73
		</property>
74
	</bean>
75

  
60 76
	<bean name="/ui/prepareShutdown.do"
61 77
		class="eu.dnetlib.functionality.modular.ui.PrepareShutdownController"
62 78
		p:menu="Prepare for shutdown" p:title="Prepare for shutdown"

Also available in: Unified diff