public void execute(ExecutionImpl execution) {
Activity activity = execution.getActivity();
String transitionName = null;
DecisionHandler usedDecisionHandler = null;
if (decisionHandler!=null) {
usedDecisionHandler = decisionHandler;
} else if (decisionHandlerName!=null) {
Environment environment = Environment.getCurrent();
Object object = environment.get(decisionHandlerName);
if (object==null) {
throw new JbpmException("decision handler for "+activity+" is null");
}
if (! (object instanceof DecisionHandler)) {
throw new JbpmException("handler for decision is not a "+DecisionHandler.class.getName()+": "+object.getClass().getName());
}
usedDecisionHandler = (DecisionHandler) object;
} else {
throw new JbpmException("no decision handler specified");
}
transitionName = usedDecisionHandler.decide(execution);
Transition transition = activity.getOutgoingTransition(transitionName);
if (transition==null) {
throw new JbpmException("handler in decision '"+activity.getName()+"' returned unexisting outgoing transition name: "+transitionName);
}