Struts Action Invocation Framework (SAIF)
The Struts Action Invocation Framework looks to improve how Struts
handles Actions adding features like Action interceptors and
Inversion of Control (IoC). Learning from other web frameworks like
WebWork 2/XWork, SAIF hopes to be a testbed for the integration of
the best features of other web frameworks into Struts.
SAIF currently only supports the 1.1 version
of Struts and is released under the
- Action interceptors
- WW2-style inversion of control
- Supports both regular Struts and Tiles
- Includes modified Struts example
The distribution can be found
The minimal release doesn't contain any Struts jars or the compiled struts example war.
SAIF requres Struts 1.1 or greater and is not compatible with any other plugin
uses a custom request processor.
To use SAIF, you must configure it as a Struts plugin, configure the interceptor config
file, and write any interceptors you need.
Struts Plug-In Configuration
SAIF needs to be configured as a plugin in the Struts configuration
file. In the plug-in configuration, the location of the interceptor
configuration file needs to be defined. It should look something like this:
<set-property property="interceptor-config" value="/WEB-INF/interceptor-config.xml" />
All interceptors are defined in interceptor-config.xml (of course it could have any name). This file contains the interceptor definitions and how they should be applied. There are two ways to declare interceptors for Struts Actions: globally and by Action. When the Action is requested, first any global interceptors will be applied, then Action-specific interceptors.
The following interceptors are included in SAIF:
Performs inversion of control functionality. Sets any components the Action has defined it needs.
This is an example of an interceptor configuration file:
<interceptor name="componentInterceptor" type="net.sf.struts.saif.ComponentInterceptor"/>
<interceptor name="testInterceptor" type="net.sf.struts.saif.TestInterceptor"/>
Interceptors can perform actions before and after a Struts Action is called. To write an interceptor, simple implement the net.sf.struts.saif.ActionInterceptor interface and implement the beforeAction() and afterAction() methods.
This is an example of an interceptor implementation:
public class TestInterceptor implements ActionInterceptor
public void beforeAction(Action action, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
public void afterAction(Action action, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
private Log log = LogFactory.getLog(TestInterceptor.class);