KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > pageflow > interceptor > Interceptors


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;
19
20
21 import java.util.List JavaDoc;
22
23 public class Interceptors
24 {
25     public static void doPreIntercept( InterceptorContext context, List JavaDoc/*< Interceptor >*/ interceptors )
26             throws InterceptorException
27     {
28         if ( interceptors != null )
29         {
30             PreInvokeInterceptorChain chain = new PreInvokeInterceptorChain( context, interceptors );
31             chain.continueChain();
32         }
33     }
34     
35     public static void doPostIntercept( InterceptorContext context, List JavaDoc/*< Interceptor >*/ interceptors )
36         throws InterceptorException
37     {
38         if ( interceptors != null )
39         {
40             PostInvokeInterceptorChain chain = new PostInvokeInterceptorChain( context, interceptors );
41             chain.continueChain();
42         }
43     }
44     
45     private static final class PreInvokeInterceptorChain
46             extends InterceptorChain
47     {
48         public PreInvokeInterceptorChain( InterceptorContext context, List JavaDoc/*< Interceptor >*/ interceptors )
49         {
50             super( context, interceptors );
51         }
52         
53         protected Object JavaDoc invoke( Interceptor interceptor )
54                 throws InterceptorException
55         {
56             interceptor.preInvoke( getContext(), this );
57             return null;
58         }
59     }
60     
61     private static final class PostInvokeInterceptorChain
62             extends InterceptorChain
63     {
64         public PostInvokeInterceptorChain( InterceptorContext context, List JavaDoc/*< Interceptor >*/ interceptors )
65         {
66             super( context, interceptors );
67         }
68         
69         protected Object JavaDoc invoke( Interceptor interceptor )
70                 throws InterceptorException
71         {
72             interceptor.postInvoke( getContext(), this );
73             return null;
74         }
75     }
76 }
77
Popular Tags