KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > web > WebPipeline


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.web;
25
26 import java.io.IOException JavaDoc;
27 import javax.servlet.ServletException JavaDoc;
28 import javax.servlet.http.HttpServletRequest JavaDoc;
29 import org.apache.catalina.Container;
30 import org.apache.catalina.Request;
31 import org.apache.catalina.Response;
32 import org.apache.catalina.core.StandardPipeline;
33
34 /**
35  * Pipeline whose invoke logic checks if a given request path represents
36  * an ad-hoc path: If so, this pipeline delegates the request to the
37  * ad-hoc pipeline of its associated web module. Otherwise, this pipeline
38  * processes the request.
39  */

40 public class WebPipeline extends StandardPipeline {
41
42     private WebModule webModule;
43     
44     /**
45      * creates an instance of WebPipeline
46      * @param container
47      */

48     public WebPipeline(Container container) {
49         super(container);
50         if(container instanceof WebModule) {
51             this.webModule = (WebModule)container;
52         }
53     }
54
55     /**
56      * Processes the specified request, and produces the appropriate
57      * response, by invoking the first valve (if any) of this pipeline, or
58      * the pipeline's basic valve.
59      *
60      * If the request path to process identifies an ad-hoc path, the
61      * web module's ad-hoc pipeline is invoked.
62      *
63      * @param request The request to process
64      * @param response The response to return
65      */

66     public void invoke(Request JavaDoc request, Response response)
67             throws IOException JavaDoc, ServletException JavaDoc {
68
69         HttpServletRequest JavaDoc hreq = (HttpServletRequest JavaDoc) request.getRequest();
70         if (webModule != null && webModule.getAdHocServletName(hreq.getServletPath()) != null) {
71             webModule.getAdHocPipeline().invoke(request, response);
72         } else {
73             doInvoke(request, response);
74         }
75     }
76 }
77
Popular Tags