|
|||||||||||||||||||
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
WebRequestServicerPipelineBridge.java | - | 87.5% | 100% | 90.9% |
|
1 | // Copyright 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
14 | ||
15 | package org.apache.tapestry.services.impl; | |
16 | ||
17 | import java.io.IOException; | |
18 | ||
19 | import javax.servlet.ServletException; | |
20 | import javax.servlet.http.HttpServletRequest; | |
21 | import javax.servlet.http.HttpServletResponse; | |
22 | ||
23 | import org.apache.tapestry.services.RequestGlobals; | |
24 | import org.apache.tapestry.services.ServletRequestServicer; | |
25 | import org.apache.tapestry.services.WebRequestServicer; | |
26 | import org.apache.tapestry.web.ServletWebRequest; | |
27 | import org.apache.tapestry.web.ServletWebResponse; | |
28 | import org.apache.tapestry.web.WebRequest; | |
29 | import org.apache.tapestry.web.WebResponse; | |
30 | ||
31 | /** | |
32 | * Bridges from the <code>tapestry.request.ServletRequestServicerPipeline</code> to the | |
33 | * <code>tapestry.request.WebRequestServicerPipeline</code>. Also, stores the web request and | |
34 | * web response into {@link org.apache.tapestry.services.RequestGlobals}. Intercepts runtime | |
35 | * exceptions and throws them wrapped as {@link javax.servlet.ServletException}. | |
36 | * | |
37 | * @author Howard M. Lewis Ship | |
38 | * @since 4.0 | |
39 | */ | |
40 | public class WebRequestServicerPipelineBridge implements ServletRequestServicer | |
41 | { | |
42 | private RequestGlobals _requestGlobals; | |
43 | ||
44 | private WebRequestServicer _webRequestServicer; | |
45 | ||
46 | 132 | public void service(HttpServletRequest request, HttpServletResponse response) |
47 | throws IOException, ServletException | |
48 | { | |
49 | 132 | _requestGlobals.store(request, response); |
50 | ||
51 | 132 | WebRequest webRequest = new ServletWebRequest(request, response); |
52 | 132 | WebResponse webResponse = new ServletWebResponse(response); |
53 | ||
54 | 132 | try |
55 | { | |
56 | 132 | _webRequestServicer.service(webRequest, webResponse); |
57 | } | |
58 | catch (RuntimeException ex) | |
59 | { | |
60 | 0 | throw new ServletException(ex); |
61 | } | |
62 | } | |
63 | ||
64 | 41 | public void setRequestGlobals(RequestGlobals requestGlobals) |
65 | { | |
66 | 41 | _requestGlobals = requestGlobals; |
67 | } | |
68 | ||
69 | 41 | public void setWebRequestServicer(WebRequestServicer webRequestServicer) |
70 | { | |
71 | 41 | _webRequestServicer = webRequestServicer; |
72 | } | |
73 | } |
|