use of org.apache.camel.component.cxf.CxfComponent in project camel by apache.
the class CamelCxfExample method main.
public static void main(String[] args) throws Exception {
// Set system properties for use with Camel property placeholders for running the examples.
System.setProperty("routerPort", "9001");
System.setProperty("servicePort", "9003");
// START SNIPPET: e1
CamelContext context = new DefaultCamelContext();
// END SNIPPET: e1
PropertiesComponent pc = new PropertiesComponent();
context.addComponent("properties", pc);
// Set up the JMS broker and the CXF SOAP over JMS server
// START SNIPPET: e2
JmsBroker broker = new JmsBroker();
Server server = new Server();
try {
broker.start();
server.start();
// END SNIPPET: e2
// Add some configuration by hand ...
// START SNIPPET: e3
context.addRoutes(new RouteBuilder() {
public void configure() {
CxfComponent cxfComponent = new CxfComponent(getContext());
CxfEndpoint serviceEndpoint = new CxfEndpoint(SERVICE_ADDRESS, cxfComponent);
serviceEndpoint.setServiceClass(Greeter.class);
// Here we just pass the exception back, don't need to use errorHandler
errorHandler(noErrorHandler());
from(ROUTER_ENDPOINT_URI).to(serviceEndpoint);
}
});
// END SNIPPET: e3
String address = ROUTER_ADDRESS.replace("{{routerPort}}", System.getProperty("routerPort"));
// Starting the routing context
// Using the CXF Client to kick off the invocations
// START SNIPPET: e4
context.start();
Client client = new Client(address + "?wsdl");
// END SNIPPET: e4
// Now everything is set up - let's start the context
client.invoke();
Thread.sleep(1000);
context.stop();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
server.stop();
broker.stop();
System.exit(0);
}
}
use of org.apache.camel.component.cxf.CxfComponent in project camel by apache.
the class CxfComponentAutoConfiguration method configureCxfComponent.
@Lazy
@Bean(name = "cxf-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(CxfComponent.class)
public CxfComponent configureCxfComponent(CamelContext camelContext, CxfComponentConfiguration configuration) throws Exception {
CxfComponent component = new CxfComponent();
component.setCamelContext(camelContext);
Map<String, Object> parameters = new HashMap<>();
IntrospectionSupport.getProperties(configuration, parameters, null, false);
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
Object value = entry.getValue();
Class<?> paramClass = value.getClass();
if (paramClass.getName().endsWith("NestedConfiguration")) {
Class nestedClass = null;
try {
nestedClass = (Class) paramClass.getDeclaredField("CAMEL_NESTED_CLASS").get(null);
HashMap<String, Object> nestedParameters = new HashMap<>();
IntrospectionSupport.getProperties(value, nestedParameters, null, false);
Object nestedProperty = nestedClass.newInstance();
IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), nestedProperty, nestedParameters);
entry.setValue(nestedProperty);
} catch (NoSuchFieldException e) {
}
}
}
IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters);
return component;
}
Aggregations