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 |
46
| public ILink getLink(boolean post, Object parameter)
|
57 |
| { |
58 |
46
| if (parameter != null)
|
59 |
0
| throw new IllegalArgumentException(EngineMessages.serviceNoParameter(this));
|
60 |
| |
61 |
46
| Map parameters = new HashMap();
|
62 |
| |
63 |
46
| return _linkFactory.constructLink(this, post, parameters, true);
|
64 |
| } |
65 |
| |
66 |
6
| public void service(IRequestCycle cycle) throws IOException
|
67 |
| { |
68 |
6
| HttpSession session = _request.getSession(false);
|
69 |
| |
70 |
6
| if (session != null)
|
71 |
| { |
72 |
4
| try
|
73 |
| { |
74 |
4
| session.invalidate();
|
75 |
| } |
76 |
| catch (IllegalStateException ex) |
77 |
| { |
78 |
2
| _log.warn("Exception thrown invalidating HttpSession.", ex);
|
79 |
| |
80 |
| |
81 |
| } |
82 |
| } |
83 |
| |
84 |
6
| String url = cycle.getAbsoluteURL(_servletPath);
|
85 |
| |
86 |
6
| _response.sendRedirect(url);
|
87 |
| } |
88 |
| |
89 |
78
| public String getName()
|
90 |
| { |
91 |
78
| return Tapestry.RESTART_SERVICE;
|
92 |
| } |
93 |
| |
94 |
| |
95 |
34
| public void setLog(Log log)
|
96 |
| { |
97 |
34
| _log = log;
|
98 |
| } |
99 |
| |
100 |
| |
101 |
38
| public void setRequest(HttpServletRequest request)
|
102 |
| { |
103 |
38
| _request = request;
|
104 |
| } |
105 |
| |
106 |
| |
107 |
38
| public void setResponse(HttpServletResponse response)
|
108 |
| { |
109 |
38
| _response = response;
|
110 |
| } |
111 |
| |
112 |
| |
113 |
32
| public void setLinkFactory(LinkFactory linkFactory)
|
114 |
| { |
115 |
32
| _linkFactory = linkFactory;
|
116 |
| } |
117 |
| |
118 |
| |
119 |
38
| public void setServletPath(String servletPath)
|
120 |
| { |
121 |
38
| _servletPath = servletPath;
|
122 |
| } |
123 |
| } |