Java Code Examples for org.apache.cxf.transport.DestinationFactoryManager#getDestinationFactoryForUri()

The following examples show how to use org.apache.cxf.transport.DestinationFactoryManager#getDestinationFactoryForUri() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MAPAggregatorImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * @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 = conduit.getMessageObserver();
            ob = new InterposedMessageObserver(bus, ob);
            destination.setMessageObserver(ob);
        }
    }
    return destination;
}
 
Example 2
Source File: ServerFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
protected String detectTransportIdFromAddress(String ad) {
    DestinationFactory df = getDestinationFactory();
    if (df == null) {
        DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class);
        df = dfm.getDestinationFactoryForUri(getAddress());
        if (df != null) {
            return df.getTransportIds().get(0);
        }
    }
    return null;
}
 
Example 3
Source File: AbstractWSDLBasedEndpointFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void modifyTransportIdPerAddress(EndpointInfo ei) {
    //get chance to set transportId according to the the publish address prefix
    //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);
    }
}
 
Example 4
Source File: AbstractJAXRSFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
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(service.getServiceInfos().get(0), 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;
}
 
Example 5
Source File: SoapTransportFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example 6
Source File: ProtobufServerFactoryBean.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
protected EndpointInfo createEndpointInfo() 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());
        }

        if (df != null) {
            transportId = df.getTransportIds().get(0);
        }
    }

    // default to http transport
    if (transportId == null) {
        transportId = "http://schemas.xmlsoap.org/wsdl/soap/http";
    }

    setTransportId(transportId);

    EndpointInfo ei = new EndpointInfo();
    ei.setTransportId(transportId);
    ei.setName(serviceFactory.getService().getName());
    ei.setAddress(getAddress());
    ei.setProperty(PROTOBUF_MESSAGE_CLASS, messageClass);

    BindingInfo bindingInfo = createBindingInfo();
    ei.setBinding(bindingInfo);

    return ei;
}