|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.xwork2.interceptor.annotations.AnnotationWorkflowInterceptor
public class AnnotationWorkflowInterceptor
Invokes any annotated methods on the action. Specifically, it supports the following annotations:
Before
- will be invoked before the action method. If the returned value is not null, it is
returned as the action result codeBeforeResult
- will be invoked after the action method but before the result executionAfter
- will be invoked after the action method and result executionThere can be multiple methods marked with the same annotations, but the order of their execution
is not guaranteed. However, the annotated methods on the superclass chain are guaranteed to be invoked before the
annotated method in the current class in the case of a Before
annotations and after, if the annotations is
After
.
public class BaseAnnotatedAction { protected String log = ""; @Before public String baseBefore() { log = log + "baseBefore-"; return null; } } public class AnnotatedAction extends BaseAnnotatedAction { @Before public String before() { log = log + "before"; return null; } public String execute() { log = log + "-execute"; return Action.SUCCESS; } @BeforeResult public void beforeResult() throws Exception { log = log +"-beforeResult"; } @After public void after() { log = log + "-after"; } }
With the interceptor applied and the action executed on AnnotatedAction
the log
instance variable will contain baseBefore-before-execute-beforeResult-after
.
<interceptor-stack name="annotatedStack"> <interceptor-ref name="staticParams"/> <interceptor-ref name="params"/> <interceptor-ref name="conversionError"/> <interceptor-ref name="annotationWorkflow"/> </interceptor-stack>
Constructor Summary | |
---|---|
AnnotationWorkflowInterceptor()
|
Method Summary | |
---|---|
void |
beforeResult(ActionInvocation invocation,
String resultCode)
Invokes any @BeforeResult annotated methods |
protected static int |
comparePriorities(int val1,
int val2)
|
void |
destroy()
Called to let an interceptor clean up any resources it has allocated. |
void |
init()
Called after an interceptor is created, but before any requests are processed using intercept , giving
the Interceptor a chance to initialize any needed resources. |
String |
intercept(ActionInvocation invocation)
Discovers annotated methods on the action and calls them according to the workflow |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AnnotationWorkflowInterceptor()
Method Detail |
---|
public String intercept(ActionInvocation invocation) throws Exception
intercept
in interface Interceptor
invocation
- the action invocation
ActionInvocation.invoke()
, or from the interceptor itself.
Exception
- any system-level error, as defined in Action.execute()
.Interceptor.intercept(com.opensymphony.xwork2.ActionInvocation)
public void destroy()
Interceptor
destroy
in interface Interceptor
public void init()
Interceptor
intercept
, giving
the Interceptor a chance to initialize any needed resources.
init
in interface Interceptor
protected static int comparePriorities(int val1, int val2)
public void beforeResult(ActionInvocation invocation, String resultCode)
beforeResult
in interface PreResultListener
invocation
- the action invocationresultCode
- the result code returned by the action (eg. success
).PreResultListener.beforeResult(com.opensymphony.xwork2.ActionInvocation,String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |