Search in sources :

Example 1 with StreamingResponseProvider

use of org.apache.cxf.jaxrs.provider.StreamingResponseProvider in project cxf by apache.

the class BookServer method createServer.

@Override
protected Server createServer(Bus bus) throws Exception {
    bus.setProperty(ExceptionMapper.class.getName(), new BusMapperExceptionMapper());
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setResourceClasses(BookStore.class, SimpleBookStore.class, BookStorePerRequest.class, BookStoreRegex.class);
    // default lifecycle is per-request, change it to singleton
    final BinaryDataProvider<Object> p = new BinaryDataProvider<>();
    p.setProduceMediaTypes(Collections.singletonList("application/bar"));
    p.setEnableBuffering(true);
    p.setReportByteArraySize(true);
    final JAXBElementProvider<?> jaxbProvider = new JAXBElementProvider<>();
    jaxbProvider.setJaxbElementClassMap(Collections.singletonMap(BookNoXmlRootElement.class.getName(), "BookNoXmlRootElement"));
    sf.setProviders(Arrays.asList(p, new BookStore.PrimitiveIntArrayReaderWriter(), new BookStore.PrimitiveDoubleArrayReaderWriter(), new BookStore.StringArrayBodyReaderWriter(), new BookStore.StringListBodyReaderWriter(), new StreamingResponseProvider<Object>(), new ContentTypeModifyingMBW(), jaxbProvider, new FormatResponseHandler(), new GenericHandlerWriter(), new FaultyRequestHandler(), new SearchContextProvider(), new QueryContextProvider(), new BlockingRequestFilter(), new FaultyResponseFilter(), new BlockedExceptionMapper(), new ParamConverterImpl()));
    sf.setInInterceptors(Arrays.asList(new CustomInFaultyInterceptor(), new LoggingInInterceptor()));
    sf.setOutInterceptors(Arrays.asList(new CustomOutInterceptor(), new LoggingOutInterceptor()));
    sf.setOutFaultInterceptors(Arrays.asList(new CustomOutFaultInterceptor()));
    sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore(), true));
    sf.setAddress("http://localhost:" + PORT + "/");
    sf.getProperties(true).put("org.apache.cxf.jaxrs.mediaTypeCheck.strict", true);
    sf.getProperties().put("search.visitor", new SQLPrinterVisitor<SearchBean>("books"));
    sf.getProperties().put("org.apache.cxf.http.header.split", true);
    sf.getProperties().put("default.content.type", "*/*");
    sf.getProperties().putAll(properties);
    return sf.create();
}
Also used : SingletonResourceProvider(org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider) ExceptionMapper(javax.ws.rs.ext.ExceptionMapper) ResponseExceptionMapper(org.apache.cxf.jaxrs.client.ResponseExceptionMapper) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) SearchBean(org.apache.cxf.jaxrs.ext.search.SearchBean) BinaryDataProvider(org.apache.cxf.jaxrs.provider.BinaryDataProvider) SearchContextProvider(org.apache.cxf.jaxrs.ext.search.SearchContextProvider) JAXBElementProvider(org.apache.cxf.jaxrs.provider.JAXBElementProvider) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) StreamingResponseProvider(org.apache.cxf.jaxrs.provider.StreamingResponseProvider) QueryContextProvider(org.apache.cxf.jaxrs.ext.search.QueryContextProvider)

Aggregations

ExceptionMapper (javax.ws.rs.ext.ExceptionMapper)1 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)1 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)1 JAXRSServerFactoryBean (org.apache.cxf.jaxrs.JAXRSServerFactoryBean)1 ResponseExceptionMapper (org.apache.cxf.jaxrs.client.ResponseExceptionMapper)1 QueryContextProvider (org.apache.cxf.jaxrs.ext.search.QueryContextProvider)1 SearchBean (org.apache.cxf.jaxrs.ext.search.SearchBean)1 SearchContextProvider (org.apache.cxf.jaxrs.ext.search.SearchContextProvider)1 SingletonResourceProvider (org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)1 BinaryDataProvider (org.apache.cxf.jaxrs.provider.BinaryDataProvider)1 JAXBElementProvider (org.apache.cxf.jaxrs.provider.JAXBElementProvider)1 StreamingResponseProvider (org.apache.cxf.jaxrs.provider.StreamingResponseProvider)1