Search in sources :

Example 1 with DelegateExpressionExecutionListener

use of org.camunda.bpm.engine.impl.bpmn.listener.DelegateExpressionExecutionListener in project camunda-bpm-platform by camunda.

the class BpmnParse method parseExecutionListener.

/**
 * Parses an {@link ExecutionListener} implementation for the given
 * executionListener element.
 *
 * @param executionListenerElement
 *          the XML element containing the executionListener definition.
 */
public ExecutionListener parseExecutionListener(Element executionListenerElement) {
    ExecutionListener executionListener = null;
    String className = executionListenerElement.attribute(PROPERTYNAME_CLASS);
    String expression = executionListenerElement.attribute(PROPERTYNAME_EXPRESSION);
    String delegateExpression = executionListenerElement.attribute(PROPERTYNAME_DELEGATE_EXPRESSION);
    Element scriptElement = executionListenerElement.elementNS(CAMUNDA_BPMN_EXTENSIONS_NS, "script");
    if (className != null) {
        executionListener = new ClassDelegateExecutionListener(className, parseFieldDeclarations(executionListenerElement));
    } else if (expression != null) {
        executionListener = new ExpressionExecutionListener(expressionManager.createExpression(expression));
    } else if (delegateExpression != null) {
        executionListener = new DelegateExpressionExecutionListener(expressionManager.createExpression(delegateExpression), parseFieldDeclarations(executionListenerElement));
    } else if (scriptElement != null) {
        try {
            ExecutableScript executableScript = parseCamundaScript(scriptElement);
            if (executableScript != null) {
                executionListener = new ScriptExecutionListener(executableScript);
            }
        } catch (BpmnParseException e) {
            addError(e);
        }
    } else {
        addError("Element 'class', 'expression', 'delegateExpression' or 'script' is mandatory on executionListener", executionListenerElement);
    }
    return executionListener;
}
Also used : ScriptExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.ScriptExecutionListener) BpmnParseException(org.camunda.bpm.engine.BpmnParseException) Element(org.camunda.bpm.engine.impl.util.xml.Element) ClassDelegateExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.ClassDelegateExecutionListener) ExecutableScript(org.camunda.bpm.engine.impl.scripting.ExecutableScript) DelegateExpressionExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.DelegateExpressionExecutionListener) ExpressionExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.ExpressionExecutionListener) DelegateExpressionExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.DelegateExpressionExecutionListener) ClassDelegateExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.ClassDelegateExecutionListener) ExecutionListener(org.camunda.bpm.engine.delegate.ExecutionListener) ScriptExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.ScriptExecutionListener) ExpressionExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.ExpressionExecutionListener) DelegateExpressionExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.DelegateExpressionExecutionListener)

Aggregations

BpmnParseException (org.camunda.bpm.engine.BpmnParseException)1 ExecutionListener (org.camunda.bpm.engine.delegate.ExecutionListener)1 ClassDelegateExecutionListener (org.camunda.bpm.engine.impl.bpmn.listener.ClassDelegateExecutionListener)1 DelegateExpressionExecutionListener (org.camunda.bpm.engine.impl.bpmn.listener.DelegateExpressionExecutionListener)1 ExpressionExecutionListener (org.camunda.bpm.engine.impl.bpmn.listener.ExpressionExecutionListener)1 ScriptExecutionListener (org.camunda.bpm.engine.impl.bpmn.listener.ScriptExecutionListener)1 ExecutableScript (org.camunda.bpm.engine.impl.scripting.ExecutableScript)1 Element (org.camunda.bpm.engine.impl.util.xml.Element)1