Versions Compared

Key

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

...

Code Block
xml
xml
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Tip
titleMore ApplicationContext configuration files needed?

Since Spring integration uses standard Listener, it can be configured to support configuration files other than applicationContext.xml.
Adding the following to your web.xml will cause Spring ApplicationContext to be inititalized from all files matching the given pattern:

Code Block
xml
xml

<!-- Context Configuration locations for Spring XML files -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext-*.xml</param-value>
</context-param>
See Spring documentation for a full description of this parameter.

Sample Spring Configuration

...

Code Block
xml
xml
<?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="personManager" class="com.acme.PersonManager"/>
    ...
</beans>

Switching from Builtin IoC to Spring

Switching is quite easy. Spring setup is done as described above. To complete migration, you will have to

  1. transfer your configured components from components.xml to applictationContext.xml appropriately. You can safely delete components.xml afterwards.
  2. remove the Component Interceptor from your interceptor stack in xwork.xml. Although it does not hurt to leave it there, it is simply redundant from now on.
Note
titleSession Scope & Spring

Spring does not support session scoped components right now. There are plans for integrating this in Spring 1.3 release. Right now, you will have to use Spring Session Components Workarounds.

Initializing Actions from Spring

...