use of org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider in project cxf by apache.
the class JAXRSInInterceptor method setExchangeProperties.
private void setExchangeProperties(Message message, Exchange exchange, OperationResourceInfo ori, MultivaluedMap<String, String> values, int numberOfResources) {
final ClassResourceInfo cri = ori.getClassResourceInfo();
exchange.put(OperationResourceInfo.class, ori);
exchange.put(JAXRSUtils.ROOT_RESOURCE_CLASS, cri);
message.put(RESOURCE_METHOD, ori.getMethodToInvoke());
message.put(URITemplate.TEMPLATE_PARAMETERS, values);
message.put(URITemplate.URI_TEMPLATE, JAXRSUtils.getUriTemplate(message, cri, ori));
String plainOperationName = ori.getMethodToInvoke().getName();
if (numberOfResources > 1) {
plainOperationName = cri.getServiceClass().getSimpleName() + "#" + plainOperationName;
}
exchange.put(RESOURCE_OPERATION_NAME, plainOperationName);
if (ori.isOneway() || PropertyUtils.isTrue(HttpUtils.getProtocolHeader(message, Message.ONE_WAY_REQUEST, null))) {
exchange.setOneWay(true);
}
ResourceProvider rp = cri.getResourceProvider();
if (rp instanceof SingletonResourceProvider) {
// cri.isSingleton is not guaranteed to indicate we have a 'pure' singleton
exchange.put(Message.SERVICE_OBJECT, rp.getInstance(message));
}
}
use of org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider in project cxf by apache.
the class BookServer20 method createServer.
@Override
protected Server createServer(Bus bus) throws Exception {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(BookStore.class);
List<Object> providers = new ArrayList<>();
providers.add(new PreMatchContainerRequestFilter2());
providers.add(new PreMatchContainerRequestFilter());
providers.add(new PostMatchContainerResponseFilter());
providers.add((Feature) context -> {
context.register(new PostMatchContainerResponseFilter3());
return true;
});
providers.add(new PostMatchContainerResponseFilter2());
providers.add(new CustomReaderBoundInterceptor());
providers.add(new CustomReaderInterceptor());
providers.add(new CustomWriterInterceptor());
providers.add(new CustomDynamicFeature());
providers.add(new PostMatchContainerRequestFilter());
providers.add(new FaultyContainerRequestFilter());
providers.add(new PreMatchReplaceStreamOrAddress());
providers.add(new ServerTestFeature());
providers.add(new JacksonJaxbJsonProvider());
providers.add(new IOExceptionMapper());
providers.add(new GregorianCalendarMessageBodyWriter());
sf.setApplication(new Application());
sf.setProviders(providers);
sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore(), true));
sf.setAddress("http://localhost:" + PORT + "/");
return sf.create();
}
use of org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider in project cxf by apache.
the class BookServerSub method createServer.
@Override
protected Server createServer(Bus bus) throws Exception {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setStaticSubresourceResolution(true);
sf.setResourceClasses(BookStoreSubObject.class);
sf.setResourceProvider(BookStoreSubObject.class, new SingletonResourceProvider(new BookStoreSubObject(), true));
sf.setAddress("http://localhost:" + PORT + "/");
return sf.create();
}
use of org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider in project cxf by apache.
the class BookCxfContinuationServlet3Server method serverFactory.
private JAXRSServerFactoryBean serverFactory(Bus bus) {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setBus(bus);
sf.setResourceClasses(BookCxfContinuationStore.class);
sf.setResourceProvider(BookCxfContinuationStore.class, new SingletonResourceProvider(new BookCxfContinuationStore()));
sf.setAddress("/");
return sf;
}
use of org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider in project cxf by apache.
the class BookCxfContinuationServer method createServer.
@Override
protected Server createServer(Bus bus) throws Exception {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(BookCxfContinuationStore.class);
sf.setResourceProvider(BookCxfContinuationStore.class, new SingletonResourceProvider(new BookCxfContinuationStore()));
sf.setAddress("http://localhost:" + PORT + "/");
return sf.create();
}
Aggregations