Search in sources :

Example 86 with JAXRSServerFactoryBean

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);
}
Also used : Server(org.apache.cxf.endpoint.Server) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean)

Example 87 with JAXRSServerFactoryBean

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));
}
Also used : BookStore(org.apache.cxf.jaxrs.resources.BookStore) SuperBookStore(org.apache.cxf.jaxrs.resources.SuperBookStore) Server(org.apache.cxf.endpoint.Server) SuperBook(org.apache.cxf.jaxrs.resources.SuperBook) Book(org.apache.cxf.jaxrs.resources.Book) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) List(java.util.List) ResponseImpl(org.apache.cxf.jaxrs.impl.ResponseImpl) Test(org.junit.Test)

Example 88 with JAXRSServerFactoryBean

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();
}
Also used : Bus(org.apache.cxf.Bus) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean)

Example 89 with JAXRSServerFactoryBean

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());
}
Also used : JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean)

Example 90 with JAXRSServerFactoryBean

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());
}
Also used : JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean)

Aggregations

JAXRSServerFactoryBean (org.apache.cxf.jaxrs.JAXRSServerFactoryBean)126 SingletonResourceProvider (org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)65 Bus (org.apache.cxf.Bus)21 JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)18 ArrayList (java.util.ArrayList)15 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)14 Test (org.junit.Test)13 HashMap (java.util.HashMap)10 Server (org.apache.cxf.endpoint.Server)10 Application (javax.ws.rs.core.Application)9 Before (org.junit.Before)8 Map (java.util.Map)7 IOException (java.io.IOException)5 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)5 ResourceProvider (org.apache.cxf.jaxrs.lifecycle.ResourceProvider)5 Bean (org.springframework.context.annotation.Bean)5 InputStream (java.io.InputStream)4 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)4 Feature (org.apache.cxf.feature.Feature)4 JAXRSBindingFactory (org.apache.cxf.jaxrs.JAXRSBindingFactory)4