01: /*
02: * Copyright (c) 2002-2006 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.xwork.interceptor;
06:
07: import com.opensymphony.xwork.ActionInvocation;
08: import org.apache.commons.logging.Log;
09: import org.apache.commons.logging.LogFactory;
10:
11: /**
12: * An abstract interceptor that provides simple access to before/after callouts.
13: *
14: * @author Jason Carreira
15: */
16: public abstract class AroundInterceptor implements Interceptor {
17:
18: protected transient Log log = LogFactory.getLog(getClass());
19:
20: public void destroy() {
21: }
22:
23: public void init() {
24: }
25:
26: public String intercept(ActionInvocation invocation)
27: throws Exception {
28: String result = null;
29:
30: before(invocation);
31: result = invocation.invoke();
32: after(invocation, result);
33:
34: return result;
35: }
36:
37: /**
38: * Called after the invocation has been executed.
39: *
40: * @param result the result value returned by the invocation
41: */
42: protected abstract void after(ActionInvocation dispatcher,
43: String result) throws Exception;
44:
45: /**
46: * Called before the invocation has been executed.
47: */
48: protected abstract void before(ActionInvocation invocation)
49: throws Exception;
50: }
|