Search in sources :

Example 1 with SLProperties

use of org.talend.esb.servicelocator.client.SLProperties in project tesb-rt-se by Talend.

the class LocatorSoapServiceImpl method buildEndpoint.

/**
 * Build Endpoint Reference for giving service name and address
 *
 * @param serviceName
 * @param adress
 * @return
 */
private W3CEndpointReference buildEndpoint(QName serviceName, String adress) throws ServiceLocatorFault, InterruptedExceptionFault {
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    // builder.serviceName(serviceName);
    builder.address(adress);
    SLEndpoint endpoint = null;
    try {
        endpoint = locatorClient.getEndpoint(serviceName, adress);
    } catch (ServiceLocatorException e) {
        ServiceLocatorFaultDetail serviceFaultDetail = new ServiceLocatorFaultDetail();
        serviceFaultDetail.setLocatorFaultDetail(serviceName.toString() + "throws ServiceLocatorFault");
        throw new ServiceLocatorFault(e.getMessage(), serviceFaultDetail);
    } catch (InterruptedException e) {
        InterruptionFaultDetail interruptionFaultDetail = new InterruptionFaultDetail();
        interruptionFaultDetail.setInterruptionDetail(serviceName.toString() + "throws InterruptionFault");
        throw new InterruptedExceptionFault(e.getMessage(), interruptionFaultDetail);
    }
    if (endpoint != null) {
        SLProperties properties = endpoint.getProperties();
        if (properties != null && !properties.getPropertyNames().isEmpty()) {
            EndpointTransformerImpl transformer = new EndpointTransformerImpl();
            DOMResult result = new DOMResult();
            transformer.writePropertiesTo(properties, result);
            Document docResult = (Document) result.getNode();
            builder.metadata(docResult.getDocumentElement());
        }
    }
    return builder.build();
}
Also used : SLProperties(org.talend.esb.servicelocator.client.SLProperties) W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) EndpointTransformerImpl(org.talend.esb.servicelocator.client.internal.EndpointTransformerImpl) DOMResult(javax.xml.transform.dom.DOMResult) InterruptionFaultDetail(org.talend.schemas.esb.locator._2011._11.InterruptionFaultDetail) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) ServiceLocatorFault(org.talend.services.esb.locator.v1.ServiceLocatorFault) SLEndpoint(org.talend.esb.servicelocator.client.SLEndpoint) Document(org.w3c.dom.Document) InterruptedExceptionFault(org.talend.services.esb.locator.v1.InterruptedExceptionFault) ServiceLocatorFaultDetail(org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail)

Example 2 with SLProperties

use of org.talend.esb.servicelocator.client.SLProperties in project tesb-rt-se by Talend.

the class LocatorRestServiceImpl method buildEndpoint.

/**
 * Build Endpoint Reference for giving service name and address
 *
 * @param serviceName
 * @param adress
 * @return
 */
private W3CEndpointReference buildEndpoint(QName serviceName, String adress) {
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    // builder.serviceName(serviceName);
    builder.address(adress);
    SLEndpoint endpoint = null;
    try {
        endpoint = locatorClient.getEndpoint(serviceName, adress);
    } catch (ServiceLocatorException e) {
        throw new WebApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build());
    } catch (InterruptedException e) {
        throw new WebApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build());
    }
    if (endpoint != null) {
        SLProperties properties = endpoint.getProperties();
        if (properties != null && !properties.getPropertyNames().isEmpty()) {
            EndpointTransformerImpl transformer = new EndpointTransformerImpl();
            DOMResult result = new DOMResult();
            transformer.writePropertiesTo(properties, result);
            Document docResult = (Document) result.getNode();
            builder.metadata(docResult.getDocumentElement());
        }
    }
    return builder.build();
}
Also used : SLProperties(org.talend.esb.servicelocator.client.SLProperties) W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) EndpointTransformerImpl(org.talend.esb.servicelocator.client.internal.EndpointTransformerImpl) DOMResult(javax.xml.transform.dom.DOMResult) WebApplicationException(javax.ws.rs.WebApplicationException) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) SLEndpoint(org.talend.esb.servicelocator.client.SLEndpoint) Document(org.w3c.dom.Document)

Example 3 with SLProperties

use of org.talend.esb.servicelocator.client.SLProperties in project tesb-rt-se by Talend.

the class CXFEndpointProviderTest method getProperties.

