use of org.talend.services.esb.locator.v1.InterruptedExceptionFault 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.services.esb.locator.v1.InterruptedExceptionFault 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.services.esb.locator.v1.InterruptedExceptionFault in project tesb-rt-se by Talend.
the class LocatorSoapServiceImpl method lookupEndpoint.
/**
* For the given service return endpoint reference randomly selected from
* list of endpoints currently registered at the service locator server.
*
* @param serviceName
* the name of the service for which to get the endpoints, must
* not be <code>null</code>
* @return endpoint references or <code>null</code>
*/
W3CEndpointReference lookupEndpoint(QName serviceName, MatcherDataType matcherData) throws ServiceLocatorFault, InterruptedExceptionFault {
List<String> names = null;
String adress;
try {
initLocator();
SLPropertiesMatcher matcher = createMatcher(matcherData);
if (matcher == null) {
names = locatorClient.lookup(serviceName);
} else {
names = locatorClient.lookup(serviceName, matcher);
}
} 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 (names != null && !names.isEmpty()) {
names = getRotatedList(names);
adress = names.get(0);
} else {
if (LOG.isLoggable(Level.WARNING)) {
LOG.log(Level.WARNING, "lookup Endpoint for " + serviceName + " failed, service is not known.");
}
ServiceLocatorFaultDetail serviceFaultDetail = new ServiceLocatorFaultDetail();
serviceFaultDetail.setLocatorFaultDetail("lookup Endpoint for " + serviceName + " failed, service is not known.");
throw new ServiceLocatorFault("Can not find Endpoint", serviceFaultDetail);
}
return buildEndpoint(serviceName, adress);
}
use of org.talend.services.esb.locator.v1.InterruptedExceptionFault in project tesb-rt-se by Talend.
the class ContextListener method contextDestroyed.
/*
* This method is invoked when the Web Application has been removed and is
* no longer able to accept requests
*/
public void contextDestroyed(ServletContextEvent event) {
// Output a simple message to the server's console
System.out.println("The Simple Web App. Has Been Removed");
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/client.xml");
LocatorService client = (LocatorService) context.getBean("locatorService");
String serviceHost = this.context.getInitParameter("serviceHost");
try {
client.unregisterEndpoint(new QName("http://talend.org/esb/examples/", "GreeterService"), serviceHost);
} catch (InterruptedExceptionFault e) {
e.printStackTrace();
} catch (ServiceLocatorFault e) {
e.printStackTrace();
}
this.context = null;
}
use of org.talend.services.esb.locator.v1.InterruptedExceptionFault in project tesb-rt-se by Talend.
the class LocatorSoapServiceImpl method registerEndpoint.
/**
* Register the endpoint for given service.
*
* @param input
* RegisterEndpointRequestType encapsulate name of service and
* endpointURL. Must not be <code>null</code>
*/
@Override
public void registerEndpoint(QName serviceName, String endpointURL, org.talend.schemas.esb.locator._2011._11.BindingType binding, org.talend.schemas.esb.locator._2011._11.TransportType transport, SLPropertiesType properties) throws ServiceLocatorFault, InterruptedExceptionFault {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Registering endpoint " + endpointURL + " for service " + serviceName + "...");
}
try {
initLocator();
BindingType bindingType = binding == null ? BindingType.SOAP11 : BindingType.valueOf(binding.value());
TransportType transportType = transport == null ? TransportType.HTTP : TransportType.valueOf(transport.value());
SLPropertiesImpl slProps = null;
if (properties != null) {
slProps = new SLPropertiesImpl();
List<EntryType> entries = properties.getEntry();
for (EntryType entry : entries) {
slProps.addProperty(entry.getKey(), entry.getValue());
}
}
SimpleEndpoint eprProvider = new SimpleEndpoint(serviceName, endpointURL, bindingType, transportType, slProps);
locatorClient.register(eprProvider, true);
} 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);
}
}
Aggregations