KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > pageflow > interceptor > action > SimpleActionInterceptor


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.action;
19
20 import org.apache.beehive.netui.pageflow.interceptor.InterceptorException;
21 import org.apache.beehive.netui.pageflow.interceptor.InterceptorChain;
22
23 import java.net.URI JavaDoc;
24 import java.net.URISyntaxException JavaDoc;
25
26 class SimpleActionInterceptor
27         extends ActionInterceptor
28 {
29     public SimpleActionInterceptor( SimpleActionInterceptorConfig config )
30     {
31         init( config );
32     }
33
34     public void preAction( ActionInterceptorContext context, InterceptorChain chain )
35             throws InterceptorException
36     {
37         if ( ! getActionInterceptorConfig().isAfterAction() ) doit( context, chain );
38     }
39
40     public void postAction( ActionInterceptorContext context, InterceptorChain chain )
41             throws InterceptorException
42     {
43         if ( getActionInterceptorConfig().isAfterAction() ) doit( context, chain );
44     }
45     
46     private void doit( ActionInterceptorContext context, InterceptorChain chain )
47         throws InterceptorException
48     {
49         try
50         {
51             String JavaDoc path = getActionInterceptorConfig().getPath();
52             setOverrideForward( new InterceptorForward( new URI JavaDoc( path ) ), context );
53             chain.continueChain();
54         }
55         catch ( URISyntaxException JavaDoc e )
56         {
57             throw new InterceptorException( e );
58         }
59     }
60
61     public void afterNestedIntercept( AfterNestedInterceptContext context ) throws InterceptorException
62     {
63     }
64     
65     public SimpleActionInterceptorConfig getActionInterceptorConfig()
66     {
67         return ( SimpleActionInterceptorConfig ) super.getConfig();
68     }
69 }
70
Popular Tags