|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
org.jscience.engineering.eventdriven.Engine
public final class Engine
This is the run-time core of the state engine system. This thread is responsible for controlling the dispatchers and data structures of the whole system. The engine can be configured to run with one of three thread schemes:
setThreadScheme() with a string parameter value of
"engine","model" or "entity" (the
string is not case-sensitive and can contain leading or trailing white
space). Passing a null value or an empty string sets the default mode.
When setting up an Engine the recommended sequence of operations is:
Engine.start());
shutdown() then
Engine.join() to wait for it to terminate.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
static java.util.Properties |
cfgProp
Configuration properties, if any. |
static int |
THREAD_PER_ENGINE
Preset value for thread-per-engine thread scheme. |
static int |
THREAD_PER_ENTITY
Preset value for thread-per-entity thread scheme. |
static int |
THREAD_PER_MODEL
Preset value for thread-per-model thread scheme. |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
Engine(java.lang.String id)
Constructor. |
|
| Method Summary | |
|---|---|
void |
addModel(Model model)
Add a model to the Engine's internal data. |
AbsEntity |
createEntity(java.lang.String modelId,
java.lang.String entityId,
java.lang.Object[] initArgs)
Creates a new Entity for a specific Model. |
void |
generateEvent(java.lang.String entityId,
java.lang.String eventSpecId)
Generate an event with no arguments for delivery to a specified entity. |
void |
generateEvent(java.lang.String entityId,
java.lang.String eventSpecId,
java.lang.Object[] args)
Generate an event for delivery to a specified entity. |
void |
run()
|
void |
setExceptionHandler(IExceptionHandler exceptionHandler)
Set the exception handler. |
void |
setStateChangeHandler(IStateChangeHandler stateChangeHandler)
Set the state change handler. |
void |
setThreadScheme(int threadSchemeValue)
Set the thread scheme. |
void |
setThreadScheme(java.lang.String threadSchemeString)
Set the thread scheme. |
void |
shutdown()
Order the Engine thread to terminate. |
void |
start()
|
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int THREAD_PER_ENGINE
public static final int THREAD_PER_MODEL
public static final int THREAD_PER_ENTITY
public static java.util.Properties cfgProp
-Djspasm.configuration=location setting).
| Constructor Detail |
|---|
public Engine(java.lang.String id)
id - The name to give to the engine.| Method Detail |
|---|
public void addModel(Model model)
throws StateModelConfigurationException
model - The model to register.
StateModelConfigurationException - if the supplied model is null
or already registered.
java.lang.IllegalStateException - DOCUMENT ME!
public AbsEntity createEntity(java.lang.String modelId,
java.lang.String entityId,
java.lang.Object[] initArgs)
throws StateProcessingException,
java.lang.InstantiationException,
java.lang.IllegalAccessException
modelId - The model to create the entity in.entityId - The unique id to give to the entity.initArgs - The initialization arguments (must match the arguments
for the Model's initial state).
StateProcessingException - if any arguments are null, the model
does not exist or the entity id already exists.
java.lang.InstantiationException - if the entity cannot be instantiated.
java.lang.IllegalAccessException - if the state method of the initialization
state cannot be executed.
java.lang.IllegalStateException - DOCUMENT ME!
public void generateEvent(java.lang.String entityId,
java.lang.String eventSpecId,
java.lang.Object[] args)
throws StateProcessingException
entityId - The target of the event.eventSpecId - The event type to be generated.args - The event arguments.
StateProcessingException - if any arguments are null, the event or
entity names do not exist, etc.
public void generateEvent(java.lang.String entityId,
java.lang.String eventSpecId)
throws StateProcessingException
entityId - The target of the event.eventSpecId - The event type to be generated.
StateProcessingException - if any arguments are null, the event or
entity names do not exist, etc.public void run()
run in interface java.lang.Runnablerun in class java.lang.Threadpublic void start()
start in class java.lang.Threadpublic void setExceptionHandler(IExceptionHandler exceptionHandler)
null.
exceptionHandler - Exception handler instance, or
null.
java.lang.IllegalStateException - DOCUMENT ME!public void setStateChangeHandler(IStateChangeHandler stateChangeHandler)
null.
stateChangeHandler - StateChangeHandler instance, or
null.
java.lang.IllegalStateException - DOCUMENT ME!
public void setThreadScheme(int threadSchemeValue)
throws java.lang.Exception
threadSchemeValue - The thread scheme value.
java.lang.Exception - if the engine is already running or the scheme value
is invalid.
java.lang.IllegalStateException - DOCUMENT ME!
public void setThreadScheme(java.lang.String threadSchemeString)
throws java.lang.Exception
threadSchemeString - The thread scheme name.
java.lang.Exception - if the engine is already running or the scheme name is
not recognized.
java.lang.IllegalStateException - DOCUMENT ME!public void shutdown()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||