Search in sources :

Example 36 with SingletonResourceProvider

use of org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider in project cxf by apache.

the class JAXRSLocalTransportTest method setUp.

@Before
public void setUp() {
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setResourceClasses(BookStore.class, BookStoreSpring.class);
    sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore(), true));
    sf.setResourceProvider(BookStoreSpring.class, new SingletonResourceProvider(new BookStoreSpring(), true));
    sf.setProvider(new JacksonJsonProvider());
    List<Interceptor<? extends Message>> outInts = new ArrayList<>();
    outInts.add(new CustomOutInterceptor());
    sf.setOutInterceptors(outInts);
    List<Interceptor<? extends Message>> inInts = new ArrayList<>();
    inInts.add(new CustomInFaultyInterceptor());
    sf.setInInterceptors(inInts);
    sf.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    sf.setAddress("local://books");
    localServer = sf.create();
}
Also used : Message(org.apache.cxf.message.Message) JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) ArrayList(java.util.ArrayList) SingletonResourceProvider(org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider) AbstractPhaseInterceptor(org.apache.cxf.phase.AbstractPhaseInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor) Before(org.junit.Before)

Example 37 with SingletonResourceProvider

use of org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider in project cxf by apache.

the class AbstractBookServerHttp2 method run.

protected void run() {
    SpringBusFactory factory = new SpringBusFactory();
    Bus bus = factory.createBus(context);
    bus.setProperty(HttpServerEngineSupport.ENABLE_HTTP2, true);
    setBus(bus);
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setBus(bus);
    sf.setResourceClasses(BookStore.class);
    sf.setProvider(new StreamingResponseProvider<Book>());
    sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore(), true));
    sf.setAddress(scheme + "://localhost:" + port + "/http2");
    server = sf.create();
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Book(org.apache.cxf.customer.book.Book) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) SingletonResourceProvider(org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)

Example 38 with SingletonResourceProvider

use of org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider in project cxf by apache.

the class RxJava2SingleServer method createServer.

@Override
protected Server createServer(Bus bus) throws Exception {
    // Make sure default JSONProvider is not loaded
    bus.setProperty("skip.default.json.provider.registration", true);
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setProvider(new JacksonJsonProvider());
    new ReactiveIOCustomizer().customize(sf);
    sf.getOutInterceptors().add(new LoggingOutInterceptor());
    sf.setResourceClasses(RxJava2SingleService.class);
    sf.setResourceProvider(RxJava2SingleService.class, new SingletonResourceProvider(new RxJava2SingleService(), true));
    sf.setAddress("http://localhost:" + PORT + "/");
    return sf.create();
}
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 39 with SingletonResourceProvider

use of org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider in project cxf by apache.

the class RxJava2MaybeServer method createServer.

@Override
protected Server createServer(Bus bus) throws Exception {
    // Make sure default JSONProvider is not loaded
    bus.setProperty("skip.default.json.provider.registration", true);
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setProvider(new JacksonJsonProvider());
    new ReactiveIOCustomizer().customize(sf);
    sf.getOutInterceptors().add(new LoggingOutInterceptor());
    sf.setResourceClasses(RxJava2MaybeService.class);
    sf.setResourceProvider(RxJava2MaybeService.class, new SingletonResourceProvider(new RxJava2MaybeService(), true));
    sf.setAddress("http://localhost:" + PORT + "/");
    return sf.create();
}
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 40 with SingletonResourceProvider

use of org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider in project cxf by apache.

the class RxJava2ObservableServer method createServer.

@Override
protected Server createServer(Bus bus) throws Exception {
    bus.setProperty("skip.default.json.provider.registration", true);
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setProvider(new JacksonJsonProvider());
    sf.setProvider(new IllegalStateExceptionMapper());
    new ReactiveIOCustomizer().customize(sf);
    sf.getOutInterceptors().add(new LoggingOutInterceptor());
    sf.setResourceClasses(RxJava2ObservableService.class);
    sf.setResourceProvider(RxJava2ObservableService.class, new SingletonResourceProvider(new RxJava2ObservableService(), true));
    sf.setAddress("http://localhost:" + PORT + "/");
    return sf.create();
}
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)

Aggregations

SingletonResourceProvider (org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)84 JAXRSServerFactoryBean (org.apache.cxf.jaxrs.JAXRSServerFactoryBean)63 Bus (org.apache.cxf.Bus)17 JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)15 ArrayList (java.util.ArrayList)14 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)14 ResourceProvider (org.apache.cxf.jaxrs.lifecycle.ResourceProvider)9 HashMap (java.util.HashMap)7 Before (org.junit.Before)7 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)5 ClassResourceInfo (org.apache.cxf.jaxrs.model.ClassResourceInfo)5 Map (java.util.Map)4 ReactiveIOCustomizer (org.apache.cxf.jaxrs.rx3.server.ReactiveIOCustomizer)4 DetectorResource (org.apache.tika.server.resource.DetectorResource)4 MetadataResource (org.apache.tika.server.resource.MetadataResource)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3 Feature (org.apache.cxf.feature.Feature)3 ReactiveIOCustomizer (org.apache.cxf.jaxrs.rx2.server.ReactiveIOCustomizer)3 Message (org.apache.cxf.message.Message)3