KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > jetty6 > JettyServletHandler


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.jetty6;
19
20 import java.io.IOException JavaDoc;
21
22 import javax.servlet.ServletException JavaDoc;
23 import javax.servlet.http.HttpServletRequest JavaDoc;
24 import javax.servlet.http.HttpServletResponse JavaDoc;
25
26 import org.mortbay.jetty.servlet.ServletHandler;
27
28 /**
29  * @version $Rev: 449059 $ $Date: 2006-09-23 05:23:09 +1000 (Sat, 23 Sep 2006) $
30  */

31 public class JettyServletHandler extends ServletHandler {
32
33     private final PreHandler chainedHandler;
34     
35     public JettyServletHandler(PreHandler chainedHandler) {
36         if (null == chainedHandler) {
37             chainedHandler = new NoOpChainedHandler();
38         }
39         this.chainedHandler = chainedHandler;
40         chainedHandler.setNextHandler(new ActualJettyServletHandler());
41     }
42
43     @Override JavaDoc
44     public void handle(String JavaDoc target, HttpServletRequest JavaDoc request,HttpServletResponse JavaDoc response, int type)
45         throws IOException JavaDoc {
46         try {
47             chainedHandler.handle(target, request, response, type);
48         } catch (ServletException JavaDoc e) {
49             throw (IOException JavaDoc) new IOException JavaDoc().initCause(e);
50         }
51     }
52
53     protected void doHandle(String JavaDoc target, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, int type)
54         throws IOException JavaDoc, ServletException JavaDoc {
55         super.handle(target, request, response, type);
56     }
57     
58     private class ActualJettyServletHandler extends AbstractPreHandler {
59
60         public void handle(String JavaDoc target, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, int type)
61                 throws IOException JavaDoc, ServletException JavaDoc {
62             doHandle(target, request, response, type);
63         }
64     }
65
66     private static class NoOpChainedHandler extends AbstractPreHandler {
67
68         public void handle(String JavaDoc target, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, int type)
69                 throws IOException JavaDoc, ServletException JavaDoc {
70             next.handle(target, request, response, type);
71         }
72     }
73     
74 }
75
Popular Tags