KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > pageflow > interceptor > request > RequestInterceptor


1 /*
2  * Copyright 2004 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  * $Header:$
17  */

18 package org.apache.beehive.netui.pageflow.interceptor.request;
19
20 import org.apache.beehive.netui.pageflow.interceptor.Interceptor;
21 import org.apache.beehive.netui.pageflow.interceptor.InterceptorChain;
22 import org.apache.beehive.netui.pageflow.interceptor.InterceptorException;
23 import org.apache.beehive.netui.pageflow.interceptor.InterceptorContext;
24 import org.apache.beehive.netui.pageflow.interceptor.InterceptorConfig;
25 import org.apache.beehive.netui.pageflow.interceptor.AbstractInterceptor;
26
27 import java.io.Serializable JavaDoc;
28
29
30 /**
31  * A request interceptor, which can run before and/or after a request. Request interceptors are configured in the
32  * <code>&lt;request-interceptors&gt;</code> element of WEB-INF/beehive-netui-config.xml.
33  */

34 public abstract class RequestInterceptor
35         extends AbstractInterceptor
36 {
37     /**
38      * Callback invoked before the request is processed. During this method, {@link #cancelRequest} may be called to
39      * cancel further request processing. {@link InterceptorChain#continueChain} is called to invoke the rest of the
40      * interceptor chain, anywhere within this method (e.g., at the end, or within a try/finally).
41      */

42     public abstract void preRequest( RequestInterceptorContext context, InterceptorChain chain )
43             throws InterceptorException;
44     
45     /**
46      * Callback invoked before the request is processed. {@link #preRequest} may be used instead.
47      */

48     public void preInvoke( InterceptorContext context, InterceptorChain chain ) throws InterceptorException
49     {
50         preRequest( ( RequestInterceptorContext ) context, chain );
51     }
52     
53     /**
54      * Callback invoked after the request is processed. {@link InterceptorChain#continueChain} should be called to
55      * invoke the rest of the interceptor chain, anywhere within this method (e.g., at the end, or within a try/finally).
56      */

57     public abstract void postRequest( RequestInterceptorContext context, InterceptorChain chain )
58         throws InterceptorException;
59     
60     /**
61      * Callback invoked after the request is processed. {@link #postRequest} may be used instead.
62      */

63     public void postInvoke( InterceptorContext context, InterceptorChain chain ) throws InterceptorException
64     {
65         postRequest( ( RequestInterceptorContext ) context, chain );
66     }
67
68     /**
69      * Cancel the request. After this is called, no further processing will happen in the request.
70      * @param context the current RequestInterceptorContext.
71      */

72     protected void cancelRequest( RequestInterceptorContext context )
73     {
74         context.cancelRequest( this );
75     }
76 }
77
Popular Tags