Search in sources :

Example 6 with ServiceLocatorException

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

the class LocatorRestServiceTest method unregisterEndpointExpectedLocatorException.

@Test(expected = WebApplicationException.class)
public void unregisterEndpointExpectedLocatorException() throws ServiceLocatorException, InterruptedException {
    sl.unregister(SERVICE_NAME, ENDPOINTURL);
    EasyMock.expectLastCall().andStubThrow(new ServiceLocatorException("test"));
    replayAll();
    lps.unregisterEndpoint(SERVICE_NAME.toString(), ENDPOINTURL);
}
Also used : ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) Test(org.junit.Test)

Example 7 with ServiceLocatorException

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

the class LocatorSoapServiceImpl method updateTimetolive.

/**
 * @see ServiceLocator
 */
@Override
public void updateTimetolive(QName serviceName, String endpointURL, int timetolive) throws ServiceLocatorFault, InterruptedExceptionFault {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Updating expiring time to happen in " + timetolive + " seconds on endpoint " + endpointURL + " for service " + serviceName + "...");
    }
    try {
        initLocator();
        locatorClient.updateTimetolive(serviceName, endpointURL, timetolive);
    } 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);
    }
}
Also used : InterruptionFaultDetail(org.talend.schemas.esb.locator._2011._11.InterruptionFaultDetail) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) ServiceLocatorFault(org.talend.services.esb.locator.v1.ServiceLocatorFault) InterruptedExceptionFault(org.talend.services.esb.locator.v1.InterruptedExceptionFault) ServiceLocatorFaultDetail(org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail)

Example 8 with ServiceLocatorException

use of org.talend.esb.servicelocator.client.ServiceLocatorException 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 9 with ServiceLocatorException

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

the class ListOperation method execute.

@Override
public Object execute() throws Exception {
    ServiceLocatorTracker slt = ServiceLocatorTracker.getInstance(sl);
    slt.updateServiceList();
    try {
        List<QName> services = new ArrayList<QName>(slt.getServiceQNames());
        if (services.isEmpty()) {
            System.out.println();
            System.out.println("No Services registered at Service Locator");
            System.out.println();
            return null;
        }
        sortServices(services);
        for (QName service : services) {
            if (filter != null && filter.length() > 0 && !service.toString().contains(filter)) {
                // Filter is set but does not match
                continue;
            }
            StringBuilder sb = new StringBuilder();
            List<SLEndpoint> endpoints = sl.getEndpoints(service);
            sortEndpoints(endpoints);
            int offlineEndpointsCount = 0;
            int onlineEndpointsCount = 0;
            for (SLEndpoint endpoint : endpoints) {
                boolean alive = endpoint.isLive();
                if (alive) {
                    onlineEndpointsCount++;
                } else {
                    offlineEndpointsCount++;
                }
                if (!offlineEndpointsOnly || offlineEndpointsOnly && !alive) {
                    sb.append(" |-");
                    sb.append(alive ? "\u001b[1;32m online \u001b[0m : " : "\u001b[1;31m offline\u001b[0m : ");
                    String address = endpoint.getAddress();
                    sb.append(address);
                    if (printProtocol || verbose) {
                        String protocol = endpoint.getBinding().getValue();
                        sb.append(" : ").append(protocol);
                    }
                    if (printTransport || verbose) {
                        String transport = endpoint.getTransport().getValue();
                        sb.append(" : ").append(transport);
                    }
                    if (printDate || verbose) {
                        if (alive) {
                            long lastTimeStarted = endpoint.getLastTimeStarted();
                            sb.append(" : online since ").append(formatTimeStamp(lastTimeStarted));
                        } else {
                            long lastTimeStopped = endpoint.getLastTimeStopped();
                            sb.append(" : offline since ").append(formatTimeStamp(lastTimeStopped));
                        }
                    }
                    sb.append("\n");
                    if (printProperties || verbose) {
                        sb.append(printProperties(endpoint.getProperties()));
                    }
                }
            }
            // Now add first line including endpoint count
            StringBuilder sbServiceName = new StringBuilder();
            if (printServiceNamespace || verbose) {
                sbServiceName.append("{").append(service.getNamespaceURI()).append("}");
            }
            sbServiceName.append("\u001b[1;37m").append(service.getLocalPart()).append("\u001b[0m");
            sbServiceName.append(" (").append(onlineEndpointsCount).append("/").append(onlineEndpointsCount + offlineEndpointsCount).append(")");
            sbServiceName.append("\n");
            sb.insert(0, sbServiceName);
            // Now print complete StringBuilder content
            if (// No offline filter applied
            !offlineServicesOnly && !offlineEndpointsOnly || // Only services with no active endpoint
            offlineServicesOnly && onlineEndpointsCount == 0 || // Only offline endpoints
            offlineEndpointsOnly && !offlineServicesOnly && offlineEndpointsCount > 0) {
                System.out.println();
                System.out.println(sb);
            }
        }
    } catch (ServiceLocatorException e) {
        System.err.println(e.getMessage());
    }
    System.out.println();
    return null;
}
Also used : QName(javax.xml.namespace.QName) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) SLEndpoint(org.talend.esb.servicelocator.client.SLEndpoint) ServiceLocatorTracker(org.talend.esb.locator.tracker.ServiceLocatorTracker) SLEndpoint(org.talend.esb.servicelocator.client.SLEndpoint)

Example 10 with ServiceLocatorException

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

the class RegisterOperation method execute.

@Override
public Object execute() throws Exception {
    ServiceLocatorTracker slt = ServiceLocatorTracker.getInstance(sl);
    System.out.println();
    try {
        QName serviceName = slt.getServiceName(service);
        sl.register(serviceName, endpoint, persistent);
        System.out.println("Endpoint has been registered at Service Locator");
        slt.updateServiceList();
    } catch (ServiceLocatorException e) {
        System.err.println(e.getMessage());
    }
    System.out.println();
    return null;
}
Also used : QName(javax.xml.namespace.QName) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) ServiceLocatorTracker(org.talend.esb.locator.tracker.ServiceLocatorTracker)

Aggregations

ServiceLocatorException (org.talend.esb.servicelocator.client.ServiceLocatorException)35 Test (org.junit.Test)13 QName (javax.xml.namespace.QName)11 SLEndpoint (org.talend.esb.servicelocator.client.SLEndpoint)8 WebApplicationException (javax.ws.rs.WebApplicationException)6 InterruptionFaultDetail (org.talend.schemas.esb.locator._2011._11.InterruptionFaultDetail)6 ServiceLocatorFaultDetail (org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail)6 InterruptedExceptionFault (org.talend.services.esb.locator.v1.InterruptedExceptionFault)6 ServiceLocatorFault (org.talend.services.esb.locator.v1.ServiceLocatorFault)6 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 ServiceLocatorTracker (org.talend.esb.locator.tracker.ServiceLocatorTracker)4 SLPropertiesMatcher (org.talend.esb.servicelocator.client.SLPropertiesMatcher)4 SimpleEndpoint (org.talend.esb.servicelocator.client.SimpleEndpoint)4 JAXBException (javax.xml.bind.JAXBException)3 Endpoint (org.talend.esb.servicelocator.client.Endpoint)3 DOMResult (javax.xml.transform.dom.DOMResult)2 W3CEndpointReferenceBuilder (javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder)2 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)2 BindingType (org.talend.esb.servicelocator.client.BindingType)2 SLProperties (org.talend.esb.servicelocator.client.SLProperties)2