Search in sources :

Example 1 with MultiplexDestination

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

the class EndpointReferenceUtils method getEndpointReferenceWithId.

/**
 * Obtain a multiplexed endpoint reference for the deployed service that contains the provided id
 * @param serviceQName identified the target service
 * @param portName identifies a particular port of the service, may be null
 * @param id that must be embedded in the returned reference
 * @param bus the current bus
 * @return a new reference or null if the target destination does not support destination mutiplexing
 */
public static EndpointReferenceType getEndpointReferenceWithId(QName serviceQName, String portName, String id, Bus bus) {
    EndpointReferenceType epr = null;
    MultiplexDestination destination = getMatchingMultiplexDestination(serviceQName, portName, bus);
    if (null != destination) {
        epr = destination.getAddressWithId(id);
    }
    return epr;
}
Also used : MultiplexDestination(org.apache.cxf.transport.MultiplexDestination)

Example 2 with MultiplexDestination

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

the class EndpointReferenceUtils method getMatchingMultiplexDestination.

private static MultiplexDestination getMatchingMultiplexDestination(QName serviceQName, String portName, Bus bus) {
    MultiplexDestination destination = null;
    ServerRegistry serverRegistry = bus.getExtension(ServerRegistry.class);
    if (null != serverRegistry) {
        List<Server> servers = serverRegistry.getServers();
        for (Server s : servers) {
            QName targetServiceQName = s.getEndpoint().getEndpointInfo().getService().getName();
            if (serviceQName.equals(targetServiceQName) && portNameMatches(s, portName)) {
                Destination dest = s.getDestination();
                if (dest instanceof MultiplexDestination) {
                    destination = (MultiplexDestination) dest;
                    break;
                }
            }
        }
    } else {
        LOG.log(Level.WARNING, "Failed to locate service matching " + serviceQName + ", because the bus ServerRegistry extension provider is null");
    }
    return destination;
}
Also used : Destination(org.apache.cxf.transport.Destination) MultiplexDestination(org.apache.cxf.transport.MultiplexDestination) Server(org.apache.cxf.endpoint.Server) QName(javax.xml.namespace.QName) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry) MultiplexDestination(org.apache.cxf.transport.MultiplexDestination)

Example 3 with MultiplexDestination

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

the class JMSDestinationTest method testIsMultiplexCapable.

@Test
public void testIsMultiplexCapable() throws Exception {
    EndpointInfo ei = setupServiceInfo("HelloWorldService", "HelloWorldPort");
    final JMSDestination destination = setupJMSDestination(ei);
    destination.setMessageObserver(createMessageObserver());
    assertTrue("is multiplex", destination instanceof MultiplexDestination);
    destination.shutdown();
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) MultiplexDestination(org.apache.cxf.transport.MultiplexDestination) Test(org.junit.Test)

Example 4 with MultiplexDestination

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

the class EndpointReferenceUtils method getEndpointReferenceId.

/**
 * Obtain the id String from the endpoint reference of the current dispatch.
 * @param messageContext the current message context
 * @return the id embedded in the current endpoint reference or null if not found
 */
public static String getEndpointReferenceId(Map<String, Object> messageContext) {
    String id = null;
    Destination destination = (Destination) messageContext.get(Destination.class.getName());
    if (destination instanceof MultiplexDestination) {
        id = ((MultiplexDestination) destination).getId(messageContext);
    }
    return id;
}
Also used : Destination(org.apache.cxf.transport.Destination) MultiplexDestination(org.apache.cxf.transport.MultiplexDestination) MultiplexDestination(org.apache.cxf.transport.MultiplexDestination)

Aggregations

MultiplexDestination (org.apache.cxf.transport.MultiplexDestination)4 Destination (org.apache.cxf.transport.Destination)2 QName (javax.xml.namespace.QName)1 Server (org.apache.cxf.endpoint.Server)1 ServerRegistry (org.apache.cxf.endpoint.ServerRegistry)1 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)1 Test (org.junit.Test)1