use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class RxJavaObservableServer method run.
protected void run() {
Bus bus = BusFactory.getDefaultBus();
// Make sure default JSONProvider is not loaded
bus.setProperty("skip.default.json.provider.registration", true);
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setProvider(new JacksonJsonProvider());
new ObservableCustomizer().customize(sf);
sf.getOutInterceptors().add(new LoggingOutInterceptor());
sf.setResourceClasses(RxJavaObservableService.class);
sf.setResourceProvider(RxJavaObservableService.class, new SingletonResourceProvider(new RxJavaObservableService(), true));
sf.setAddress("http://localhost:" + PORT + "/");
server = sf.create();
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class BookServerWebSocket method run.
protected void run() {
Bus bus = BusFactory.getDefaultBus();
setBus(bus);
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setBus(bus);
sf.setResourceClasses(BookStoreWebSocket.class, BookStorePerRequest.class);
sf.setProvider(new StreamingResponseProvider<Book>());
sf.setResourceProvider(BookStoreWebSocket.class, new SingletonResourceProvider(new BookStoreWebSocket(), true));
sf.setAddress("ws://localhost:" + port + "/websocket");
server = sf.create();
BusFactory.setDefaultBus(null);
BusFactory.setThreadDefaultBus(null);
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project tomee by apache.
the class CxfRsHttpListener method deploy.
private void deploy(final String contextRoot, final Class<?> clazz, final String address, final ResourceProvider rp, final Object serviceBean, final Application app, final Invoker invoker, final Collection<Object> additionalProviders, final ServiceConfiguration configuration, final WebBeansContext webBeansContext) {
final ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(CxfUtil.initBusLoader());
try {
final JAXRSServerFactoryBean factory = newFactory(address, createServiceJmxName(clazz.getClassLoader()), createEndpointName(app));
configureFactory(additionalProviders, configuration, factory, webBeansContext);
factory.setResourceClasses(clazz);
context = contextRoot;
if (context == null) {
context = "";
}
if (!context.startsWith("/")) {
context = "/" + context;
}
if (rp != null) {
factory.setResourceProvider(rp);
}
if (app != null) {
factory.setApplication(app);
}
if (invoker != null) {
factory.setInvoker(invoker);
}
if (serviceBean != null) {
factory.setServiceBean(serviceBean);
} else {
factory.setServiceClass(clazz);
}
server = factory.create();
destination = (HttpDestination) server.getDestination();
fireServerCreated(oldLoader);
} finally {
if (oldLoader != null) {
CxfUtil.clearBusLoader(oldLoader);
}
}
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project camel by apache.
the class CxfRsEndpointBeansTest method testCxfBusInjection.
@Test
public void testCxfBusInjection() {
CxfRsEndpoint serviceEndpoint = context.getEndpoint("cxfrs:bean:serviceEndpoint", CxfRsEndpoint.class);
CxfRsEndpoint routerEndpoint = context.getEndpoint("cxfrs:bean:routerEndpoint", CxfRsEndpoint.class);
JAXRSServerFactoryBean server = routerEndpoint.createJAXRSServerFactoryBean();
JAXRSClientFactoryBean client = serviceEndpoint.createJAXRSClientFactoryBean();
assertEquals("These cxfrs endpoints don't share the same bus", server.getBus().getId(), client.getBus().getId());
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project camel by apache.
the class CamelConnectorCatalogRestTest method setup.
@Before
public void setup() {
catalog = new CamelConnectorCatalogRest();
port = AvailablePortFinder.getNextAvailable(9000);
// setup Apache CXF REST server
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(CamelConnectorCatalogRest.class);
sf.setResourceProvider(CamelConnectorCatalogRest.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();
}
Aggregations