Overview
CXF includes a "local" transport. This transport allows you to send messsages more efficiently inside a JVM. The messages will serialized and piped from one endpoint to another.
The local transport supports URIs of the structure "local://{endpoint_name}" where {endpoint_name} is any set of characters. To use the local transport you simply need to set your address to a local URI.
Examples
JAX-WS
This code shows how to publish on a local endpoint:
import javax.xml.ws.Endpoint;
HelloServiceImpl serverImpl = new HelloServiceImpl();
|
Or with XML:
xsi:schemaLocation="
http:
http:
http:
< import resource= "classpath:META-INF/cxf/cxf.xml" />
< import resource= "classpath:META-INF/cxf/cxf-extension-soap.xml" />
<bean class = "org.apache.cxf.transport.local.LocalTransportFactory" lazy-init= "false" >
<property name= "transportIds" >
<list>
<value>http:
<value>http:
<value>http:
</list>
</property>
</bean>
<jaxws:endpoint name= "helloWorld" address= "local://hello" implementor= "org.example.HelloServiceImpl" /> </beans>
|
Simple Frontend
Before you use the local transport , you need to register the default soap transportURI with the local transport factory in the bus
Bus bus = BusFactory.getDefaultBus();
LocalTransportFactory localTransport = new LocalTransportFactory();
ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager. class );
|
You can also pass in a local://address to the server and client factory beans:
import org.apache.cxf.frontend.ServerFactoryBean;
ServerFactoryBean sf = new ServerFactoryBean();
sf.setServiceBean( new HelloServiceImpl());
sf.setServiceClass(HelloService. class );
sf.create();
|
import org.apache.cxf.frontend.ClientProxyFactoryBean;
ClientProxyFactoryBean cf = new ClientProxyFactoryBean();
cf.setServiceClass(HelloService. class );
HelloService h = (HelloService) cf.create();
|