Search in sources :

Example 1 with GenericOperation

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);
    }
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) SAXReader(org.dom4j.io.SAXReader) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ConfigurationException(org.osgi.service.cm.ConfigurationException) GenericOperation(org.talend.esb.job.controller.GenericOperation) ByteArrayInputStream(java.io.ByteArrayInputStream) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with GenericOperation

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();
    }
}
Also used : GenericOperation(org.talend.esb.job.controller.GenericOperation)

Example 3 with GenericOperation

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;
}
Also used : GenericOperation(org.talend.esb.job.controller.GenericOperation)

Example 4 with GenericOperation

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);
}
Also used : GenericOperation(org.talend.esb.job.controller.GenericOperation) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with GenericOperation

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);
}
Also used : GenericOperation(org.talend.esb.job.controller.GenericOperation) Test(org.junit.Test)

Aggregations

GenericOperation (org.talend.esb.job.controller.GenericOperation)5 Test (org.junit.Test)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 QName (javax.xml.namespace.QName)1 SAXReader (org.dom4j.io.SAXReader)1 Ignore (org.junit.Ignore)1 ConfigurationException (org.osgi.service.cm.ConfigurationException)1