Search in sources :

Example 16 with JAXRSServerFactoryBean

use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project tomee by apache.

the class CxfRsHttpListener method deploy.

private void deploy(final String contextRoot, final Class<?> clazz, final String address, final ResourceProvider rp, final Object serviceBean, final Application app, final Invoker invoker, final Collection<Object> additionalProviders, final ServiceConfiguration configuration, final WebBeansContext webBeansContext) {
    final ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(CxfUtil.initBusLoader());
    try {
        final JAXRSServerFactoryBean factory = newFactory(address, createServiceJmxName(clazz.getClassLoader()), createEndpointName(app));
        configureFactory(additionalProviders, configuration, factory, webBeansContext);
        factory.setResourceClasses(clazz);
        context = contextRoot;
        if (context == null) {
            context = "";
        }
        if (!context.startsWith("/")) {
            context = "/" + context;
        }
        if (rp != null) {
            factory.setResourceProvider(rp);
        }
        if (app != null) {
            factory.setApplication(app);
        }
        if (invoker != null) {
            factory.setInvoker(invoker);
        }
        if (serviceBean != null) {
            factory.setServiceBean(serviceBean);
        } else {
            factory.setServiceClass(clazz);
        }
        server = factory.create();
        destination = (HttpDestination) server.getDestination();
        fireServerCreated(oldLoader);
    } finally {
        if (oldLoader != null) {
            CxfUtil.clearBusLoader(oldLoader);
        }
    }
}
Also used : JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean)

Example 17 with JAXRSServerFactoryBean

use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project ddf by codice.

the class TestPlugin method startServer.

private static void startServer() {
    LOGGER.info("Starting server.");
    endpoint = mock(MockRestEndpoint.class);
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setResourceClasses(MockRestEndpoint.class);
    sf.setAddress(ENDPOINT_ADDRESS);
    sf.setResourceProvider(MockRestEndpoint.class, new SingletonResourceProvider(endpoint, true));
    LOGGER.info("Creating server.");
    server = sf.create();
}
Also used : JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) SingletonResourceProvider(org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)

Aggregations

JAXRSServerFactoryBean (org.apache.cxf.jaxrs.JAXRSServerFactoryBean)17 SingletonResourceProvider (org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)7 Before (org.junit.Before)4 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)3 JAXRSBindingFactory (org.apache.cxf.jaxrs.JAXRSBindingFactory)3 ArrayList (java.util.ArrayList)2 Endpoint (org.apache.cxf.endpoint.Endpoint)2 ManagedEndpoint (org.apache.cxf.endpoint.ManagedEndpoint)2 JAXRSClientFactoryBean (org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean)2 Swagger2Feature (org.apache.cxf.jaxrs.swagger.Swagger2Feature)2 CommonsDigester (org.apache.tika.parser.utils.CommonsDigester)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)1 TbSysWsConfig (com.netsteadfast.greenstep.po.hbm.TbSysWsConfig)1 Console (java.io.Console)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Level (java.util.logging.Level)1