| 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 org.apache.camel.CamelContext; |
| 21 |
|
import org.apache.camel.Endpoint; |
| 22 |
|
import org.apache.camel.impl.DefaultComponent; |
| 23 |
|
import org.apache.cxf.Bus; |
| 24 |
|
import org.apache.cxf.bus.CXFBusFactory; |
| 25 |
|
|
| 26 |
|
import java.net.URI; |
| 27 |
|
import java.util.Map; |
| 28 |
|
import java.util.Properties; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
public class CxfInvokeComponent extends DefaultComponent<CxfExchange> { |
| 34 |
|
private Bus bus; |
| 35 |
|
|
| 36 |
1 |
public CxfInvokeComponent() { |
| 37 |
1 |
bus = CXFBusFactory.getDefaultBus(); |
| 38 |
1 |
} |
| 39 |
|
|
| 40 |
|
public CxfInvokeComponent(CamelContext context) { |
| 41 |
0 |
super(context); |
| 42 |
0 |
bus = CXFBusFactory.getDefaultBus(); |
| 43 |
0 |
} |
| 44 |
|
|
| 45 |
|
@Override |
| 46 |
|
protected Endpoint<CxfExchange> createEndpoint(String uri, String remaining, Map parameters) throws Exception { |
| 47 |
1 |
return new CxfInvokeEndpoint(getAddress(remaining), this, getQueryAsProperties(new URI(remaining))); |
| 48 |
|
} |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
protected Properties getQueryAsProperties(URI u) { |
| 57 |
1 |
Properties retval = new Properties(); |
| 58 |
1 |
if (u.getQuery() != null) { |
| 59 |
1 |
String[] parameters = u.getQuery().split("&"); |
| 60 |
3 |
for (int i = 0; i < parameters.length; i++) { |
| 61 |
2 |
String[] s = parameters[i].split("="); |
| 62 |
2 |
retval.put(s[0], s[1]); |
| 63 |
|
} |
| 64 |
|
} |
| 65 |
1 |
return retval; |
| 66 |
|
} |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
protected String getAddress(String uri) { |
| 75 |
1 |
int index = uri.indexOf("?"); |
| 76 |
1 |
if (-1 != index) { |
| 77 |
1 |
return uri.substring(0, index); |
| 78 |
|
} |
| 79 |
0 |
return uri; |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
public Bus getBus() { |
| 83 |
1 |
return bus; |
| 84 |
|
} |
| 85 |
|
} |