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