} catch (Exception e) {
e.printStackTrace();
Throwable t = (e instanceof SquirrelRuntimeException) ?
((SquirrelRuntimeException)e).getTargetException() : e;
// wrap any exception into transition exception
TransitionException te = new TransitionException(t, ErrorCodes.FSM_TRANSITION_ERROR,
new Object[]{actionContext.from, actionContext.to, actionContext.event,
actionContext.context, actionContext.action.name(), e.getMessage()});
fireEvent(new ExecActionExceptionEventImpl<T, S, E, C>(te, i+1, actionSize, actionContext));
throw te;
} finally {
fireEvent(AfterExecActionEventImpl.get(i+1, actionSize, actionContext));
}
} else {
logger.info("Method call action \""+actionContext.action.name()+"\" ("+(i+1)+" of "+actionSize+") was ignored.");
}
}
for(Entry<ActionContext<T, S, E, C>, Future<?>> entry : futures.entrySet()) {
final Future<?> future = entry.getValue();
final ActionContext<T, S, E, C> actionContext = entry.getKey();
try {
logger.debug("Waiting action \'"+actionContext.action.toString()+"\' to finish.");
if(actionContext.action.timeout()>=0) {
future.get(actionContext.action.timeout(), TimeUnit.MILLISECONDS);
} else {
future.get();
}
logger.debug("Action \'"+actionContext.action.toString()+"\' finished.");
} catch (Exception e) {
future.cancel(true);
Throwable t = e;
if(e instanceof ExecutionException) {
t = ((ExecutionException)e).getCause();
}
TransitionException te = new TransitionException(t, ErrorCodes.FSM_TRANSITION_ERROR,
new Object[]{actionContext.from, actionContext.to, actionContext.event,
actionContext.context, actionContext.action.name(), e.getMessage()});
fireEvent(new ExecActionExceptionEventImpl<T, S, E, C>(te,
actionContext.position, actionTotalSize, actionContext));
throw te;