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>();
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 (transitionsToTake.size() > 0) {
execution.takeAll(transitionsToTake, joinedExecutions);
} else {
if (defaultSequenceFlow != null) {
PvmTransition defaultTransition = execution.getActivity().findOutgoingTransition(defaultSequenceFlow);
if (defaultTransition != null) {
execution.take(defaultTransition);
} else {
throw new ProcessEngineException("Default sequence flow '" + defaultSequenceFlow + "' could not be not found");
}
} 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");
}
}
} else {
if (log.isLoggable(Level.FINE)) {
log.fine("Inclusive gateway '" + activity.getId() + "' does not activate");
}
}
}