1
2
3
4
5
6
7
8
9
10
11 package psiprobe.controllers.wrapper;
12
13 import jakarta.servlet.http.HttpServletRequest;
14 import jakarta.servlet.http.HttpServletResponse;
15
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18 import org.springframework.beans.factory.annotation.Value;
19 import org.springframework.stereotype.Controller;
20 import org.springframework.web.bind.annotation.RequestMapping;
21 import org.springframework.web.servlet.ModelAndView;
22 import org.springframework.web.servlet.mvc.ParameterizableViewController;
23 import org.tanukisoftware.wrapper.WrapperManager;
24
25 import psiprobe.model.wrapper.WrapperInfo;
26
27
28
29
30 @Controller
31 public class WrapperInfoController extends ParameterizableViewController {
32
33
34 private static final Logger logger = LoggerFactory.getLogger(WrapperInfoController.class);
35
36 @RequestMapping(path = "/wrapper.htm")
37 @Override
38 public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
39 throws Exception {
40 return super.handleRequest(request, response);
41 }
42
43 @Override
44 protected ModelAndView handleRequestInternal(HttpServletRequest request,
45 HttpServletResponse response) throws Exception {
46
47 WrapperInfo wi = new WrapperInfo();
48
49 try {
50 Class.forName("org.tanukisoftware.wrapper.WrapperManager");
51 wi.setVersion(WrapperManager.getVersion());
52 wi.setBuildTime(WrapperManager.getBuildTime());
53 wi.setUser(
54 WrapperManager.getUser(false) != null ? WrapperManager.getUser(false).getUser() : null);
55 wi.setInteractiveUser(WrapperManager.getInteractiveUser(false) != null
56 ? WrapperManager.getInteractiveUser(false).getUser()
57 : null);
58 wi.setJvmPid(WrapperManager.getJavaPID());
59 wi.setWrapperPid(WrapperManager.getWrapperPID());
60 wi.setProperties(WrapperManager.getProperties().entrySet());
61 wi.setControlledByWrapper(WrapperManager.isControlledByNativeWrapper());
62 wi.setDebugEnabled(WrapperManager.isDebugEnabled());
63 wi.setLaunchedAsService(WrapperManager.isLaunchedAsService());
64 } catch (ClassNotFoundException e) {
65 logger.info("Could not find WrapperManager class. Is wrapper.jar in the classpath?");
66 logger.trace("", e);
67 wi.setControlledByWrapper(false);
68 }
69 return new ModelAndView(getViewName(), "wrapperInfo", wi);
70 }
71
72 @Value("wrapper")
73 @Override
74 public void setViewName(String viewName) {
75 super.setViewName(viewName);
76 }
77
78 }