Activity activity = execution.getActivity();
// if this is a single, non concurrent root
if (Execution.STATE_ACTIVE_ROOT.equals(execution.getState())) {
// just pass through
Transition transition = activity.getDefaultOutgoingTransition();
if (transition==null) {
throw new JbpmException("join must have an outgoing transition");
}
execution.take(transition);
} else if (Execution.STATE_ACTIVE_CONCURRENT.equals(execution.getState())) {
// force version increment in the parent execution
Session session = Environment.getFromCurrent(Session.class);
session.lock(execution.getParent(), lockMode);
execution.setState(Execution.STATE_INACTIVE_JOIN);
execution.waitForSignal();
ExecutionImpl concurrentRoot = execution.getParent();
List<ExecutionImpl> joinedExecutions = getJoinedExecutions(concurrentRoot, activity);
if (isComplete(joinedExecutions, activity)) {
endJoinedExecutions(joinedExecutions);
ExecutionImpl outgoingExecution = null;
if (concurrentRoot.getExecutions().size()==0) {
outgoingExecution = concurrentRoot;
outgoingExecution.setState(Execution.STATE_ACTIVE_ROOT);
} else {
outgoingExecution = concurrentRoot.createExecution();
outgoingExecution.setState(Execution.STATE_ACTIVE_CONCURRENT);
}
execution.setActivity(activity, outgoingExecution);
Transition transition = activity.getDefaultOutgoingTransition();
if (transition==null) {
throw new JbpmException("join must have an outgoing transition");
}
outgoingExecution.take(transition);
}