Versions Compared

Key

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

...

Code Block
xml
xml
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

    <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
    <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
	
    <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl">
        <property name="inInterceptors">
            <list>
                <ref bean="logInbound"/>
            </list>
        </property>
        <property name="outInterceptors">
            <list>
                <ref bean="logOutbound"/>
            </list>
        </property>
        <property name="outFaultInterceptors">
            <list>
                <ref bean="logOutbound"/>
            </list>
        </property>
        <property name="inFaultInterceptors">
            <list>
                <ref bean="logInbound"/>
            </list>
        </property>
    </bean> 
</beans>

In this example, you specify that the CXF bus is implemented by class org.apache.cxf.bus.CXFBusImpl, and that it's id is "cxf". This is the default, but you have to re-iterate the fact if you want the bus to contribute the logging interceptors to the outbound and inbound interceptor chain for all client and server endpoints. You can avoid this duplication by using the next form of configuration:

...

Code Block
xml
xml
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:cxf="http://cxf.apache.org/core"
      xsi:schemaLocation="
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

    <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
    <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>

    <cxf:bus>
        <cxf:inInterceptors>
            <ref bean="logInbound"/>
        </cxf:inInterceptors>
        <cxf:outInterceptors>
            <ref bean="logOutbound"/>
        </cxf:outInterceptors>
        <cxf:outFaultInterceptors>
            <ref bean="logOutbound"/>
        </cxf:outFaultInterceptors>
        <cxf:inFaultInterceptors>
            <ref bean="logOutboundlogInbound"/>
        </cxf:inFaultInterceptors>
    </cxf:bus> 
</beans>

Here, there is no need to specify the implementation class of the bus - nor the fact that the inInterceptors, outInterceptors, outFaultInterceptors, and inFaultInterceptors child elements are of type list. All of this information is embedded in the underlying schema and the bean definition parser that's invoked for <cxf:bus> elemens. Note that you have to specify the location of this schema in the schemaLocation attribute of the <beans> element so that Spring can validate the configuration file. But it gets even simpler in the next example:

...