Search in sources :

Example 1 with ReactorCustomizer

use of org.apache.cxf.jaxrs.reactor.server.ReactorCustomizer in project cxf by apache.

the class ReactorServer method run.

@Override
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.getProperties(true).put("useStreamingSubscriber", false);
    sf.setProvider(new JacksonJsonProvider());
    new ReactorCustomizer().customize(sf);
    sf.getOutInterceptors().add(new LoggingOutInterceptor());
    sf.setResourceClasses(FluxService.class, MonoService.class);
    sf.setResourceProvider(FluxService.class, new SingletonResourceProvider(new FluxService(), true));
    sf.setResourceProvider(MonoService.class, new SingletonResourceProvider(new MonoService(), true));
    sf.setAddress("http://localhost:" + PORT + "/reactor");
    server1 = sf.create();
    JAXRSServerFactoryBean sf2 = new JAXRSServerFactoryBean();
    sf2.setProvider(new JacksonJsonProvider());
    new ReactorCustomizer().customize(sf2);
    sf2.getOutInterceptors().add(new LoggingOutInterceptor());
    sf2.setResourceClasses(FluxService.class);
    sf2.setResourceProvider(FluxService.class, new SingletonResourceProvider(new FluxService(), true));
    sf2.setAddress("http://localhost:" + PORT + "/reactor2");
    server2 = sf2.create();
}
Also used : Bus(org.apache.cxf.Bus) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) SingletonResourceProvider(org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider) ReactorCustomizer(org.apache.cxf.jaxrs.reactor.server.ReactorCustomizer)

Aggregations

JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)1 Bus (org.apache.cxf.Bus)1 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)1 JAXRSServerFactoryBean (org.apache.cxf.jaxrs.JAXRSServerFactoryBean)1 SingletonResourceProvider (org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)1 ReactorCustomizer (org.apache.cxf.jaxrs.reactor.server.ReactorCustomizer)1