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);
}
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);
}
}
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();
}
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;
}
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;
}
Aggregations