Search in sources :

Example 56 with JAXRSServerFactoryBean

use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.

the class BookCxfContinuationServer method run.

protected void run() {
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setResourceClasses(BookCxfContinuationStore.class);
    sf.setResourceProvider(BookCxfContinuationStore.class, new SingletonResourceProvider(new BookCxfContinuationStore()));
    sf.setAddress("http://localhost:" + PORT + "/");
    sf.create();
}
Also used : JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) SingletonResourceProvider(org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)

Example 57 with JAXRSServerFactoryBean

use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.

the class Server method createEndpoint.

private void createEndpoint(String address) {
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setResourceClasses(BookStore.class);
    sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore(), false));
    sf.setAddress(address);
    servers.add(sf.create());
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.BookStore) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) SingletonResourceProvider(org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)

Example 58 with JAXRSServerFactoryBean

use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.

the class RxJava2FlowableServer method createFactoryBean.

private JAXRSServerFactoryBean createFactoryBean(Bus bus, boolean useStreamingSubscriber, String relAddress) {
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.getProperties(true).put("useStreamingSubscriber", useStreamingSubscriber);
    sf.setProvider(new JacksonJsonProvider());
    new ReactiveIOCustomizer().customize(sf);
    sf.getOutInterceptors().add(new LoggingOutInterceptor());
    sf.setResourceClasses(RxJava2FlowableService.class);
    sf.setResourceProvider(RxJava2FlowableService.class, new SingletonResourceProvider(new RxJava2FlowableService(), true));
    sf.setAddress("http://localhost:" + PORT + relAddress);
    return sf;
}
Also used : ReactiveIOCustomizer(org.apache.cxf.jaxrs.rx2.server.ReactiveIOCustomizer) 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)

Example 59 with JAXRSServerFactoryBean

use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean 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)

Example 60 with JAXRSServerFactoryBean

use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.

the class BookHttpsServer method run.

protected void run() {
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setResourceClasses(BookStore.class);
    // default lifecycle is per-request, change it to singleton
    sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore()));
    sf.setAddress("https://localhost:" + PORT + "/");
    sf.create();
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.BookStore) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) SingletonResourceProvider(org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)

Aggregations

JAXRSServerFactoryBean (org.apache.cxf.jaxrs.JAXRSServerFactoryBean)63 SingletonResourceProvider (org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)30 Bus (org.apache.cxf.Bus)11 Test (org.junit.Test)10 JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)7 ArrayList (java.util.ArrayList)7 Application (javax.ws.rs.core.Application)6 HashMap (java.util.HashMap)5 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)5 ResourceProvider (org.apache.cxf.jaxrs.lifecycle.ResourceProvider)4 Before (org.junit.Before)4 Map (java.util.Map)3 UriInfo (javax.ws.rs.core.UriInfo)3 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)3 Server (org.apache.cxf.endpoint.Server)3 JAXRSBindingFactory (org.apache.cxf.jaxrs.JAXRSBindingFactory)3 Bean (org.springframework.context.annotation.Bean)3 Annotation (java.lang.annotation.Annotation)2 Endpoint (org.apache.cxf.endpoint.Endpoint)2 ManagedEndpoint (org.apache.cxf.endpoint.ManagedEndpoint)2