A - The SM action enumeration.public class AcsScxmlActionDispatcher<A extends java.lang.Enum<A>>
extends java.lang.Object
AcsScxmlDispatchingAction,
thus bringing action handlers under user control
instead of using directly the handler instantiated by the SCXML framework.
Handlers must be registered using registerActionHandler(Enum, AcsScxmlActionExecutor).
| Modifier and Type | Class and Description |
|---|---|
static interface |
AcsScxmlActionDispatcher.ActionExceptionHandler |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CUSTOM_ACTIONS_DOMAIN_NAME |
protected java.util.logging.Logger |
logger |
| Constructor and Description |
|---|
AcsScxmlActionDispatcher(java.util.logging.Logger logger,
java.lang.Class<A> actionType) |
| Modifier and Type | Method and Description |
|---|---|
void |
execute(A action,
EventDispatcher evtDispatcher,
ErrorReporter errRep,
SCInstance scInstance,
java.util.Collection<TriggerEvent> derivedEvents)
Generic action handler, dispatches to the right handler based on action type.
|
AcsScxmlActionExecutor<A> |
getActionHandler(A action)
An alternative to
execute(Enum, EventDispatcher, ErrorReporter, SCInstance, Collection)
where the handler can be accessed and stored directly. |
java.lang.Class<A> |
getActionType()
Used by an
AcsScxmlDispatchingAction object to convert its action name to the corresponding enum value. |
protected java.util.List<CustomAction> |
getScxmlActionMap()
Wraps the registered action handlers in a form suitable for the SCXML framework.
|
boolean |
isActionMappingComplete()
Checks whether all action enums have an action handler registered.
|
void |
registerActionHandler(A action,
AcsScxmlActionExecutor<A> handler)
Registers an action handler for the given SM action.
|
void |
setActionExceptionHandler(AcsScxmlActionDispatcher.ActionExceptionHandler handler) |
public static final java.lang.String CUSTOM_ACTIONS_DOMAIN_NAME
protected final java.util.logging.Logger logger
public AcsScxmlActionDispatcher(java.util.logging.Logger logger,
java.lang.Class<A> actionType)
public void execute(A action, EventDispatcher evtDispatcher, ErrorReporter errRep, SCInstance scInstance, java.util.Collection<TriggerEvent> derivedEvents) throws ModelException, SCXMLExpressionException
TODO: org.apache.commons.scxml.env.SimpleErrorReporter#onError prints the class name of the "Object errCtx". Currently we'd get NPE or useless info.
ModelExceptionSCXMLExpressionExceptionpublic AcsScxmlActionExecutor<A> getActionHandler(A action)
execute(Enum, EventDispatcher, ErrorReporter, SCInstance, Collection)
where the handler can be accessed and stored directly.
Using this approach may bring a tiny performance advantage, but probably should be removed again..public void registerActionHandler(A action, AcsScxmlActionExecutor<A> handler)
action - handler - public boolean isActionMappingComplete()
This method can be used to validate early at runtime that no action goes without handler, which might happen after a change in the SM model.
Note that this kind of completeness check could also be done at build time using an action enum with visitor pattern, see http://raginggoblin.wordpress.com/2010/06/10/switch-over-all-values-of-a-java-enum/. However, this would require us to dispatch all actions through a single interface that has a typed method per action and whose implementation could then of course dispatch further to various objects. For the time being we stay with the looser coupling of registering various action handler objects and validating them for completeness early at runtime (not waiting until some rare action finally occurs).
public java.lang.Class<A> getActionType()
AcsScxmlDispatchingAction object to convert its action name to the corresponding enum value.
(This type information cannot be passed directly because Apache SCXML creates the action with an empty constructor.)protected java.util.List<CustomAction> getScxmlActionMap()
execute(Enum, EventDispatcher, ErrorReporter, SCInstance, Collection).public void setActionExceptionHandler(AcsScxmlActionDispatcher.ActionExceptionHandler handler)