Search in sources :

Example 1 with DestinationFactory

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

the class SoapTransportFactory method getDestination.

public Destination getDestination(EndpointInfo ei, Bus bus) throws IOException {
    String address = ei.getAddress();
    BindingInfo bi = ei.getBinding();
    String transId = ei.getTransportId();
    if (bi instanceof SoapBindingInfo) {
        transId = ((SoapBindingInfo) bi).getTransportURI();
        if (transId == null) {
            transId = ei.getTransportId();
        }
    }
    DestinationFactory destinationFactory;
    try {
        DestinationFactoryManager mgr = bus.getExtension(DestinationFactoryManager.class);
        if (StringUtils.isEmpty(address) || address.startsWith("http") || address.startsWith("jms") || address.startsWith("soap.udp") || address.startsWith("/")) {
            destinationFactory = mgr.getDestinationFactory(mapTransportURI(transId, address));
        } else {
            destinationFactory = mgr.getDestinationFactoryForUri(address);
        }
        if (destinationFactory == null) {
            throw new IOException("Could not find destination factory for transport " + transId);
        }
        return destinationFactory.getDestination(ei, bus);
    } catch (BusException e) {
        IOException ex = new IOException("Could not find destination factory for transport " + transId);
        ex.initCause(e);
        throw ex;
    }
}
Also used : DestinationFactory(org.apache.cxf.transport.DestinationFactory) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) IOException(java.io.IOException) BusException(org.apache.cxf.BusException)

Example 2 with DestinationFactory

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

the class ServiceImpl method createEndpointInfo.

private EndpointInfo createEndpointInfo(AbstractServiceFactoryBean serviceFactory, QName portName, PortInfoImpl portInfo) throws BusException {
    EndpointInfo ei = null;
    String address = portInfo.getAddress();
    String bindingID = BindingID.getBindingID(portInfo.getBindingID());
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    try {
        // the bindingId might be the transportId, just attempt to
        // load it to force the factory to load
        dfm.getDestinationFactory(bindingID);
    } catch (BusException ex) {
    // ignore
    }
    DestinationFactory df = dfm.getDestinationFactoryForUri(address);
    String transportId = null;
    if (df != null && df.getTransportIds() != null && !df.getTransportIds().isEmpty()) {
        transportId = df.getTransportIds().get(0);
    } else {
        transportId = bindingID;
    }
    Object config = null;
    if (serviceFactory instanceof JaxWsServiceFactoryBean) {
        config = new JaxWsSoapBindingConfiguration((JaxWsServiceFactoryBean) serviceFactory);
    }
    BindingInfo bindingInfo = bus.getExtension(BindingFactoryManager.class).getBindingFactory(bindingID).createBindingInfo(serviceFactory.getService(), bindingID, config);
    Service service = serviceFactory.getService();
    service.getServiceInfos().get(0).addBinding(bindingInfo);
    ei = new EndpointInfo(service.getServiceInfos().get(0), transportId);
    ei.setName(portName);
    ei.setAddress(address);
    ei.setBinding(bindingInfo);
    service.getServiceInfos().get(0).addEndpoint(ei);
    return ei;
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) DestinationFactory(org.apache.cxf.transport.DestinationFactory) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) BindingInfo(org.apache.cxf.service.model.BindingInfo) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) JaxWsSoapBindingConfiguration(org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration) BusException(org.apache.cxf.BusException)

Example 3 with DestinationFactory

use of org.apache.cxf.transport.DestinationFactory 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 4 with DestinationFactory

use of org.apache.cxf.transport.DestinationFactory 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 5 with DestinationFactory

use of org.apache.cxf.transport.DestinationFactory 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)

Aggregations

DestinationFactory (org.apache.cxf.transport.DestinationFactory)19 DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)18 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)10 Bus (org.apache.cxf.Bus)9 Destination (org.apache.cxf.transport.Destination)7 QName (javax.xml.namespace.QName)6 BusException (org.apache.cxf.BusException)4 ConduitInitiator (org.apache.cxf.transport.ConduitInitiator)4 ConduitInitiatorManager (org.apache.cxf.transport.ConduitInitiatorManager)4 HTTPTransportFactory (org.apache.cxf.transport.http.HTTPTransportFactory)4 Test (org.junit.Test)4 ConfigurerImpl (org.apache.cxf.configuration.spring.ConfigurerImpl)3 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)3 IOException (java.io.IOException)2 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)2 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)2 Message (org.apache.cxf.message.Message)2 MessageImpl (org.apache.cxf.message.MessageImpl)2 BindingInfo (org.apache.cxf.service.model.BindingInfo)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1