Search in sources :

Example 26 with DestinationFactoryManager

use of org.apache.cxf.transport.DestinationFactoryManager in project cxf by apache.

the class AbstractJAXRSFactoryBean method createEndpointInfo.

/*
     * EndpointInfo contains information form WSDL's physical part such as
     * endpoint address, binding, transport etc. For JAX-RS based EndpointInfo,
     * as there is no WSDL, these information are set manually, eg, default
     * transport is http, binding is JAX-RS binding, endpoint address is from
     * server mainline.
     */
protected EndpointInfo createEndpointInfo(Service service) throws BusException {
    String transportId = getTransportId();
    if (transportId == null && getAddress() != null) {
        DestinationFactory df = getDestinationFactory();
        if (df == null) {
            DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class);
            df = dfm.getDestinationFactoryForUri(getAddress());
            super.setDestinationFactory(df);
        }
        if (df != null) {
            transportId = df.getTransportIds().get(0);
        }
    }
    // default to http transport
    if (transportId == null) {
        transportId = "http://cxf.apache.org/transports/http";
    }
    setTransportId(transportId);
    EndpointInfo ei = new EndpointInfo();
    ei.setTransportId(transportId);
    ei.setName(serviceFactory.getService().getName());
    ei.setAddress(getAddress());
    BindingInfo bindingInfo = createBindingInfo();
    ei.setBinding(bindingInfo);
    if (!StringUtils.isEmpty(publishedEndpointUrl)) {
        ei.setProperty("publishedEndpointUrl", publishedEndpointUrl);
    }
    ei.setName(service.getName());
    serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINTINFO_CREATED, ei);
    return ei;
}
Also used : DestinationFactory(org.apache.cxf.transport.DestinationFactory) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) BindingInfo(org.apache.cxf.service.model.BindingInfo)

Example 27 with DestinationFactoryManager

use of org.apache.cxf.transport.DestinationFactoryManager in project cxf by apache.

the class JettyHTTPServerEngineFactoryTest method testMakeSureTransportFactoryHasEngineFactory.

/**
 * This test makes sure that a default Spring initialized bus will
 * have the JettyHTTPServerEngineFactory (absent of <httpj:engine-factory>
 * configuration.
 */
@Test
public void testMakeSureTransportFactoryHasEngineFactory() throws Exception {
    bus = BusFactory.getDefaultBus(true);
    assertNotNull("Cannot get bus", bus);
    // Make sure we got the Transport Factory.
    DestinationFactoryManager destFM = bus.getExtension(DestinationFactoryManager.class);
    assertNotNull("Cannot get DestinationFactoryManager", destFM);
    DestinationFactory destF = destFM.getDestinationFactory("http://cxf.apache.org/transports/http");
    assertNotNull("No DestinationFactory", destF);
    assertTrue(HTTPTransportFactory.class.isInstance(destF));
    // And the JettyHTTPServerEngineFactory should be there.
    JettyHTTPServerEngineFactory factory = bus.getExtension(JettyHTTPServerEngineFactory.class);
    assertNotNull("EngineFactory is not configured.", factory);
}
Also used : DestinationFactory(org.apache.cxf.transport.DestinationFactory) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) Test(org.junit.Test)

Example 28 with DestinationFactoryManager

use of org.apache.cxf.transport.DestinationFactoryManager in project cxf by apache.

the class ApplicationContextTest method checkContext.

