use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project camel by apache.
the class CamelCatalogRestTest method setup.
@Before
public void setup() {
catalog = new CamelCatalogRest();
port = AvailablePortFinder.getNextAvailable(9000);
// setup Apache CXF REST server
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(CamelCatalogRest.class);
sf.setResourceProvider(CamelCatalogRest.class, new SingletonResourceProvider(catalog));
// to use jackson for json
sf.setProvider(JacksonJsonProvider.class);
sf.setAddress("http://localhost:" + port);
// create and start the CXF server (non blocking)
server = sf.create();
server.start();
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project camel by apache.
the class CamelCatalogSwaggerTest method setup.
@Before
public void setup() {
catalog = new CamelCatalogRest();
port = AvailablePortFinder.getNextAvailable(9000);
// setup Apache CXF REST server
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(CamelCatalogRest.class);
sf.setResourceProvider(CamelCatalogRest.class, new SingletonResourceProvider(catalog));
Swagger2Feature swagger = new Swagger2Feature();
swagger.setBasePath("/");
swagger.setScanAllResources(false);
swagger.setPrettyPrint(true);
swagger.setSupportSwaggerUi(true);
swagger.setTitle("Camel Catalog REST Api");
swagger.setDescription("REST Api for the Camel Catalog");
swagger.setVersion(catalog.getCatalogVersion());
swagger.setContact("Apache Camel");
sf.getFeatures().add(swagger);
// to use jackson for json
sf.setProvider(JacksonJsonProvider.class);
sf.setAddress("http://localhost:" + port);
// create and start the CXF server (non blocking)
server = sf.create();
server.start();
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project camel by apache.
the class CxfRsEndpointTest method testCxfRsEndpointSetProvider.
@Test
public void testCxfRsEndpointSetProvider() throws Exception {
String endpointUri = "cxfrs://http://localhost:" + CTX + "" + "?resourceClass=org.apache.camel.component.cxf.jaxrs.testbean.CustomerService";
CxfRsComponent component = new CxfRsComponent(context);
CxfRsEndpoint endpoint = (CxfRsEndpoint) component.createEndpoint(endpointUri);
JSONProvider<?> jsonProvider = new JSONProvider<Object>();
jsonProvider.setDropRootElement(true);
jsonProvider.setSupportUnwrapped(true);
endpoint.setProvider(jsonProvider);
JAXRSServerFactoryBean sfb = endpoint.createJAXRSServerFactoryBean();
assertEquals("Get a wrong proider size", 1, sfb.getProviders().size());
JAXRSClientFactoryBean cfb = endpoint.createJAXRSClientFactoryBean();
assertEquals("Get a wrong proider size", 1, cfb.getProviders().size());
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project camel by apache.
the class CxfBeanEndpoint method createServer.
private void createServer(List<Object> serviceBeans) {
Object obj = serviceBeans.get(0).getClass().getAnnotation(WebService.class);
if (obj != null) {
JaxWsServerFactoryBean bean = new JaxWsServerFactoryBean();
bean.setTransportId(CxfBeanTransportFactory.TRANSPORT_ID);
bean.setServiceClass(serviceBeans.get(0).getClass());
// set the bean instance as well, otherwise CXF will re-create a new instance of the class
bean.setServiceBean(serviceBeans.get(0));
if (bean.getJaxWsServiceFactory() != null) {
bean.getJaxWsServiceFactory().setPopulateFromClass(isPopulateFromClass());
}
bean.setBus(bus);
bean.setStart(true);
bean.setAddress("camel://" + createEndpointUri());
if (loggingFeatureEnabled) {
bean.getFeatures().add(new LoggingFeature());
}
server = bean.create();
} else {
JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
bean.setServiceBeans(serviceBeans);
bean.setAddress("camel://" + createEndpointUri());
bean.setStart(true);
bean.setTransportId(CxfBeanTransportFactory.TRANSPORT_ID);
bean.setBus(bus);
if (loggingFeatureEnabled) {
bean.getFeatures().add(new LoggingFeature());
}
bean.setProviders(providers);
server = bean.create();
}
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project camel by apache.
the class CxfRsConsumer method createServer.
protected Server createServer() {
CxfRsEndpoint endpoint = (CxfRsEndpoint) getEndpoint();
CxfRsInvoker cxfRsInvoker = new CxfRsInvoker(endpoint, this);
JAXRSServerFactoryBean svrBean = endpoint.createJAXRSServerFactoryBean();
Bus bus = endpoint.getBus();
// We need to apply the bus setting from the CxfRsEndpoint which does not use the default bus
if (bus != null) {
svrBean.setBus(bus);
}
svrBean.setInvoker(cxfRsInvoker);
return svrBean.create();
}
Aggregations