|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.tapestry.engine; |
|
16 |
| |
|
17 |
| import java.io.IOException; |
|
18 |
| import java.util.HashMap; |
|
19 |
| import java.util.Map; |
|
20 |
| |
|
21 |
| import javax.servlet.http.HttpServletRequest; |
|
22 |
| import javax.servlet.http.HttpServletResponse; |
|
23 |
| import javax.servlet.http.HttpSession; |
|
24 |
| |
|
25 |
| import org.apache.commons.logging.Log; |
|
26 |
| import org.apache.tapestry.IRequestCycle; |
|
27 |
| import org.apache.tapestry.Tapestry; |
|
28 |
| import org.apache.tapestry.services.LinkFactory; |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| public class RestartService implements IEngineService |
|
40 |
| { |
|
41 |
| |
|
42 |
| private Log _log; |
|
43 |
| |
|
44 |
| |
|
45 |
| private HttpServletRequest _request; |
|
46 |
| |
|
47 |
| |
|
48 |
| private HttpServletResponse _response; |
|
49 |
| |
|
50 |
| |
|
51 |
| private LinkFactory _linkFactory; |
|
52 |
| |
|
53 |
| |
|
54 |
| private String _servletPath; |
|
55 |
| |
|
56 |
69
| public ILink getLink(boolean post, Object parameter)
|
|
57 |
| { |
|
58 |
69
| if (parameter != null)
|
|
59 |
0
| throw new IllegalArgumentException(EngineMessages.serviceNoParameter(this));
|
|
60 |
| |
|
61 |
69
| Map parameters = new HashMap();
|
|
62 |
| |
|
63 |
69
| return _linkFactory.constructLink(this, post, parameters, true);
|
|
64 |
| } |
|
65 |
| |
|
66 |
9
| public void service(IRequestCycle cycle) throws IOException
|
|
67 |
| { |
|
68 |
9
| HttpSession session = _request.getSession(false);
|
|
69 |
| |
|
70 |
9
| if (session != null)
|
|
71 |
| { |
|
72 |
6
| try
|
|
73 |
| { |
|
74 |
6
| session.invalidate();
|
|
75 |
| } |
|
76 |
| catch (IllegalStateException ex) |
|
77 |
| { |
|
78 |
3
| _log.warn("Exception thrown invalidating HttpSession.", ex);
|
|
79 |
| |
|
80 |
| |
|
81 |
| } |
|
82 |
| } |
|
83 |
| |
|
84 |
9
| String url = cycle.getAbsoluteURL(_servletPath);
|
|
85 |
| |
|
86 |
9
| _response.sendRedirect(url);
|
|
87 |
| } |
|
88 |
| |
|
89 |
117
| public String getName()
|
|
90 |
| { |
|
91 |
117
| return Tapestry.RESTART_SERVICE;
|
|
92 |
| } |
|
93 |
| |
|
94 |
| |
|
95 |
51
| public void setLog(Log log)
|
|
96 |
| { |
|
97 |
51
| _log = log;
|
|
98 |
| } |
|
99 |
| |
|
100 |
| |
|
101 |
57
| public void setRequest(HttpServletRequest request)
|
|
102 |
| { |
|
103 |
57
| _request = request;
|
|
104 |
| } |
|
105 |
| |
|
106 |
| |
|
107 |
57
| public void setResponse(HttpServletResponse response)
|
|
108 |
| { |
|
109 |
57
| _response = response;
|
|
110 |
| } |
|
111 |
| |
|
112 |
| |
|
113 |
48
| public void setLinkFactory(LinkFactory linkFactory)
|
|
114 |
| { |
|
115 |
48
| _linkFactory = linkFactory;
|
|
116 |
| } |
|
117 |
| |
|
118 |
| |
|
119 |
57
| public void setServletPath(String servletPath)
|
|
120 |
| { |
|
121 |
57
| _servletPath = servletPath;
|
|
122 |
| } |
|
123 |
| } |