use of org.camunda.bpm.engine.delegate.CaseExecutionListener in project camunda-bpm-platform by camunda.
the class ItemHandler method initializeCaseExecutionListeners.
protected void initializeCaseExecutionListeners(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
PlanItemDefinition definition = getDefinition(element);
List<CamundaCaseExecutionListener> listeners = queryExtensionElementsByClass(definition, CamundaCaseExecutionListener.class);
for (CamundaCaseExecutionListener listener : listeners) {
CaseExecutionListener caseExecutionListener = initializeCaseExecutionListener(element, activity, context, listener);
String eventName = listener.getCamundaEvent();
if (eventName != null) {
activity.addListener(eventName, caseExecutionListener);
} else {
for (String event : getStandardEvents(element)) {
activity.addListener(event, caseExecutionListener);
}
}
}
}
use of org.camunda.bpm.engine.delegate.CaseExecutionListener in project camunda-bpm-platform by camunda.
the class DelegateExpressionCaseExecutionListener method notify.
public void notify(DelegateCaseExecution caseExecution) throws Exception {
// Note: we can't cache the result of the expression, because the
// caseExecution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'
Object delegate = expression.getValue(caseExecution);
applyFieldDeclaration(fieldDeclarations, delegate);
if (delegate instanceof CaseExecutionListener) {
CaseExecutionListener listenerInstance = (CaseExecutionListener) delegate;
Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(new CaseExecutionListenerInvocation(listenerInstance, caseExecution));
} else {
throw new ProcessEngineException("Delegate expression " + expression + " did not resolve to an implementation of " + CaseExecutionListener.class);
}
}
use of org.camunda.bpm.engine.delegate.CaseExecutionListener in project camunda-bpm-platform by camunda.
the class ClassDelegateCaseExecutionListener method notify.
public void notify(DelegateCaseExecution caseExecution) throws Exception {
CaseExecutionListener listenerInstance = getListenerInstance();
Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(new CaseExecutionListenerInvocation(listenerInstance, caseExecution));
}
use of org.camunda.bpm.engine.delegate.CaseExecutionListener in project camunda-bpm-platform by camunda.
the class ItemHandler method initializeCaseExecutionListener.
protected CaseExecutionListener initializeCaseExecutionListener(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CamundaCaseExecutionListener listener) {
Collection<CamundaField> fields = listener.getCamundaFields();
List<FieldDeclaration> fieldDeclarations = initializeFieldDeclarations(element, activity, context, fields);
ExpressionManager expressionManager = context.getExpressionManager();
CaseExecutionListener caseExecutionListener = null;
String className = listener.getCamundaClass();
String expression = listener.getCamundaExpression();
String delegateExpression = listener.getCamundaDelegateExpression();
CamundaScript scriptElement = listener.getCamundaScript();
if (className != null) {
caseExecutionListener = new ClassDelegateCaseExecutionListener(className, fieldDeclarations);
} else if (expression != null) {
Expression expressionExp = expressionManager.createExpression(expression);
caseExecutionListener = new ExpressionCaseExecutionListener(expressionExp);
} else if (delegateExpression != null) {
Expression delegateExp = expressionManager.createExpression(delegateExpression);
caseExecutionListener = new DelegateExpressionCaseExecutionListener(delegateExp, fieldDeclarations);
} else if (scriptElement != null) {
ExecutableScript executableScript = initializeScript(element, activity, context, scriptElement);
if (executableScript != null) {
caseExecutionListener = new ScriptCaseExecutionListener(executableScript);
}
}
return caseExecutionListener;
}
Aggregations