"Could not find default leave transition: " + this);
}
}
public void leave(String type) {
JpdlConnection connection = (JpdlConnection)
getJpdlNode().getOutgoingConnection(type);
if (connection == null) {
throw new JbpmException("transition '" + type
+ "' is not a leaving transition of node '" + this + "'");
}
removeEventListeners();
fireEvent(Event.EVENTTYPE_NODE_LEAVE);
((NodeInstanceContainer) getNodeInstanceContainer()).removeNodeInstance(this);
Event event = connection.getEvent(Event.EVENTTYPE_TRANSITION);
if (event != null) {
List<Action> actions = event.getActions();
if (actions != null) {
for (Action action: actions) {
try {
action.execute(new JpdlExecutionContext());
} catch (Exception exception) {
boolean handled = false;
List<ExceptionHandler> exceptionHandlers = connection.getExceptionHandlers();
try {
for (ExceptionHandler exceptionHandler: exceptionHandlers) {
if (exceptionHandler.matches(exception)) {
exceptionHandler.handleException(null, new JpdlExecutionContext());
handled = true;
}
}
} catch (Exception e) {
exception = e;
}
if (!handled) {
if (exception instanceof JbpmException) {
throw (JbpmException) exception;
} else {
throw new DelegationException(exception, null);
}
}
}
}
}
}
String condition = connection.getCondition();
if (condition != null) {
Object result = JbpmExpressionEvaluator.evaluate(
condition, new JpdlExecutionContext());
if (result == null) {
throw new JbpmException("connection condition " + condition
+ " evaluated to null");
} else if (!(result instanceof Boolean)) {
throw new JbpmException("connection condition " + condition
+ " evaluated to non-boolean: "
+ result.getClass().getName());
} else if (!((Boolean) result).booleanValue()) {
throw new JbpmException("connection condition " + condition
+ " evaluated to 'false'");
}
}
((NodeInstanceContainer) getNodeInstanceContainer())
.getNodeInstance(connection.getTo()).trigger(this, connection.getToType());
}