Package org.mule.module.bpm

Examples of org.mule.module.bpm.MessageService


        perform(execution);
    }

    public void perform(OpenExecution execution) throws Exception
    {
        MessageService mule = EnvironmentImpl.getCurrent().get(MuleMessageService.class);
        if (mule == null)
        {
            throw new JbpmException("The Mule MessageService is not available from the ProcessEngine, you may need to add it to your jbpm.cfg.xml file");
        }

        if (payloadExpression == null)
        {
            payloadObject = execution.getVariable(Process.PROCESS_VARIABLE_DATA);
            if (payloadObject == null)
            {
                payloadObject = execution.getVariable(Process.PROCESS_VARIABLE_INCOMING);
            }
        }
        else
        {
            // The payloadSource may be specified using an expression (e.g.,
            // #{myObject.myStuff.myField} would first retrieve the process
            // variable "myObject" and then call .getMyStuff().getMyField()
            payloadObject = ScriptManager.getScriptManager().evaluateExpression(payloadExpression, null);
        }
        if (payloadObject == null)
        {
            throw new IllegalArgumentException("Payload for message is null.  Payload source is \""
                                               + payloadExpression + "\"");
        }

        Map props = new HashMap();

        props.put(Process.PROPERTY_PROCESS_TYPE, ((ExecutionImpl) execution).getProcessDefinition().getName());
        props.put(Process.PROPERTY_PROCESS_ID, execution.getId());
        String state = Jbpm.getState(execution.getProcessInstance());
        props.put("MULE_BPM_PROCESS_STATE", state);
        log.debug("process state: " + state);       

        // Set process vars as properties on outgoing Mule messages.
        for (Entry<String, ?> var : execution.getVariables().entrySet())
        {
            if (!var.getKey().startsWith(MuleProperties.PROPERTY_PREFIX))
            {
                log.debug("process var: " + var.getKey() + " = " + var.getValue());
                props.put(var.getKey(), var.getValue());
            }
        }

        // Just in case the endpoint itself is an expression
        endpoint = (String) ScriptManager.getScriptManager().evaluateExpression(endpoint, null);
        MuleMessage response = mule.generateMessage(endpoint, payloadObject, props, mep);

        if (mep.hasResponse() && response != null)
        {
            Object responsePayload = response.getPayload();
   
View Full Code Here


        perform(execution);
    }

    public void perform(OpenExecution execution) throws Exception
    {
        MessageService mule = EnvironmentImpl.getCurrent().get(MuleMessageService.class);
        if (mule == null)
        {
            throw new JbpmException("The Mule MessageService is not available from the ProcessEngine, you may need to add it to your jbpm.cfg.xml file");
        }

        Object payloadObject = null;
        if (payloadExpression == null)
        {
            payloadObject = execution.getVariable(Process.PROCESS_VARIABLE_DATA);
            if (payloadObject == null)
            {
                payloadObject = execution.getVariable(Process.PROCESS_VARIABLE_INCOMING);
            }
        }
        else
        {
            // The payloadSource may be specified using an expression (e.g.,
            // #{myObject.myStuff.myField} would first retrieve the process
            // variable "myObject" and then call .getMyStuff().getMyField()
            payloadObject = ScriptManager.getScriptManager().evaluateExpression(payloadExpression, null);
        }
        if (payloadObject == null)
        {
            throw new IllegalArgumentException("Payload for message is null.  Payload source is \""
                                               + payloadExpression + "\"");
        }

        Map props = new HashMap();

        props.put(Process.PROPERTY_PROCESS_TYPE, ((ExecutionImpl) execution).getProcessDefinition().getName());
        props.put(Process.PROPERTY_PROCESS_ID, execution.getId());
        String state = Jbpm.getState(execution.getProcessInstance());
        props.put("MULE_BPM_PROCESS_STATE", state);
        log.debug("process state: " + state);       

        // Set process vars as properties on outgoing Mule messages.
        for (Entry<String, ?> var : execution.getVariables().entrySet())
        {
            if (!var.getKey().startsWith(MuleProperties.PROPERTY_PREFIX))
            {
                log.debug("process var: " + var.getKey() + " = " + var.getValue());
                props.put(var.getKey(), var.getValue());
            }
        }

        // Just in case the endpoint itself is an expression
        endpoint = (String) ScriptManager.getScriptManager().evaluateExpression(endpoint, null);
        MuleMessage response = mule.generateMessage(endpoint, payloadObject, props, mep);

        if (mep.hasResponse() && response != null)
        {
            Object responsePayload = response.getPayload();
   
View Full Code Here

TOP

Related Classes of org.mule.module.bpm.MessageService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.