List of usage examples for org.apache.commons.scxml.semantics ErrorConstants UNKNOWN_ACTION
String UNKNOWN_ACTION
To view the source code for org.apache.commons.scxml.semantics ErrorConstants UNKNOWN_ACTION.
Click Source Link
From source file:com.headstrong.fusion.statemachine.StateMachineErrorReporter.java
/** * @see ErrorReporter#onError(String, String, Object) *//*from ww w. j av a2s . c o m*/ public void onError(final String errorCode, final String errDetail, final Object errCtx) { // Note: the if-then-else below is based on the actual usage // (codebase search), it has to be kept up-to-date as the code changes String errCode = errorCode.intern(); StringBuffer msg = new StringBuffer(); msg.append(errCode).append(" ("); msg.append(errDetail).append("): "); if (errCode == ErrorConstants.NO_INITIAL) { if (errCtx instanceof SCXML) { // determineInitialStates msg.append("<SCXML>"); } else if (errCtx instanceof State) { // determineInitialStates // determineTargetStates msg.append("State ").append(LogUtils.getTTPath((State) errCtx)); } } else if (errCode == ErrorConstants.UNKNOWN_ACTION) { // executeActionList msg.append("Action: ").append(errCtx.getClass().getName()); } else if (errCode == ErrorConstants.ILLEGAL_CONFIG) { // isLegalConfig if (errCtx instanceof Map.Entry) { TransitionTarget tt = (TransitionTarget) (((Map.Entry) errCtx).getKey()); Set vals = (Set) (((Map.Entry) errCtx).getValue()); msg.append(LogUtils.getTTPath(tt)).append(" : ["); for (Iterator i = vals.iterator(); i.hasNext();) { TransitionTarget tx = (TransitionTarget) i.next(); msg.append(LogUtils.getTTPath(tx)); if (i.hasNext()) { msg.append(", "); } } msg.append(']'); } else if (errCtx instanceof Set) { Set vals = (Set) errCtx; msg.append("<SCXML> : ["); for (Iterator i = vals.iterator(); i.hasNext();) { TransitionTarget tx = (TransitionTarget) i.next(); msg.append(LogUtils.getTTPath(tx)); if (i.hasNext()) { msg.append(", "); } } msg.append(']'); } } if (logger.isWarnEnabled()) { logger.warn(msg.toString()); } }
From source file:de.dfki.iui.mmds.dialogue.SiamErrorReporter.java
/** * @see ErrorReporter#onError(String, String, Object) */// ww w .ja v a 2 s . c o m @Override @SuppressWarnings("unchecked") public void onError(final String errorCode, final String errDetail, final Object errCtx) { // Note: the if-then-else below is based on the actual usage // (codebase search), it has to be kept up-to-date as the code changes String errCode = errorCode.intern(); StringBuffer msg = new StringBuffer(); msg.append(errCode).append(" ("); msg.append(errDetail).append("): "); if (errCode == ErrorConstants.NO_INITIAL) { if (errCtx instanceof SCXML) { // determineInitialStates msg.append("<SCXML>"); } else if (errCtx instanceof State) { // determineInitialStates // determineTargetStates msg.append("State " + LogUtils.getTTPath((State) errCtx)); } } else if (errCode == ErrorConstants.UNKNOWN_ACTION) { // executeActionList msg.append("Action: " + errCtx.getClass().getName()); } else if (errCode == ErrorConstants.ILLEGAL_CONFIG) // isLegalConfig if (errCtx instanceof Map.Entry) { // unchecked cast below Map.Entry<TransitionTarget, Set<TransitionTarget>> badConfigMap = (Map.Entry<TransitionTarget, Set<TransitionTarget>>) errCtx; TransitionTarget tt = badConfigMap.getKey(); Set<TransitionTarget> vals = badConfigMap.getValue(); msg.append(LogUtils.getTTPath(tt) + " : ["); for (Iterator<TransitionTarget> i = vals.iterator(); i.hasNext();) { TransitionTarget tx = i.next(); msg.append(LogUtils.getTTPath(tx)); if (i.hasNext()) { msg.append(", "); } } msg.append(']'); } else if (errCtx instanceof Set) { // unchecked cast below Set<TransitionTarget> vals = (Set<TransitionTarget>) errCtx; msg.append("<SCXML> : ["); for (Iterator<TransitionTarget> i = vals.iterator(); i.hasNext();) { TransitionTarget tx = i.next(); msg.append(LogUtils.getTTPath(tx)); if (i.hasNext()) { msg.append(", "); } } msg.append(']'); } if (log.isWarnEnabled()) { log.warn(msg.toString()); } }
From source file:alma.acs.nc.sm.generic.AcsScxmlActionDispatcher.java
/** * Generic action handler, dispatches to the right handler based on action type. * <p>/*from ww w . ja v a2 s. c o m*/ * TODO: org.apache.commons.scxml.env.SimpleErrorReporter#onError prints the class name of the "Object errCtx". * Currently we'd get NPE or useless info. */ public void execute(A action, final EventDispatcher evtDispatcher, final ErrorReporter errRep, final SCInstance scInstance, final Collection<TriggerEvent> derivedEvents) throws ModelException, SCXMLExpressionException { AcsScxmlActionExecutor<A> handler = getActionHandler(action); if (handler != null) { boolean handledAction = false; try { handledAction = handler.execute(action, evtDispatcher, errRep, scInstance, derivedEvents); } catch (AcsJStateMachineActionEx ex) { handledAction = true; if (actionExceptionHandler != null) { // handler is optional // ex will be thrown at the user actionExceptionHandler.setActionException(ex); } else { logger.log(Level.WARNING, "Handler " + handler.getClass() + " failed to execute action " + action.name(), ex); } // TODO: define and fire a standardized internal error event so that the state machine // can reflect the problem and can be maneuvered out of the error again by the user } if (!handledAction) { errRep.onError(ErrorConstants.UNKNOWN_ACTION, "Handler " + handler.getClass() + " handler unexpectedly did not handle action ", action); } } else { errRep.onError(ErrorConstants.UNKNOWN_ACTION, "No handler registered for action " + action.name(), null); } }