decisionHandler = (DecisionHandler) decisionDelegation.instantiate();
String transitionName = decisionHandler.decide(executionContext);
transition = getLeavingTransition(transitionName);
if (transition == null) {
throw new JbpmException("decision '"
+ name
+ "' selected non existing transition '"
+ transitionName
+ "'");
}
}
else if (decisionExpression != null) {
Object result = JbpmExpressionEvaluator.evaluate(decisionExpression, executionContext);
if (result == null) {
throw new JbpmException("decision expression '" + decisionExpression + "' returned null");
}
String transitionName = result.toString();
transition = getLeavingTransition(transitionName);
if (transition == null) {
throw new JbpmException("decision '"
+ name
+ "' selected non existing transition '"
+ transitionName
+ "'");
}
}
else if (decisionConditions != null && !decisionConditions.isEmpty()) {
// backwards compatible mode based on separate DecisionCondition's
for (DecisionCondition decisionCondition : decisionConditions) {
Object result = JbpmExpressionEvaluator.evaluate(decisionCondition.getExpression(),
executionContext);
if (Boolean.TRUE.equals(result)) {
String transitionName = decisionCondition.getTransitionName();
transition = getLeavingTransition(transitionName);
if (transition != null) break;
}
}
}
else {
// new mode based on conditions in the transition itself
for (Transition candidate : leavingTransitions) {
String conditionExpression = candidate.getCondition();
if (conditionExpression != null) {
Object result = JbpmExpressionEvaluator.evaluate(conditionExpression, executionContext);
if (Boolean.TRUE.equals(result)) {
transition = candidate;
break;
}
}
}
}
}
catch (Exception exception) {
raiseException(exception, executionContext);
if (!equals(executionContext.getNode())) {
return;
}
}
finally {
currentThread.setContextClassLoader(contextClassLoader);
}
if (transition == null) {
transition = getDefaultLeavingTransition();
if (transition == null)
throw new JbpmException("decision cannot select transition: " + this);
log.debug("decision did not select transition, taking default " + transition);
}
// since the decision node evaluates condition expressions, the condition of the