public void execute(ActivityExecution execution) throws Exception {
execution.inactivate();
lockConcurrentRoot(execution);
PvmActivity activity = execution.getActivity();
if (!activeConcurrentExecutionsExist(execution)) {
if (log.isLoggable(Level.FINE)) {
log.fine("inclusive gateway '" + activity.getId() + "' activates");
}
List<ActivityExecution> joinedExecutions = execution.findInactiveConcurrentExecutions(activity);
String defaultSequenceFlow = (String) execution.getActivity().getProperty("default");
List<PvmTransition> transitionsToTake = new ArrayList<PvmTransition>();
// find matching non-default sequence flows
for (PvmTransition outgoingTransition : execution.getActivity().getOutgoingTransitions()) {
if (defaultSequenceFlow == null || !outgoingTransition.getId().equals(defaultSequenceFlow)) {
Condition condition = (Condition) outgoingTransition.getProperty(BpmnParse.PROPERTYNAME_CONDITION);
if (condition == null || condition.evaluate(execution)) {
transitionsToTake.add(outgoingTransition);
}
}
}
// if none found, add default flow
if (transitionsToTake.isEmpty()) {
if (defaultSequenceFlow != null) {
PvmTransition defaultTransition = execution.getActivity().findOutgoingTransition(defaultSequenceFlow);
if (defaultTransition == null) {
throw new ProcessEngineException("Default sequence flow '" + defaultSequenceFlow + "' could not be not found");
}
transitionsToTake.add(defaultTransition);
} else {
// No sequence flow could be found, not even a default one
throw new ProcessEngineException("No outgoing sequence flow of the inclusive gateway '" + execution.getActivity().getId()
+ "' could be selected for continuing the process");
}
}
// take the flows found
execution.takeAll(transitionsToTake, joinedExecutions);
} else {
if (log.isLoggable(Level.FINE)) {
log.fine("Inclusive gateway '" + activity.getId() + "' does not activate");
}
}
}