Classes in this File | Line Coverage | Branch Coverage | Complexity | |||||||
ServletConnection |
|
| 1.0;1 |
1 | /* |
|
2 | * Copyright 1999,2005 The Apache Software Foundation. |
|
3 | * |
|
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | * you may not use this file except in compliance with the License. |
|
6 | * You may obtain a copy of the License at |
|
7 | * |
|
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 | * |
|
10 | * Unless required by applicable law or agreed to in writing, software |
|
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 | * See the License for the specific language governing permissions and |
|
14 | * limitations under the License. |
|
15 | */ |
|
16 | package org.apache.xmlrpc.webserver; |
|
17 | ||
18 | import java.io.IOException; |
|
19 | import java.net.Socket; |
|
20 | ||
21 | import javax.servlet.http.HttpServlet; |
|
22 | import javax.servlet.http.HttpServletRequest; |
|
23 | import javax.servlet.http.HttpServletResponse; |
|
24 | ||
25 | import org.apache.xmlrpc.util.ThreadPool.Task; |
|
26 | ||
27 | ||
28 | /** {@link org.apache.xmlrpc.webserver.ServletWebServer ServletWebServer's} |
|
29 | * {@link org.apache.xmlrpc.util.ThreadPool.Task} for handling a single |
|
30 | * servlet connection. |
|
31 | */ |
|
32 | public class ServletConnection implements Task { |
|
33 | private final HttpServlet servlet; |
|
34 | private final Socket socket; |
|
35 | private final HttpServletRequest request; |
|
36 | private final HttpServletResponse response; |
|
37 | ||
38 | /** Creates a new instance. |
|
39 | * @param pServlet The servlet, which ought to handle the request. |
|
40 | * @param pSocket The socket, to which the client is connected. |
|
41 | * @throws IOException |
|
42 | */ |
|
43 | 70 | public ServletConnection(HttpServlet pServlet, Socket pSocket) throws IOException { |
44 | 70 | servlet = pServlet; |
45 | 70 | socket = pSocket; |
46 | 70 | request = new HttpServletRequestImpl(socket); |
47 | 70 | response = new HttpServletResponseImpl(socket); |
48 | 70 | } |
49 | ||
50 | public void run() throws Throwable { |
|
51 | 70 | servlet.service(request, response); |
52 | 70 | } |
53 | } |