01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: * $Header:$
18: */
19: package org.apache.beehive.netui.pageflow.interceptor.action;
20:
21: import org.apache.beehive.netui.pageflow.interceptor.InterceptorException;
22: import org.apache.beehive.netui.pageflow.interceptor.InterceptorChain;
23:
24: import java.net.URI;
25: import java.net.URISyntaxException;
26:
27: class SimpleActionInterceptor extends ActionInterceptor {
28: public SimpleActionInterceptor(SimpleActionInterceptorConfig config) {
29: init(config);
30: }
31:
32: public void preAction(ActionInterceptorContext context,
33: InterceptorChain chain) throws InterceptorException {
34: if (!getActionInterceptorConfig().isAfterAction())
35: doit(context, chain);
36: }
37:
38: public void postAction(ActionInterceptorContext context,
39: InterceptorChain chain) throws InterceptorException {
40: if (getActionInterceptorConfig().isAfterAction())
41: doit(context, chain);
42: }
43:
44: private void doit(ActionInterceptorContext context,
45: InterceptorChain chain) throws InterceptorException {
46: try {
47: String path = getActionInterceptorConfig().getPath();
48: setOverrideForward(new InterceptorForward(new URI(path)),
49: context);
50: chain.continueChain();
51: } catch (URISyntaxException e) {
52: throw new InterceptorException(e);
53: }
54: }
55:
56: public void afterNestedIntercept(AfterNestedInterceptContext context)
57: throws InterceptorException {
58: }
59:
60: public SimpleActionInterceptorConfig getActionInterceptorConfig() {
61: return (SimpleActionInterceptorConfig) super.getConfig();
62: }
63: }
|