]> git.argeo.org Git - gpl/argeo-slc.git/blob - ShutdownRuntime.java
3b792e47b9480ae3c665b4552bdeabc35b3350a8
[gpl/argeo-slc.git] / ShutdownRuntime.java
1 package org.argeo.slc.web.mvc.management;
2
3 import javax.servlet.http.HttpServletRequest;
4 import javax.servlet.http.HttpServletResponse;
5
6 import org.argeo.slc.deploy.DynamicRuntime;
7 import org.argeo.slc.msg.ExecutionAnswer;
8 import org.argeo.slc.web.mvc.AbstractServiceController;
9 import org.springframework.web.servlet.ModelAndView;
10
11 /** . */
12 public class ShutdownRuntime extends AbstractServiceController {
13 private DynamicRuntime<?> dynamicRuntime;
14
15 @Override
16 protected void handleServiceRequest(HttpServletRequest request,
17 HttpServletResponse response, ModelAndView modelAndView)
18 throws Exception {
19 new Thread() {
20 public void run() {
21 // wait in order to let call return
22 try {
23 Thread.sleep(3000);
24 } catch (InterruptedException e) {
25 // silent
26 }
27 dynamicRuntime.shutdown();
28 }
29 }.start();
30 ExecutionAnswer answer = ExecutionAnswer.ok("Server shutting down...");
31 modelAndView.addObject(answer);
32 }
33
34 public void setDynamicRuntime(DynamicRuntime<?> dynamicRuntime) {
35 this.dynamicRuntime = dynamicRuntime;
36 }
37
38 }