26.8. Spring Application Context as a Seam Component
Although it is possible to use the Spring
ContextLoaderListener
to start your application's Spring ApplicationContext
, there are some limitations: the Spring ApplicationContext
must be started after the SeamListener
, and starting a Spring ApplicationContext
for use in Seam unit and integration tests can be complicated.
To overcome these limitations, the Spring integration includes a Seam component that can start a Spring
ApplicationContext
. To use this component, place the <spring:context-loader/>
definition in the components.xml
file. Specify your Spring context file location in the config-locations
attribute. If more than one configuration file is required, you can place them in the nested <spring:config-locations/>
element, as per standard components.xml
multi-value practices.
<components xmlns="http://jboss.com/products/seam/components" xmlns:spring="http://jboss.com/products/seam/spring" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.2.xsd http://jboss.com/products/seam/spring http://jboss.com/products/seam/spring-2.2.xsd"> <spring:context-loader config-locations= "/WEB-INF/applicationContext.xml"/> </components>