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