use of org.talend.esb.job.controller.GenericOperation in project tesb-rt-se by Talend.
the class GenericServiceProviderImpl method invoke.
// @javax.jws.WebMethod(exclude=true)
public final Source invoke(Source request) {
QName operationQName = (QName) context.getMessageContext().get(MessageContext.WSDL_OPERATION);
LOG.info("Invoke operation '" + operationQName + "'");
GenericOperation esbProviderCallback = getESBProviderCallback(operationQName.getLocalPart());
if (esbProviderCallback == null) {
throw new RuntimeException("Handler for operation " + operationQName + " cannot be found");
}
try {
ByteArrayOutputStream os = new java.io.ByteArrayOutputStream();
StaxUtils.copy(request, os);
org.dom4j.Document requestDoc = new SAXReader().read(new ByteArrayInputStream(os.toByteArray()));
Object payload;
if (extractHeaders) {
Map<String, Object> esbRequest = new HashMap<String, Object>();
esbRequest.put(ESBProviderCallback.HEADERS_SOAP, context.getMessageContext().get(Header.HEADER_LIST));
esbRequest.put(ESBProviderCallback.HEADERS_HTTP, context.getMessageContext().get(MessageContext.HTTP_REQUEST_HEADERS));
esbRequest.put(ESBProviderCallback.REQUEST, requestDoc);
esbRequest.put(CorrelationIDFeature.MESSAGE_CORRELATION_ID, context.getMessageContext().get(CorrelationIDFeature.MESSAGE_CORRELATION_ID));
payload = esbRequest;
} else {
payload = requestDoc;
}
LOG.fine("Generic provider invoked with payload: " + payload);
Object result = esbProviderCallback.invoke(payload, isOperationRequestResponse(operationQName.getLocalPart()));
// oneway
if (result == null) {
return null;
}
LOG.fine("Generic provider callback returns: " + result);
if (result instanceof Map<?, ?>) {
Map<String, Object> map = CastUtils.cast((Map<?, ?>) result);
return processResult(map.get(ESBEndpointConstants.REQUEST_PAYLOAD));
} else {
return processResult(result);
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.talend.esb.job.controller.GenericOperation in project tesb-rt-se by Talend.
the class JobLauncherImpl method esbJobFactoryRemoved.
@Override
public void esbJobFactoryRemoved(TalendESBJobFactory esbJobFactory, String name) {
LOG.info("Removing ESB job factory for job " + name + ".");
GenericOperation task = operations.remove(name);
if (task != null) {
task.stop();
}
}
use of org.talend.esb.job.controller.GenericOperation in project tesb-rt-se by Talend.
the class JobLauncherImpl method retrieveOperation.
@Override
public synchronized GenericOperation retrieveOperation(String jobName, String[] args) {
GenericOperation task = operations.get(jobName);
if (task == null) {
throw new IllegalArgumentException("Talend ESB job with name " + jobName + "' not found");
}
task.start(args);
return task;
}
use of org.talend.esb.job.controller.GenericOperation in project tesb-rt-se by Talend.
the class JobLauncherRetrieveOperationTest method retrieveSecondTimeOperationReturnsSame.
@Test
@Ignore
public void retrieveSecondTimeOperationReturnsSame() throws Exception {
GenericOperation operation1 = jobLauncher.retrieveOperation(JOB_NAME_1, EMPTY_STRING_ARR);
GenericOperation operation2 = jobLauncher.retrieveOperation(JOB_NAME_1, EMPTY_STRING_ARR);
assertSame(operation1, operation2);
}
use of org.talend.esb.job.controller.GenericOperation in project tesb-rt-se by Talend.
the class JobLauncherRetrieveOperationTest method retrieveNewOperation.
@Test
public void retrieveNewOperation() throws Exception {
GenericOperation operation = jobLauncher.retrieveOperation(JOB_NAME_1, new String[0]);
assertNotNull(operation);
}
Aggregations