Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Another advantage of the SpringObjectFactory approach is that it can also be used to load interceptors using the same sort of logic. If the interceptor is stateless, then it's possible to create the interceptor as a singelton instance, but otherwise it's best to create it as a Spring prototype.
In order to be used, the default ObjectFactory that XWork WebWork uses should be replaced with an instance of the SpringObjectFactory. The xwork-optional package ships with a ContextListener that does this, assuming that the Spring application context has already been configured. Add the following to web.xml:

Code Block
xml
xml
<!-- This needs to be after Spring ContextLoaderListener -->
<listener>
  <listener-class>com.opensymphony.xwork.spring.SpringObjectFactoryListener</listener-class>
</listener>

Note: this is actually an XWork configuration but for simplicity, I just mention WebWork.