|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.tapestry.request; |
|
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.Tapestry; |
|
24 |
| import org.apache.tapestry.services.ServletRequestServicer; |
|
25 |
| import org.apache.tapestry.services.ServletRequestServicerFilter; |
|
26 |
| import org.apache.tapestry.spec.ILibrarySpecification; |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| public class DecodedRequestInjector implements ServletRequestServicerFilter |
|
37 |
| { |
|
38 |
| private ILibrarySpecification _applicationSpecification; |
|
39 |
| |
|
40 |
| private IRequestDecoder _decoder; |
|
41 |
| |
|
42 |
123
| public void initializeService()
|
|
43 |
| { |
|
44 |
123
| if (_applicationSpecification.checkExtension(Tapestry.REQUEST_DECODER_EXTENSION_NAME))
|
|
45 |
3
| _decoder = (IRequestDecoder) _applicationSpecification.getExtension(
|
|
46 |
| Tapestry.REQUEST_DECODER_EXTENSION_NAME, |
|
47 |
| IRequestDecoder.class); |
|
48 |
| } |
|
49 |
| |
|
50 |
375
| public void service(HttpServletRequest request, HttpServletResponse response,
|
|
51 |
| ServletRequestServicer servicer) throws IOException, ServletException |
|
52 |
| { |
|
53 |
375
| HttpServletRequest decodedRequest = _decoder == null ? request : wrapRequest(request);
|
|
54 |
| |
|
55 |
375
| servicer.service(decodedRequest, response);
|
|
56 |
| } |
|
57 |
| |
|
58 |
3
| public HttpServletRequest wrapRequest(HttpServletRequest request)
|
|
59 |
| { |
|
60 |
3
| DecodedRequest decodedRequest = _decoder.decodeRequest(request);
|
|
61 |
| |
|
62 |
3
| return new DecodedRequestWrapper(request, decodedRequest);
|
|
63 |
| } |
|
64 |
| |
|
65 |
123
| public void setApplicationSpecification(ILibrarySpecification applicationSpecification)
|
|
66 |
| { |
|
67 |
123
| _applicationSpecification = applicationSpecification;
|
|
68 |
| } |
|
69 |
| |
|
70 |
| } |