private void checkContext(TestApplicationContext ctx) throws Exception {
    ConfigurerImpl cfg = new ConfigurerImpl(ctx);
    EndpointInfo info = getEndpointInfo("bla", "Foo", "http://localhost:9000");
    Bus bus = (Bus) ctx.getBean(Bus.DEFAULT_BUS_ID);
    bus.setExtension(cfg, Configurer.class);
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    DestinationFactory factory = dfm.getDestinationFactory("http://cxf.apache.org/transports/http");
    Destination d = factory.getDestination(info, bus);
    assertTrue(d instanceof JettyHTTPDestination);
    JettyHTTPDestination jd = (JettyHTTPDestination) d;
    assertEquals("foobar", jd.getServer().getContentEncoding());
    JettyHTTPServerEngine engine = (JettyHTTPServerEngine) jd.getEngine();
    assertEquals(111, engine.getThreadingParameters().getMinThreads());
    assertEquals(120, engine.getThreadingParameters().getMaxThreads());
    assertEquals("TestPrefix", engine.getThreadingParameters().getThreadNamePrefix());
    ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
    ConduitInitiator ci = cim.getConduitInitiator("http://cxf.apache.org/transports/http");
    HTTPConduit conduit = (HTTPConduit) ci.getConduit(info, bus);
    assertEquals(97, conduit.getClient().getConnectionTimeout());
    info.setName(new QName("urn:test:ns", "Bar"));
    conduit = (HTTPConduit) ci.getConduit(info, bus);
    assertEquals(79, conduit.getClient().getConnectionTimeout());
    JettyHTTPDestination jd2 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("foo", "bar", "http://localhost:9001"), bus);
    engine = (JettyHTTPServerEngine) jd2.getEngine();
    assertEquals(40000, engine.getMaxIdleTime());
    assertFalse(engine.getSendServerVersion());
    assertEquals(99, engine.getThreadingParameters().getMinThreads());
    assertEquals(777, engine.getThreadingParameters().getMaxThreads());
    assertEquals("AnotherPrefix", engine.getThreadingParameters().getThreadNamePrefix());
    assertTrue("The engine should support session manager", engine.isSessionSupport());
    assertNotNull("The handlers should not be null", engine.getHandlers());
    assertEquals(1, engine.getHandlers().size());
    JettyHTTPDestination jd3 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo", "https://localhost:9002"), bus);
    engine = (JettyHTTPServerEngine) jd3.getEngine();
    assertEquals(111, engine.getThreadingParameters().getMinThreads());
    assertEquals(120, engine.getThreadingParameters().getMaxThreads());
    assertEquals("TestPrefix", engine.getThreadingParameters().getThreadNamePrefix());
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isWant(), true);
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isRequired(), true);
    JettyHTTPDestination jd4 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo2", "https://localhost:9003"), bus);
    engine = (JettyHTTPServerEngine) jd4.getEngine();
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isWant(), false);
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isRequired(), false);
    JettyHTTPDestination jd5 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo", "http://localhost:9100"), bus);
    engine = (JettyHTTPServerEngine) jd5.getEngine();
    String r = "expected fallback thread parameters configured for port 0";
    assertNotNull(r, engine.getThreadingParameters());
    assertEquals(r, 21, engine.getThreadingParameters().getMinThreads());
    assertEquals(r, 389, engine.getThreadingParameters().getMaxThreads());
}
Also used : Bus(org.apache.cxf.Bus) DestinationFactory(org.apache.cxf.transport.DestinationFactory) Destination(org.apache.cxf.transport.Destination) JettyHTTPDestination(org.apache.cxf.transport.http_jetty.JettyHTTPDestination) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) ConfigurerImpl(org.apache.cxf.configuration.spring.ConfigurerImpl) QName(javax.xml.namespace.QName) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) JettyHTTPServerEngine(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator) JettyHTTPDestination(org.apache.cxf.transport.http_jetty.JettyHTTPDestination)

Example 29 with DestinationFactoryManager

use of org.apache.cxf.transport.DestinationFactoryManager in project cxf by apache.

the class ApplicationContextTest method checkContext.

private void checkContext(TestApplicationContext ctx) throws Exception {
    ConfigurerImpl cfg = new ConfigurerImpl(ctx);
    EndpointInfo info = getEndpointInfo("bla", "Foo", "http://localhost:9000");
    Bus bus = (Bus) ctx.getBean(Bus.DEFAULT_BUS_ID);
    bus.setExtension(cfg, Configurer.class);
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    DestinationFactory factory = dfm.getDestinationFactory("http://cxf.apache.org/transports/http");
    Destination d = factory.getDestination(info, bus);
    assertTrue(d instanceof NettyHttpDestination);
    NettyHttpDestination jd = (NettyHttpDestination) d;
    assertEquals("foobar", jd.getServer().getContentEncoding());
    NettyHttpServerEngine engine = (NettyHttpServerEngine) jd.getEngine();
    assertEquals(120, engine.getThreadingParameters().getThreadPoolSize());
    ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
    ConduitInitiator ci = cim.getConduitInitiator("http://cxf.apache.org/transports/http");
    HTTPConduit conduit = (HTTPConduit) ci.getConduit(info, bus);
    assertEquals(97, conduit.getClient().getConnectionTimeout());
    info.setName(new QName("urn:test:ns", "Bar"));
    conduit = (HTTPConduit) ci.getConduit(info, bus);
    assertEquals(79, conduit.getClient().getConnectionTimeout());
    NettyHttpDestination jd2 = (NettyHttpDestination) factory.getDestination(getEndpointInfo("foo", "bar", "http://localhost:9001"), bus);
    engine = (NettyHttpServerEngine) jd2.getEngine();
    assertEquals(40000, engine.getReadIdleTime());
    assertEquals(10000, engine.getMaxChunkContentSize());
    assertTrue("The engine should support session manager", engine.isSessionSupport());
    NettyHttpDestination jd3 = (NettyHttpDestination) factory.getDestination(getEndpointInfo("sna", "foo", "https://localhost:9002"), bus);
    engine = (NettyHttpServerEngine) jd3.getEngine();
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isWant(), true);
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isRequired(), true);
    NettyHttpDestination jd4 = (NettyHttpDestination) factory.getDestination(getEndpointInfo("sna", "foo2", "https://localhost:9003"), bus);
    engine = (NettyHttpServerEngine) jd4.getEngine();
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isWant(), false);
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isRequired(), false);
/*NettyHttpDestination jd5 =
            (NettyHttpDestination)factory.getDestination(
                getEndpointInfo("sna", "foo", "http://localhost:9100"));*/