@Test
public void getProperties() {
    CXFEndpointProvider epp = new CXFEndpointProvider(SERVICE_QNAME_1, ENDPOINT_1, PROPERTIES);
    SLProperties properties = epp.getProperties();
    assertTrue(properties.hasProperty(NAME_1));
    assertTrue(properties.hasProperty(NAME_2));
}
Also used : SLProperties(org.talend.esb.servicelocator.client.SLProperties) Test(org.junit.Test)

Example 4 with SLProperties

use of org.talend.esb.servicelocator.client.SLProperties in project tesb-rt-se by Talend.

the class CXFEndpointProviderTest method getPropertiesNotDefined.

@Test
public void getPropertiesNotDefined() {
    CXFEndpointProvider epp = new CXFEndpointProvider(SERVICE_QNAME_1, ENDPOINT_1, null);
    SLProperties properties = epp.getProperties();
    Collection<String> keys = properties.getPropertyNames();
    assertThat(keys, empty());
}
Also used : SLProperties(org.talend.esb.servicelocator.client.SLProperties) Test(org.junit.Test)

Example 5 with SLProperties

use of org.talend.esb.servicelocator.client.SLProperties in project tesb-rt-se by Talend.

the class ServiceLocatorImpl method lookup.

/**
 * {@inheritDoc}
 */
@Override
public synchronized List<String> lookup(QName serviceName, SLPropertiesMatcher matcher) throws ServiceLocatorException, InterruptedException {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Looking up endpoints of service " + serviceName + "...");
    }
    List<String> liveEndpoints;
    RootNode rootNode = getBackend().connect();
    ServiceNode serviceNode = rootNode.getServiceNode(serviceName);
    if (serviceNode.exists()) {
        liveEndpoints = new ArrayList<String>();
        List<EndpointNode> endpointNodes = serviceNode.getEndPoints();
        for (EndpointNode endpointNode : endpointNodes) {
            if (endpointNode.isLive()) {
                byte[] content = endpointNode.getContent();
                SLEndpoint endpoint = transformer.toSLEndpoint(serviceName, content, true);
                SLProperties props = endpoint.getProperties();
                if (LOG.isLoggable(Level.FINE)) {
                    StringBuilder sb = new StringBuilder();
                    for (String prop : props.getPropertyNames()) {
                        sb.append(prop + " : ");
                        for (String value : props.getValues(prop)) {
                            sb.append(value + " ");
                        }
                        sb.append("\n");
                    }
                    LOG.fine("Lookup of service " + serviceName + " props = " + sb.toString());
                    LOG.fine("matcher = " + matcher.toString());
                }
                if (matcher.isMatching(props)) {
                    liveEndpoints.add(endpointNode.getEndpointName());
                    if (LOG.isLoggable(Level.FINE))
                        LOG.fine("matched =  " + endpointNode.getEndpointName());
                } else if (LOG.isLoggable(Level.FINE))
                    LOG.fine("not matched =  " + endpointNode.getEndpointName());
            }
        }
    } else {
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("Lookup of service " + serviceName + " failed, service is not known.");
        }
        liveEndpoints = Collections.emptyList();
    }
    return liveEndpoints;
}
Also used : SLProperties(org.talend.esb.servicelocator.client.SLProperties) SLEndpoint(org.talend.esb.servicelocator.client.SLEndpoint)

Aggregations

SLProperties (org.talend.esb.servicelocator.client.SLProperties)6 SLEndpoint (org.talend.esb.servicelocator.client.SLEndpoint)4 Test (org.junit.Test)3 DOMResult (javax.xml.transform.dom.DOMResult)2 W3CEndpointReferenceBuilder (javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder)2 ServiceLocatorException (org.talend.esb.servicelocator.client.ServiceLocatorException)2 EndpointTransformerImpl (org.talend.esb.servicelocator.client.internal.EndpointTransformerImpl)2 Document (org.w3c.dom.Document)2 HashMap (java.util.HashMap)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 QName (javax.xml.namespace.QName)1 Bus (org.apache.cxf.Bus)1 ClientLifeCycleManagerImpl (org.apache.cxf.bus.managers.ClientLifeCycleManagerImpl)1 ServerLifeCycleManagerImpl (org.apache.cxf.bus.managers.ServerLifeCycleManagerImpl)1 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)1 Service (org.apache.cxf.service.Service)1 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)1 ServiceLocator (org.talend.esb.servicelocator.client.ServiceLocator)1 ServiceLocatorMock (org.talend.esb.servicelocator.cxf.internal.internal.ServiceLocatorMock)1 InterruptionFaultDetail (org.talend.schemas.esb.locator._2011._11.InterruptionFaultDetail)1