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.tanukisoftware.wrapper.WrapperManager;
23
24 import psiprobe.PostParameterizableViewController;
25
26
27
28
29 @Controller
30 public class RestartJvmController extends PostParameterizableViewController {
31
32
33 private static final Logger logger = LoggerFactory.getLogger(RestartJvmController.class);
34
35 @RequestMapping(path = "/adm/restartvm.ajax")
36 @Override
37 public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
38 throws Exception {
39 return super.handleRequest(request, response);
40 }
41
42 @Override
43 protected ModelAndView handleRequestInternal(HttpServletRequest request,
44 HttpServletResponse response) throws Exception {
45
46 boolean done = false;
47 try {
48 Class.forName("org.tanukisoftware.wrapper.WrapperManager");
49 logger.info("JVM is RESTARTED by {}", request.getRemoteAddr());
50 WrapperManager.restartAndReturn();
51 done = true;
52 } catch (ClassNotFoundException e) {
53 logger.info("WrapperManager not found. Do you have wrapper.jar in the classpath?");
54 logger.trace("", e);
55 }
56 return new ModelAndView(getViewName(), "done", done);
57 }
58
59 @Value("ajax/jvm_restarted")
60 @Override
61 public void setViewName(String viewName) {
62 super.setViewName(viewName);
63 }
64
65 }