Search in sources :

Example 11 with DestinationFactoryManager

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

the class MAPAggregatorImpl method getDestination.

/**
 * @param address the address
 * @return a Destination for the address
 */
private Destination getDestination(Bus bus, String address, Message message) throws IOException {
    Destination destination = null;
    DestinationFactoryManager factoryManager = bus.getExtension(DestinationFactoryManager.class);
    DestinationFactory factory = factoryManager.getDestinationFactoryForUri(address);
    if (factory != null) {
        Endpoint ep = message.getExchange().getEndpoint();
        EndpointInfo ei = new EndpointInfo();
        ei.setName(new QName(ep.getEndpointInfo().getName().getNamespaceURI(), ep.getEndpointInfo().getName().getLocalPart() + ".decoupled"));
        ei.setAddress(address);
        destination = factory.getDestination(ei, bus);
        Conduit conduit = ContextUtils.getConduit(null, message);
        if (conduit != null) {
            MessageObserver ob = ((Observable) conduit).getMessageObserver();
            ob = new InterposedMessageObserver(bus, ob);
            destination.setMessageObserver(ob);
        }
    }
    return destination;
}
Also used : Destination(org.apache.cxf.transport.Destination) DestinationFactory(org.apache.cxf.transport.DestinationFactory) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) MessageObserver(org.apache.cxf.transport.MessageObserver) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) Endpoint(org.apache.cxf.endpoint.Endpoint) QName(javax.xml.namespace.QName) Conduit(org.apache.cxf.transport.Conduit) Observable(org.apache.cxf.transport.Observable)

Example 12 with DestinationFactoryManager

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

the class NettyHttpServerEngineFactoryTest method testTransportFactoryHasEngineFactory.

@Test
public void testTransportFactoryHasEngineFactory() 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));
    NettyHttpServerEngineFactory factory = bus.getExtension(NettyHttpServerEngineFactory.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 13 with DestinationFactoryManager

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

the class Wsdl11AttachmentPolicyProviderTest method oneTimeSetUp.

@BeforeClass
public static void oneTimeSetUp() throws Exception {
    IMocksControl control = EasyMock.createNiceControl();
    Bus bus = control.createMock(Bus.class);
    WSDLManager manager = new WSDLManagerImpl();
    WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andReturn(dfm).anyTimes();
    EasyMock.expect(dfm.getDestinationFactory(EasyMock.isA(String.class))).andReturn(null).anyTimes();
    BindingFactoryManager bfm = control.createMock(BindingFactoryManager.class);
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm).anyTimes();
    EasyMock.expect(bfm.getBindingFactory(EasyMock.isA(String.class))).andReturn(null).anyTimes();
    control.replay();
    int n = 19;
    services = new ServiceInfo[n];
    endpoints = new EndpointInfo[n];
    for (int i = 0; i < n; i++) {
        String resourceName = "/attachment/wsdl11/test" + i + ".wsdl";
        URL url = Wsdl11AttachmentPolicyProviderTest.class.getResource(resourceName);
        try {
            services[i] = builder.buildServices(manager.getDefinition(url.toString())).get(0);
        } catch (WSDLException ex) {
            ex.printStackTrace();
            fail("Failed to build service from resource " + resourceName);
        }
        assertNotNull(services[i]);
        endpoints[i] = services[i].getEndpoints().iterator().next();
        assertNotNull(endpoints[i]);
    }
    control.verify();
}
Also used : IMocksControl(org.easymock.IMocksControl) Bus(org.apache.cxf.Bus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) WSDLException(javax.wsdl.WSDLException) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) WSDLManager(org.apache.cxf.wsdl.WSDLManager) WSDLManagerImpl(org.apache.cxf.wsdl11.WSDLManagerImpl) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) URL(java.net.URL) BeforeClass(org.junit.BeforeClass)

Example 14 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 UndertowHTTPDestination);
    UndertowHTTPDestination jd = (UndertowHTTPDestination) d;
    assertEquals("foobar", jd.getServer().getContentEncoding());
    UndertowHTTPServerEngine engine = (UndertowHTTPServerEngine) jd.getEngine();
    assertEquals(111, engine.getThreadingParameters().getMinThreads());
    assertEquals(120, engine.getThreadingParameters().getMaxThreads());
    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());
    UndertowHTTPDestination jd2 = (UndertowHTTPDestination) factory.getDestination(getEndpointInfo("foo", "bar", "http://localhost:9001"), bus);
    engine = (UndertowHTTPServerEngine) jd2.getEngine();
    assertEquals(40000, engine.getMaxIdleTime());
    assertEquals(99, engine.getThreadingParameters().getMinThreads());
    assertEquals(777, engine.getThreadingParameters().getMaxThreads());
    assertNotNull("The handlers should not be null", engine.getHandlers());
    assertEquals(1, engine.getHandlers().size());
    UndertowHTTPDestination jd3 = (UndertowHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo", "https://localhost:9002"), bus);
    engine = (UndertowHTTPServerEngine) jd3.getEngine();
    assertEquals(111, engine.getThreadingParameters().getMinThreads());
    assertEquals(120, engine.getThreadingParameters().getMaxThreads());
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isWant(), true);
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isRequired(), true);
    UndertowHTTPDestination jd4 = (UndertowHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo2", "https://localhost:9003"), bus);
    engine = (UndertowHTTPServerEngine) jd4.getEngine();
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isWant(), false);
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isRequired(), false);
    UndertowHTTPDestination jd5 = (UndertowHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo", "http://localhost:9100"), bus);
    engine = (UndertowHTTPServerEngine) 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 : UndertowHTTPServerEngine(org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngine) Bus(org.apache.cxf.Bus) DestinationFactory(org.apache.cxf.transport.DestinationFactory) Destination(org.apache.cxf.transport.Destination) UndertowHTTPDestination(org.apache.cxf.transport.http_undertow.UndertowHTTPDestination) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) ConfigurerImpl(org.apache.cxf.configuration.spring.ConfigurerImpl) UndertowHTTPDestination(org.apache.cxf.transport.http_undertow.UndertowHTTPDestination) 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) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator)

Example 15 with DestinationFactoryManager

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

the class AbstractWSDLBasedEndpointFactory method modifyTransportIdPerAddress.

private void modifyTransportIdPerAddress(EndpointInfo ei) {
    // this is useful for local & camel transport
    if (transportId == null && getAddress() != null) {
        DestinationFactory df = getDestinationFactory();
        if (df == null) {
            DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class);
            df = dfm.getDestinationFactoryForUri(getAddress());
        }
        if (df != null) {
            transportId = df.getTransportIds().get(0);
        } else {
            // check conduits (the address could be supported on
            // client only)
            ConduitInitiatorManager cim = getBus().getExtension(ConduitInitiatorManager.class);
            ConduitInitiator ci = cim.getConduitInitiatorForUri(getAddress());
            if (ci != null) {
                transportId = ci.getTransportIds().get(0);
            }
        }
    }
    if (transportId != null) {
        ei.setTransportId(transportId);
    }
}
Also used : DestinationFactory(org.apache.cxf.transport.DestinationFactory) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator)

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