|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.scxml.env.AbstractStateMachine
This class demonstrates one approach for providing the base
functionality needed by classes representing stateful entities,
whose behaviors are defined via SCXML documents.
SCXML documents (more generically, UML state chart diagrams) can be
used to define stateful behavior of objects, and Commons SCXML enables
developers to use this model directly into the corresponding code
artifacts. The resulting artifacts tend to be much simpler, embody
a useful separation of concerns and are easier to understand and
maintain. As the size of the modeled entity grows, these benefits
become more apparent.
This approach functions by registering an SCXMLListener that gets
notified onentry, and calls the namesake method for each state that
has been entered.
This class swallows all exceptions only to log them. Developers of
subclasses should think of themselves as "component developers"
catering to other end users, and therefore ensure that the subclasses
are free of ModelException
s and the like. Most methods
are protected
for ease of subclassing.
Nested Class Summary | |
protected class |
AbstractStateMachine.EntryListener
A SCXMLListener that is only concerned about "onentry" notifications. |
Constructor Summary | |
AbstractStateMachine(URL scxmlDocument)
Convenience constructor. |
|
AbstractStateMachine(URL scxmlDocument,
Context rootCtx,
Evaluator evaluator)
Primary constructor. |
Method Summary | |
boolean |
fireEvent(String event)
Fire an event on the SCXML engine. |
SCXMLExecutor |
getEngine()
Get the SCXML engine driving the "lifecycle" of the instances of this class. |
org.apache.commons.logging.Log |
getLog()
Get the log for this class. |
static SCXML |
getStateMachine()
Get the SCXML object representing this state machine. |
boolean |
invoke(String methodName)
Invoke the no argument method with the following name. |
protected void |
logError(Exception exception)
Utility method for logging error. |
boolean |
resetMachine()
Reset the state machine. |
void |
setLog(org.apache.commons.logging.Log log)
Set the log for this class. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public AbstractStateMachine(URL scxmlDocument)
scxmlDocument
- The URL pointing to the SCXML document that
describes the "lifecycle" of the
instances of this class.public AbstractStateMachine(URL scxmlDocument, Context rootCtx, Evaluator evaluator)
scxmlDocument
- The URL pointing to the SCXML document that
describes the "lifecycle" of the
instances of this class.rootCtx
- The root context for this instance.evaluator
- The expression evaluator for this instance.Context
,
Evaluator
Method Detail |
public boolean fireEvent(String event)
event
- The event name.
public static SCXML getStateMachine()
public SCXMLExecutor getEngine()
public org.apache.commons.logging.Log getLog()
public void setLog(org.apache.commons.logging.Log log)
log
- The log to set.public boolean invoke(String methodName)
methodName
- The method to invoke.
public boolean resetMachine()
protected void logError(Exception exception)
exception
- The exception leading to this error condition.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |