Search in sources :

Example 46 with Server

use of org.apache.cxf.endpoint.Server in project cxf by apache.

the class JaxWsServerFactoryBean method create.

public Server create() {
    ClassLoaderHolder orig = null;
    try {
        if (bus != null) {
            ClassLoader loader = bus.getExtension(ClassLoader.class);
            if (loader != null) {
                orig = ClassLoaderUtils.setThreadContextClassloader(loader);
            }
        }
        Server server = super.create();
        initializeResourcesAndHandlerChain(server);
        checkPrivateEndpoint(server.getEndpoint());
        return server;
    } finally {
        if (orig != null) {
            orig.reset();
        }
    }
}
Also used : Server(org.apache.cxf.endpoint.Server) ClassLoaderHolder(org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder)

Example 47 with Server

use of org.apache.cxf.endpoint.Server in project cxf by apache.

the class NamespaceConfusionTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    Server s = createService(NameServiceImpl.class);
    service = s.getEndpoint().getService();
    databinding = (AegisDatabinding) service.getDataBinding();
    tm = databinding.getAegisContext().getTypeMapping();
}
Also used : Server(org.apache.cxf.endpoint.Server) Before(org.junit.Before)

Example 48 with Server

use of org.apache.cxf.endpoint.Server in project cxf by apache.

the class ExplicitPrefixTest method setupService.

private ServiceAndMapping setupService(Class<?> seiClass, Map<String, String> namespaces) {
    AegisDatabinding db = new AegisDatabinding();
    db.setNamespaceMap(namespaces);
    Server s = createService(seiClass, null, db);
    ServiceAndMapping serviceAndMapping = new ServiceAndMapping();
    serviceAndMapping.setServer(s);
    serviceAndMapping.setService(s.getEndpoint().getService());
    serviceAndMapping.setTypeMapping((TypeMapping) serviceAndMapping.getService().get(TypeMapping.class.getName()));
    return serviceAndMapping;
}
Also used : Server(org.apache.cxf.endpoint.Server) TypeMapping(org.apache.cxf.aegis.type.TypeMapping) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding)

Example 49 with Server

use of org.apache.cxf.endpoint.Server in project cxf by apache.

the class JAXRSUtilsTest method testInjectApplicationInPerRequestResource.

@Test
public void testInjectApplicationInPerRequestResource() throws Exception {
    CustomerApplication app = new CustomerApplication();
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setServiceClass(Customer.class);
    sf.setApplication(app);
    sf.setStart(false);
    Server server = sf.create();
    @SuppressWarnings("unchecked") ThreadLocalProxy<UriInfo> proxy = (ThreadLocalProxy<UriInfo>) app.getUriInfo();
    assertNotNull(proxy);
    ClassResourceInfo cri = sf.getServiceFactory().getClassResourceInfo().get(0);
    Customer customer = (Customer) cri.getResourceProvider().getInstance(createMessage());
    assertNull(customer.getApplication1());
    assertNull(customer.getApplication2());
    invokeCustomerMethod(cri, customer, server);
    assertSame(app, customer.getApplication1());
    assertSame(app, customer.getApplication2());
    assertTrue(proxy.get() instanceof UriInfo);
}
Also used : ThreadLocalProxy(org.apache.cxf.jaxrs.impl.tl.ThreadLocalProxy) Server(org.apache.cxf.endpoint.Server) CustomerApplication(org.apache.cxf.jaxrs.CustomerApplication) Customer(org.apache.cxf.jaxrs.Customer) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) ClassResourceInfo(org.apache.cxf.jaxrs.model.ClassResourceInfo) UriInfo(javax.ws.rs.core.UriInfo) ThreadLocalUriInfo(org.apache.cxf.jaxrs.impl.tl.ThreadLocalUriInfo) Test(org.junit.Test)

Example 50 with Server

use of org.apache.cxf.endpoint.Server in project cxf by apache.

the class RESTLoggingTest method testNonBinary.

@Test
public void testNonBinary() throws IOException, InterruptedException {
    LoggingFeature loggingFeature = new LoggingFeature();
    TestEventSender sender = new TestEventSender();
    loggingFeature.setSender(sender);
    Server server = createService(SERVICE_URI_BINARY, new TestServiceRestBinary(), loggingFeature);
    server.start();
    WebClient client = createClient(SERVICE_URI_BINARY, loggingFeature);
    client.get(InputStream.class).close();
    client.close();
    List<LogEvent> events = sender.getEvents();
    await().until(() -> events.size(), is(4));
    server.stop();
    server.destroy();
    Assert.assertEquals(4, events.size());
    assertContentLogged(events.get(0));
    assertContentLogged(events.get(1));
    assertContentNotLogged(events.get(2));
    assertContentNotLogged(events.get(3));
}
Also used : Server(org.apache.cxf.endpoint.Server) LogEvent(org.apache.cxf.ext.logging.event.LogEvent) InputStream(java.io.InputStream) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Aggregations

Server (org.apache.cxf.endpoint.Server)199 Test (org.junit.Test)119 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)54 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)52 MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)50 Resource (org.apache.cxf.ws.transfer.resource.Resource)50 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)47 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)44 Element (org.w3c.dom.Element)44 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)33 Put (org.apache.cxf.ws.transfer.Put)33 Fragment (org.apache.cxf.ws.transfer.dialect.fragment.Fragment)32 Service (org.apache.cxf.service.Service)27 Bus (org.apache.cxf.Bus)25 PutResponse (org.apache.cxf.ws.transfer.PutResponse)25 Endpoint (org.apache.cxf.endpoint.Endpoint)21 ArrayList (java.util.ArrayList)18 QName (javax.xml.namespace.QName)18 ServerRegistry (org.apache.cxf.endpoint.ServerRegistry)18 Document (org.w3c.dom.Document)18