Versions Compared

Key

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

...

Where you have a Spring bean defined in your applicationContext.xml named "bar". Note that the com.acme.Foo action did not need to be changed, because it can be autowired.

A typical spring configuration for bar could look as following.

Code Block
langxml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="autodetect">
    <bean id="bar" class="com.my.BarClass" singleton="false"/>
    ...
</beans>
Note
TitleTake Note

Note the id attribute in the spring configuration corresponds to the class attribute in xwork configuration. Also note that in the spring configuration, the singleton attribute is set to false. This would mostly be the case that is desired as Webwork creates a new action class upon each request. Hence when Spring integration is used, this would be the desired behaviour. Making Springs singleton attribute false would allow this.

Remember: this is not required. This is only needed if you wish to override the default behavior when the action is created in WebWork by decorating it with Spring-enabled interceptors and IoC that cannot be automatically determined by Spring. Keep in mind that WebWork's Spring integration will do standard IoC, using whatever auto-wiring you specify, even if you don't explicitely map each action in Spring. So typically you don't need to do this, but it is good to know how this can be done if you need to.