...
| Code Block |
|---|
|
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/blueprint/core"
xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org/schemas/blueprint/jaxws.xsd">
<!-- CXF BraveFeature -->
<bean id="braveFeature" class="org.apache.cxf.tracing.brave.BraveFeature">
<argument index="0" ref="brave" />
</bean>
<cxf:bus>
<cxf:features>
<cxf:logging />
</cxf:features>
</cxf:bus>
<bean id="catalogServiceImpl" class="demo.jaxws.tracing.server.impl.CatalogServiceImpl">
<argument index="0" ref="brave" />
</bean>
<bean id="braveBuilder" class="com.github.kristofa.brave.Brave.Builder">
<argument index="0" value="catalog-service" />
</bean>
<bean id="brave" factory-ref="braveBuilder" factory-method="build" />
<jaxws:endpoint
implementor="#catalogServiceImpl"
address="/catalog"
implementorClass="demo.jaxws.tracing.server.impl.CatalogServiceImpl">
<jaxws:features>
<ref component-id="braveFeature" />
</jaxws:features>
</jaxws:endpoint>
</blueprint> |
Migrating from brave-cxf3
The migration path from OpenZipkin Brave / / TODOCXF to Apache CXF integration is pretty straightforward and essentially boils down to using JAX-RS ( BraveFeature for server side / BraveClientFeature for client side (imported from org.apache.cxf.tracing.brave.jaxrs package), for example:
| Code Block |
|---|
|
JAXRSServerFactoryBean serverFactory = new JAXRSServerFactoryBean();
serverFactory.setServiceBeans(new RestFooService());
serverFactory.setAddress("http://localhost:9001/");
serverFactory.getFeatures().add(new BraveFeature(brave));
serverFactory.create(); |
Although you may continue to use OpenZipkin Brave API directly, for the server-side it is preferable to inject @Context TracerContext into your JAX-RS services in order to interface with the tracer.
| Code Block |
|---|
|
JAXRSClientFactoryBean clientFactory = new JAXRSClientFactoryBean();
clientFactory.setAddress("http://localhost:9001/");
clientFactory.setServiceClass(FooService.class);
clientFactory.getFeatures().add(new BraveClientFeature(brave));
FooService client = (FooService) clientFactory.create() |
Similarly for JAX-WS BraveFeature for server side / BraveClientFeature for client side (imported from org.apache.cxf.tracing.brave package), for example:
| Code Block |
|---|
|
JaxWsServerFactoryBean serverFactory = new JaxWsServerFactoryBean();
serverFactory.setAddress("http://localhost:9000/test");
serverFactory.setServiceClass(FooService.class);
serverFactory.setServiceBean(fooServiceImplementation);
serverFactory.getFeatures().add(new BraveFeature(brave));
serverFactory.create(); |
| Code Block |
|---|
JAXRSClientFactoryBean clientFactory = new JAXRSClientFactoryBean();
clientFactory.setAddress("http://localhost:9001/");
clientFactory.setServiceClass(FooService.class);
clientFactory.getFeatures().add(new BraveClientFeature(brave));
FooService client = (FooService) clientFactory.create(); |