| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
package org.apache.camel.component.cxf; |
| 19 |
|
|
| 20 |
|
import java.net.URI; |
| 21 |
|
import java.util.Map; |
| 22 |
|
|
| 23 |
|
import org.apache.camel.CamelContext; |
| 24 |
|
import org.apache.camel.Endpoint; |
| 25 |
|
import org.apache.camel.impl.DefaultComponent; |
| 26 |
|
import org.apache.cxf.Bus; |
| 27 |
|
import org.apache.cxf.BusException; |
| 28 |
|
import org.apache.cxf.bus.CXFBusFactory; |
| 29 |
|
import org.apache.cxf.service.model.EndpointInfo; |
| 30 |
|
import org.apache.cxf.transport.DestinationFactoryManager; |
| 31 |
|
import org.apache.cxf.transport.local.LocalTransportFactory; |
| 32 |
|
import org.xmlsoap.schemas.wsdl.http.AddressType; |
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
public class CxfComponent extends DefaultComponent<CxfExchange> { |
| 40 |
|
private LocalTransportFactory localTransportFactory; |
| 41 |
|
|
| 42 |
0 |
public CxfComponent() { |
| 43 |
0 |
} |
| 44 |
|
|
| 45 |
|
public CxfComponent(CamelContext context) { |
| 46 |
0 |
super(context); |
| 47 |
0 |
} |
| 48 |
|
|
| 49 |
|
@Override |
| 50 |
|
protected Endpoint<CxfExchange> createEndpoint(String uri, String remaining, Map parameters) throws Exception { |
| 51 |
0 |
URI u = new URI(remaining); |
| 52 |
|
|
| 53 |
|
|
| 54 |
0 |
EndpointInfo endpointInfo = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http"); |
| 55 |
0 |
AddressType a = new AddressType(); |
| 56 |
0 |
a.setLocation(remaining); |
| 57 |
0 |
endpointInfo.addExtensor(a); |
| 58 |
|
|
| 59 |
0 |
return new CxfEndpoint(uri, this, endpointInfo); |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
public LocalTransportFactory getLocalTransportFactory() throws BusException { |
| 63 |
0 |
if (localTransportFactory == null) { |
| 64 |
0 |
localTransportFactory = findLocalTransportFactory(); |
| 65 |
0 |
if (localTransportFactory == null) { |
| 66 |
0 |
localTransportFactory = new LocalTransportFactory(); |
| 67 |
|
} |
| 68 |
|
} |
| 69 |
0 |
return localTransportFactory; |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
public void setLocalTransportFactory(LocalTransportFactory localTransportFactory) { |
| 73 |
0 |
this.localTransportFactory = localTransportFactory; |
| 74 |
0 |
} |
| 75 |
|
|
| 76 |
|
protected LocalTransportFactory findLocalTransportFactory() throws BusException { |
| 77 |
0 |
Bus bus = CXFBusFactory.getDefaultBus(); |
| 78 |
0 |
DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class); |
| 79 |
0 |
return (LocalTransportFactory) dfm.getDestinationFactory(LocalTransportFactory.TRANSPORT_ID); |
| 80 |
|
} |
| 81 |
|
} |