com.opensymphony.xwork.spring.interceptor
Class ActionAutowiringInterceptor

java.lang.Object
  extended by com.opensymphony.xwork.interceptor.AroundInterceptor
      extended by com.opensymphony.xwork.spring.interceptor.ActionAutowiringInterceptor
All Implemented Interfaces:
Interceptor, java.io.Serializable, org.springframework.context.ApplicationContextAware

public class ActionAutowiringInterceptor
extends AroundInterceptor
implements org.springframework.context.ApplicationContextAware

TODO: Give a description of the Interceptor. TODO: Describe the paramters for this Interceptor. TODO: Discuss some possible extension of the Interceptor.

 
 <!-- TODO: Describe how the Interceptor reference will effect execution -->
 <action name="someAction" class="com.examples.SomeAction">
      TODO: fill in the interceptor reference.
     <interceptor-ref name=""/>
     <result name="success">good_result.ftl</result>
 </action>
 
 
Autowires action classes to Spring beans. The strategy for autowiring the beans can be configured by setting the parameter on the interceptor. Actions that need access to the ActionContext can implements the ApplicationContextAware interface. The context will also be placed on the action context under the APPLICATION_CONTEXT attribute.

Author:
Simon Stewart, Eric Hauser
See Also:
Serialized Form

Field Summary
static java.lang.String APPLICATION_CONTEXT
           
 
Constructor Summary
ActionAutowiringInterceptor()
           
 
Method Summary
protected  void after(ActionInvocation dispatcher, java.lang.String result)
          Called after the invocation has been executed.
protected  void before(ActionInvocation invocation)
          Looks for the ApplicationContext under the attribute that the Spring listener sets in the servlet context.
protected  org.springframework.context.ApplicationContext getApplicationContext()
           
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
           
 void setAutowireStrategy(java.lang.Integer autowireStrategy)
           
 
Methods inherited from class com.opensymphony.xwork.interceptor.AroundInterceptor
destroy, init, intercept
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APPLICATION_CONTEXT

public static final java.lang.String APPLICATION_CONTEXT
See Also:
Constant Field Values
Constructor Detail

ActionAutowiringInterceptor

public ActionAutowiringInterceptor()
Method Detail

setAutowireStrategy

public void setAutowireStrategy(java.lang.Integer autowireStrategy)
Parameters:
autowireStrategy -

after

protected void after(ActionInvocation dispatcher,
                     java.lang.String result)
              throws java.lang.Exception
Description copied from class: AroundInterceptor
Called after the invocation has been executed.

Specified by:
after in class AroundInterceptor
Parameters:
dispatcher -
result -
Throws:
java.lang.Exception

before

protected void before(ActionInvocation invocation)
               throws java.lang.Exception
Looks for the ApplicationContext under the attribute that the Spring listener sets in the servlet context. The configuration is done the first time here instead of in init() since the ActionContext is not available during Interceptor initialization.

Autowires the action to Spring beans and places the ApplicationContext on the ActionContext

TODO Should this check to see if the SpringObjectFactory has already been configured instead of instantiating a new one? Or is there a good reason for the interceptor to have it's own factory?

Specified by:
before in class AroundInterceptor
Parameters:
invocation -
Throws:
java.lang.Exception

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Parameters:
applicationContext -
Throws:
org.springframework.beans.BeansException

getApplicationContext

protected org.springframework.context.ApplicationContext getApplicationContext()
Returns:
context

XWork Project Page