use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class RuntimeDelegateImpl method createEndpoint.
@Override
public <T> T createEndpoint(Application app, Class<T> endpointType) throws IllegalArgumentException, UnsupportedOperationException {
if (app == null || (!Server.class.isAssignableFrom(endpointType) && !JAXRSServerFactoryBean.class.isAssignableFrom(endpointType))) {
throw new IllegalArgumentException();
}
JAXRSServerFactoryBean bean = ResourceUtils.createApplication(app, false, false, false, null);
if (JAXRSServerFactoryBean.class.isAssignableFrom(endpointType)) {
return endpointType.cast(bean);
}
bean.setStart(false);
Server server = bean.create();
return endpointType.cast(server);
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class JAXRSClientFactoryBeanTest method testVoidResponseAcceptWildcard.
@Test
public void testVoidResponseAcceptWildcard() throws Exception {
String address = "local://store";
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setServiceBean(new BookStore());
sf.setAddress(address);
Server s = sf.create();
BookStore store = JAXRSClientFactory.create(address, BookStore.class);
store.addBook(new Book());
s.stop();
ResponseImpl response = (ResponseImpl) WebClient.client(store).getResponse();
Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>) response.getOutMessage().get(Message.PROTOCOL_HEADERS));
assertTrue(headers.get(HttpHeaders.ACCEPT).contains(MediaType.WILDCARD));
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class JaxRsTestActivator method createServer.
@Override
protected Server createServer() {
Bus bus = BusFactory.newInstance().createBus();
bus.setExtension(JaxRsTestActivator.class.getClassLoader(), ClassLoader.class);
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setBus(bus);
sf.setResourceClasses(BookStore.class);
sf.setAddress("/jaxrs");
return sf.create();
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class SseEventSourceImplTest method startServer.
private static void startServer(Type type, String payload) {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setAddress(LOCAL_ADDRESS + type.name());
sf.setServiceBean(new EventServer(payload));
SERVERS.put(type, sf.create());
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class SseEventSourceImplTest method startDynamicServer.
private static void startDynamicServer(Type type, Function<HttpHeaders, String> function) {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setAddress(LOCAL_ADDRESS + type.name());
sf.setServiceBean(new DynamicServer(function, type == Type.EVENT_RETRY_LAST_EVENT_ID));
SERVERS.put(type, sf.create());
}
Aggregations