...
Here, simply define a bus element in your Spring configuration file, and add child elements as required, for example:
Code Block | ||||
---|---|---|---|---|
| ||||
<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>
|
...
Although usually less convenient, interceptors can be added to the bus using Java code. Given an EndpointImpl object, the bus can be accessed (and interceptors added) as follows:
Code Block |
---|
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()); |
...