@Intercepts(value={RequestInit,ActionBeanResolution,HandlerResolution,BindingAndValidation,CustomValidation,EventHandling,ResolutionExecution,RequestComplete}) public class BeforeAfterMethodInterceptor extends java.lang.Object implements Interceptor
Interceptor that inspects ActionBeans for Before
and After
annotations and
runs the annotated methods at the requested point in the request lifecycle. There is no limit
on the number of methods within an ActionBean that can be marked with @Before
and
@After
annotations, and individual methods may be marked with one or both annotations.
To configure the BeforeAfterMethodInterceptor for use you will need to add the following to
your web.xml
(assuming no other interceptors are yet configured):
<init-param> <param-name>Interceptor.Classes</param-name> <param-value>net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor</param-value> </init-param>
If one or more interceptors are already configured in your web.xml
simply separate
the fully qualified names of the interceptors with commas (additional whitespace is ok).
Modifier and Type | Class and Description |
---|---|
protected static class |
BeforeAfterMethodInterceptor.FilterMethods
Helper class used to collect Before and After methods for a class and provide easy
and rapid access to them by LifecycleStage.
|
Constructor and Description |
---|
BeforeAfterMethodInterceptor() |
Modifier and Type | Method and Description |
---|---|
protected BeforeAfterMethodInterceptor.FilterMethods |
getFilterMethods(java.lang.Class<? extends ActionBean> beanClass)
Gets the Before/After methods for the ActionBean.
|
Resolution |
intercept(ExecutionContext context)
Does the main work of the interceptor as described in the class level javadoc.
|
protected Resolution |
invoke(ActionBean bean,
java.lang.reflect.Method m,
LifecycleStage stage,
java.lang.Class<? extends java.lang.annotation.Annotation> when)
Helper method that will invoke the supplied method and manage any exceptions and
returns from the object.
|
public Resolution intercept(ExecutionContext context) throws java.lang.Exception
intercept
in interface Interceptor
context
- the current ExecutionContextjava.lang.Exception
- if one of the before/after methods raises an exceptionprotected Resolution invoke(ActionBean bean, java.lang.reflect.Method m, LifecycleStage stage, java.lang.Class<? extends java.lang.annotation.Annotation> when) throws java.lang.Exception
java.lang.Exception
protected BeforeAfterMethodInterceptor.FilterMethods getFilterMethods(java.lang.Class<? extends ActionBean> beanClass)
@Before
or @After
.beanClass
- The action bean class to get methods for.? Copyright 2005-2006, Stripes Development Team.