LibraryToggle FramesPrintFeedback

The servlet container looks in the WEB-INF/web.xml file to determine what classes are needed to activate the Web application. When deploying a Fuse Services Framework based application using the Spring context listener, the servlet container needs to load the org.springframework.web.context.ContextLoaderListener class. This is specified using the listener element and its listener-class child.

The org.springframework.web.context.ContextLoaderListener class uses a context parameter called contextConfigLocation to determine the location of the Spring configuration file. The context parameter is configured using the context-parameter element. The context-param element has two children that specify parameters and their values. The param-name element specifies the parameter's name. The param-value element specifies the parameter's value.

Example 5.5 shows a web.xml file that configures the servlet container to load the Spring listener and a Spring configuration file.

Example 5.5. Web Application Configuration for Loading the Spring Context Listener

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <context-param> 1
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/beans.xml</param-value>
  </context-param>

  <listener> 2
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  ...
</web-app>

The XML in Example 5.5 does the following:

1

Specifies that the Spring context listener will load the application's Spring configuration from WEB-INF/beans.xml.

2

Specifies that the servlet container should load the Spring context listener.

The Spring configuration file for a application using the Spring context listener is similar to a standard Fuse Services Framework configuration file. It uses all of the same endpoint configuration elements described in Configuring JAX-WS Endpoints. It can also contain standard Spring beans.

The difference between a typical Fuse Services Framework configuration file and a configuration file for using the Spring context listener is that the Spring context listener configuration must import the configuration for all of the Fuse Services Framework runtime components used by the endpoint's exposed by the application. These components are imported into the configuration as resources using an import element for each component's configuration.

Example 5.6 shows the configuration for a simple consumer endpoint being deployed using the Spring context listener.


The import elements at the beginning of Example 5.6 import the required Fuse Services Framework component configuration. The required Fuse Services Framework component configuration files depends on the features being used by the endpoints. At a minimum, an application in a servlet container will need the components shown in Example 5.6.

[Tip]Tip

Importing the cxf-all.xml configuration file will automatically import all of the Fuse Services Framework components.

Comments powered by Disqus
loading table of contents...