use of org.talend.esb.servicelocator.client.internal.endpoint.EndpointDataType in project tesb-rt-se by Talend.
the class EndpointTransformerImpl method createEndpointData.
private EndpointDataType createEndpointData(Endpoint eprProvider, long lastTimeStarted, long lastTimeStopped) throws ServiceLocatorException {
EndpointDataType endpointData = ENDPOINT_OBJECT_FACTORY.createEndpointDataType();
endpointData.setBinding(BindingType.fromValue(eprProvider.getBinding().getValue()));
endpointData.setTransport(TransportType.fromValue(eprProvider.getTransport().getValue()));
endpointData.setLastTimeStarted(lastTimeStarted);
endpointData.setLastTimeStopped(lastTimeStopped);
DOMResult result = new DOMResult();
eprProvider.writeEndpointReferenceTo(result, this);
Document doc = (Document) result.getNode();
endpointData.setEndpointReference(doc.getDocumentElement());
return endpointData;
}
use of org.talend.esb.servicelocator.client.internal.endpoint.EndpointDataType in project tesb-rt-se by Talend.
the class EndpointTransformerImpl method toEndPointData.
@SuppressWarnings("unchecked")
public static EndpointDataType toEndPointData(byte[] content) {
if (content == null) {
throw new IllegalArgumentException("content must not be null.");
}
final InputStream is = new ByteArrayInputStream(content);
try {
JAXBContext jc = JaxbContextHandler.getEndpointContext();
JAXBElement<EndpointDataType> slEndpoint = (JAXBElement<EndpointDataType>) jc.createUnmarshaller().unmarshal(is);
return slEndpoint.getValue();
} catch (JAXBException e) {
if (LOG.isLoggable(Level.SEVERE)) {
LOG.log(Level.SEVERE, "Failed to deserialize endpoint data", e);
}
EndpointDataType endpointData = ENDPOINT_OBJECT_FACTORY.createEndpointDataType();
endpointData.setLastTimeStarted(-1);
endpointData.setLastTimeStopped(-1);
return endpointData;
}
}
use of org.talend.esb.servicelocator.client.internal.endpoint.EndpointDataType in project tesb-rt-se by Talend.
the class EndpointTransformerImpl method serialize.
private byte[] serialize(EndpointDataType endpointData) throws ServiceLocatorException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(50000);
try {
JAXBElement<EndpointDataType> epd = ENDPOINT_OBJECT_FACTORY.createEndpointData(endpointData);
createMarshaller().marshal(epd, outputStream);
} catch (JAXBException e) {
if (LOG.isLoggable(Level.SEVERE)) {
LOG.log(Level.SEVERE, "Failed to serialize endpoint data", e);
}
throw new ServiceLocatorException("Failed to serialize endpoint data", e);
}
return outputStream.toByteArray();
}
Aggregations