/*engine = (NettyHttpServerEngine)jd5.getEngine();
        String r = "expected fallback thread parameters configured for port 0";
        assertNotNull(r, engine.getThreadingParameters());
        assertEquals(r, 21, engine.getThreadingParameters().getMinThreads());
        assertEquals(r, 389, engine.getThreadingParameters().getMaxThreads());*/
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Bus(org.apache.cxf.Bus) DestinationFactory(org.apache.cxf.transport.DestinationFactory) Destination(org.apache.cxf.transport.Destination) NettyHttpDestination(org.apache.cxf.transport.http.netty.server.NettyHttpDestination) NettyHttpServerEngine(org.apache.cxf.transport.http.netty.server.NettyHttpServerEngine) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) ConfigurerImpl(org.apache.cxf.configuration.spring.ConfigurerImpl) QName(javax.xml.namespace.QName) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator) NettyHttpDestination(org.apache.cxf.transport.http.netty.server.NettyHttpDestination)

Example 30 with DestinationFactoryManager

use of org.apache.cxf.transport.DestinationFactoryManager in project cxf by apache.

the class UndertowHTTPServerEngineFactoryTest method testMakeSureTransportFactoryHasEngineFactory.

/**
 * This test makes sure that a default Spring initialized bus will
 * have the UndertowHTTPServerEngineFactory (absent of <httpu:engine-factory>
 * configuration.
 */
@Test
public void testMakeSureTransportFactoryHasEngineFactory() throws Exception {
    bus = BusFactory.getDefaultBus(true);
    assertNotNull("Cannot get bus", bus);
    // Make sure we got the Transport Factory.
    DestinationFactoryManager destFM = bus.getExtension(DestinationFactoryManager.class);
    assertNotNull("Cannot get DestinationFactoryManager", destFM);
    DestinationFactory destF = destFM.getDestinationFactory("http://cxf.apache.org/transports/http");
    assertNotNull("No DestinationFactory", destF);
    assertTrue(HTTPTransportFactory.class.isInstance(destF));
    // And the UndertowHTTPServerEngineFactory should be there.
    UndertowHTTPServerEngineFactory factory = bus.getExtension(UndertowHTTPServerEngineFactory.class);
    assertNotNull("EngineFactory is not configured.", factory);
}
Also used : DestinationFactory(org.apache.cxf.transport.DestinationFactory) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) Test(org.junit.Test)

Aggregations

DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)40 Bus (org.apache.cxf.Bus)23 DestinationFactory (org.apache.cxf.transport.DestinationFactory)18 ConduitInitiatorManager (org.apache.cxf.transport.ConduitInitiatorManager)16 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)15 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)13 QName (javax.xml.namespace.QName)9 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)8 WSDLServiceBuilder (org.apache.cxf.wsdl11.WSDLServiceBuilder)8 Before (org.junit.Before)8 Test (org.junit.Test)8 Destination (org.apache.cxf.transport.Destination)7 BindingInfo (org.apache.cxf.service.model.BindingInfo)6 Definition (javax.wsdl.Definition)5 Service (javax.wsdl.Service)5 WSDLReader (javax.wsdl.xml.WSDLReader)5 SoapBindingInfo (org.apache.cxf.binding.soap.model.SoapBindingInfo)5 LocalTransportFactory (org.apache.cxf.transport.local.LocalTransportFactory)5 BusException (org.apache.cxf.BusException)4 ConduitInitiator (org.apache.cxf.transport.ConduitInitiator)4