|
Page Edited :
CXF20DOC :
Bus Configuration
Bus Configuration has been edited by Glen Mazza (Nov 21, 2007). Change summary: Added hardcoded sample for bus configuration. Configuring the BusThe Bus is the backbone of CXF architecture. It manages extensions and acts as an interceptor provider. The interceptors for the bus will be added to the respective inbound and outbound message and fault interceptor chains for all client and server endpoints created on the bus (in its context). By default, it contributes no interceptors to either of these interceptor chain types, but they can be added via configuration files or with Java code, as shown below. Note: For endpoint-specific configuration (as opposed to configuration for all for endpoints created by the CXF bus), look at the Logging Messages section for code samples. Using a Configuration FileHere, simply define a bus element in your Spring configuration file, and add child elements as required,for example: <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="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
<cxf:bus>
<cxf:outInterceptors>
<ref bean="logOutbound"/>
</cxf:outInterceptors>
</cxf:bus>
</beans>
The configurable properties of the bus are defined in the bus configuration schema http://cxf.apache.org/schemas/core.xsd The <bus> element supports the following child elements:
Configuration using Java codeAlthough usually less convenient, interceptors can be added to the bus using Java code. Given an EndpointImpl import javax.xml.ws.Endpoint; import org.apache.cxf.interceptor.LoggingInInterceptor; import org.apache.cxf.interceptor.LoggingOutInterceptor; import org.apache.cxf.jaxws.EndpointImpl; Object implementor = new GreeterImpl(); EndpointImpl ep = (EndpointImpl) Endpoint.publish("http://localhost/service", implementor); ep.getServiceFactory().getBus().getInInterceptors().add(new LoggingInInterceptor()); ep.getServiceFactory().getBus().getOutInterceptors().add(new LoggingOutInterceptor()); Extending the BusTODO: Explain how to add a custom bus extension (META-INF/cxf/cxf.extension ...). |
Unsubscribe or edit your notifications preferences
