WebWork 2 : Interceptors
This page last changed on Dec 14, 2004 by casey.
OverviewInterceptors are objects that dynamically intercept Action invocations. They provide the developer with the opportunity to define code that can be executed before and/or after the execution of an action. They also have the ability to prevent an action from executing. Interceptors provide developers a way to encapulate common functionality in a re-usable form that can be applied to one or more Actions. See XW:Interceptors for further details. Below describes built in Webwork interceptors.Webwork & XWork InterceptorsInterceptor classes are also defined using a key-value pair specified in the xwork configuration file. The names specified below come specified in webwork-default.xml. If you extend the webwork-default package, then you can use the names below. Otherwise they must be defined in your package with a name-class pair specified in the <interceptors> tag.
Order of Interceptor ExecutionInterceptors provide an excellent means to wrap before/after processing. The concept reduces code duplication (think AOP).<interceptor-stack name="xaStack"> <interceptor-ref name="thisWillRunFirstInterceptor"/> <interceptor-ref name="thisWillRunNextInterceptor"/> <interceptor-ref name="followedByThisInterceptor"/> <interceptor-ref name="thisWillRunLastInterceptor"/> </interceptor-stack> Note that some interceptors will interrupt the stack/chain/flow… so the order is very important. Iterceptors implementing com.opensymphony.xwork.interceptor.PreResultListener will run after the Action executes its action method but before the Result executesthisWillRunFirstInterceptor thisWillRunNextInterceptor followedByThisInterceptor thisWillRunLastInterceptor MyAction1 MyAction2 (chain) MyPreResultListener MyResult (result) thisWillRunLastInterceptor followedByThisInterceptor thisWillRunNextInterceptor thisWillRunFirstInterceptor |
![]() |
Document generated by Confluence on Dec 14, 2004 16:36 |