01: /*
02: * Copyright 1999-2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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:
17: package org.apache.coyote.tomcat3;
18:
19: import org.apache.coyote.Adapter;
20: import org.apache.tomcat.core.ContextManager;
21:
22: /** Adapter between Coyote and Tomcat.
23: *
24: * This class handles the task of passing of an individual request to
25: * Tomcat to handle. Also some of the connection-specific methods are
26: * delegated to here.
27: * @Author Bill Barker
28: */
29: public class Tomcat3Adapter implements Adapter {
30: ContextManager cm;
31:
32: Tomcat3Adapter(ContextManager ctxman) {
33: cm = ctxman;
34: }
35:
36: static int containerRequestNOTE = 1; // XXX Implement a NoteManager, namespaces.
37:
38: /** Pass off an individual request to Tomcat.
39: */
40: public void service(org.apache.coyote.Request request,
41: org.apache.coyote.Response response) throws Exception {
42: Tomcat3Request reqA;
43: Tomcat3Response resA;
44:
45: reqA = (Tomcat3Request) request.getNote(containerRequestNOTE);
46: if (reqA == null) {
47: reqA = new Tomcat3Request();
48: resA = new Tomcat3Response();
49: cm.initRequest(reqA, resA);
50:
51: reqA.setCoyoteRequest(request);
52: resA.setCoyoteResponse(response);
53: request.setNote(containerRequestNOTE, reqA);
54: } else {
55: resA = (Tomcat3Response) reqA.getResponse();
56: }
57:
58: if (reqA.scheme().isNull()) {
59: reqA.scheme().setString("http");
60: }
61: try {
62: cm.service(reqA, resA);
63: } finally {
64: reqA.recycle();
65: resA.recycle();
66: }
67: }
68: }
|