|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
InvokeEngineTerminator.java | - | 100% | 100% | 100% |
|
1 |
// Copyright 2004, 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 |
import java.io.IOException;
|
|
17 |
|
|
18 |
import javax.servlet.ServletException;
|
|
19 |
import javax.servlet.http.HttpServlet;
|
|
20 |
import javax.servlet.http.HttpServletRequest;
|
|
21 |
import javax.servlet.http.HttpServletResponse;
|
|
22 |
|
|
23 |
import org.apache.tapestry.Constants;
|
|
24 |
import org.apache.tapestry.IEngine;
|
|
25 |
import org.apache.tapestry.request.RequestContext;
|
|
26 |
import org.apache.tapestry.services.EngineManager;
|
|
27 |
import org.apache.tapestry.services.Infrastructure;
|
|
28 |
import org.apache.tapestry.services.RequestServicer;
|
|
29 |
import org.apache.tapestry.spec.IApplicationSpecification;
|
|
30 |
|
|
31 |
/**
|
|
32 |
* The terminatior for the <code>tapestry.RequestProcessor</code> pipeline,
|
|
33 |
* this service is responsible for locating the correct engine instance and
|
|
34 |
* letting it to the rest of the request.
|
|
35 |
*
|
|
36 |
* @author Howard Lewis Ship
|
|
37 |
* @since 3.1
|
|
38 |
*/
|
|
39 |
public class InvokeEngineTerminator implements RequestServicer |
|
40 |
{ |
|
41 |
private HttpServlet _servlet;
|
|
42 |
private EngineManager _engineManager;
|
|
43 |
private IApplicationSpecification _specification;
|
|
44 |
private Infrastructure _infrastructure;
|
|
45 |
|
|
46 | 185 |
public void service(HttpServletRequest request, HttpServletResponse response) |
47 |
throws IOException, ServletException
|
|
48 |
{ |
|
49 | 185 |
IEngine engine = _engineManager.getEngineInstance(); |
50 |
|
|
51 | 185 |
request.setAttribute(Constants.INFRASTRUCTURE_KEY, _infrastructure); |
52 |
|
|
53 | 185 |
RequestContext context = new RequestContext(_servlet, request, response, _specification);
|
54 |
|
|
55 | 185 |
try
|
56 |
{ |
|
57 | 185 |
engine.service(context); |
58 |
} |
|
59 |
finally
|
|
60 |
{ |
|
61 | 185 |
_engineManager.storeEngineInstance(engine); |
62 |
|
|
63 | 185 |
context.cleanup(); |
64 |
} |
|
65 |
|
|
66 |
} |
|
67 |
|
|
68 | 52 |
public void setEngineManager(EngineManager manager) |
69 |
{ |
|
70 | 52 |
_engineManager = manager; |
71 |
} |
|
72 |
|
|
73 | 52 |
public void setServlet(HttpServlet servlet) |
74 |
{ |
|
75 | 52 |
_servlet = servlet; |
76 |
} |
|
77 |
|
|
78 | 52 |
public void setSpecification(IApplicationSpecification specification) |
79 |
{ |
|
80 | 52 |
_specification = specification; |
81 |
} |
|
82 |
|
|
83 | 52 |
public void setInfrastructure(Infrastructure infrastructure) |
84 |
{ |
|
85 | 52 |
_infrastructure = infrastructure; |
86 |
} |
|
87 |
|
|
88 |
} |
|
89 |
|
|