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.ajp.tomcat4;
18:
19: import java.io.IOException;
20:
21: import javax.servlet.ServletException;
22: import javax.servlet.http.HttpServlet;
23: import javax.servlet.http.HttpServletRequest;
24: import javax.servlet.http.HttpServletResponse;
25:
26: import org.apache.catalina.Container;
27: import org.apache.catalina.ContainerServlet;
28: import org.apache.catalina.Context;
29: import org.apache.catalina.Wrapper;
30:
31: /**
32: * Module loader for JkServlet
33: *
34: * @author Costin Manolache
35: */
36: public class JkServlet extends HttpServlet implements ContainerServlet {
37: // -------------------- ContainerServlet interface --------------------
38: Wrapper wrapper;
39:
40: public Wrapper getWrapper() {
41: if (dL > 0)
42: d("getWrapper()");
43: return wrapper;
44: }
45:
46: public void setWrapper(Wrapper wrapper) {
47: if (dL > 0)
48: d("setWrapper() " + wrapper);
49: this .wrapper = wrapper;
50: }
51:
52: Context ctx;
53:
54: /**
55: * Initialize this servlet.
56: */
57: public void init() throws ServletException {
58: super .init();
59: if (wrapper == null) {
60: log("No wrapper available, make sure the app is trusted");
61: System.out
62: .println("No wrapper available, make sure the app is trusted");
63: return;
64: }
65:
66: ctx = (Context) wrapper.getParent();
67:
68: if (dL > 0) {
69: d("Wrapper: " + wrapper.getClass().getName() + " "
70: + wrapper);
71: d("Ctx: " + ctx.getClass().getName() + " " + ctx);
72: Object parent = ctx.getParent();
73: d("P: " + parent.getClass().getName() + " " + parent);
74: while (parent instanceof Container) {
75: parent = ((Container) parent).getParent();
76: d("P: " + parent.getClass().getName() + " " + parent);
77: }
78: }
79:
80: }
81:
82: public void service(HttpServletRequest request,
83: HttpServletResponse response) throws IOException,
84: ServletException {
85: throw new ServletException("Shouldn't be called direclty");
86: }
87:
88: private static final int dL = 10;
89:
90: private static void d(String s) {
91: System.err.println("JkServlet: " + s);
92: }
93:
94: }
|