public interface ModelExecutor extends BaseModelExecutor, java.lang.Runnable
For a default model executor, call the create()
method.
Model executors does not need to be thread-safe.
As a general rule, all methods of this interface will throw
NullPointerException
if a null reference is given to them as a
parameter, unless the opposite is explicitly stated in the documentation of
the methods.
See the documentation of Model
for an overview on modeling in
JtxtUML.
Modifier and Type | Interface and Description |
---|---|
static class |
ModelExecutor.Status
Represents the life cycle of a model executor.
|
Modifier and Type | Method and Description |
---|---|
ModelExecutor |
addErrorListener(ErrorListener listener)
Adds a new
ErrorListener to be called when errors are raised
during the model execution. |
ModelExecutor |
addTerminationBlocker(java.lang.Object blocker)
Adds a termination blocker to this model executor's set of blockers.
|
ModelExecutor |
addTerminationListener(java.lang.Runnable listener)
Registers the specified
Runnable to be run when the model
execution is terminated. |
ModelExecutor |
addTraceListener(TraceListener listener)
Adds a new
TraceListener to be called when certain (valid) events
happen during the model execution. |
ModelExecutor |
addWarningListener(WarningListener listener)
Adds a new
WarningListener to be called when warnings are raised
during the model execution. |
ModelExecutor |
awaitInitialization()
Awaits the model execution to finish the specified initialization and
only returns after; if the current thread is interrupted, this method
still keeps waiting.
|
ModelExecutor |
awaitInitializationNoCatch()
Awaits the model execution to finish the specified initialization and
only returns after; throws an exception if interrupted.
|
default void |
awaitTermination()
Awaits the model execution to terminate and only returns after; if the
current thread is interrupted, this method still keeps waiting.
|
void |
awaitTerminationNoCatch()
Awaits the model execution to terminate and only returns after; throws an
exception if interrupted.
|
static ModelExecutor |
create()
Creates a default model executor engine without a name.
|
static ModelExecutor |
create(java.lang.String name)
Creates a default model executor engine with the given name.
|
default CheckLevel |
getCheckLevel()
A shorthand operation for
getSettings() .
checkLevel . |
default double |
getExecutionTimeMultiplier()
The model execution time helps testing txtUML models in the following
way: when any time-related event inside the model is set to take
ms milliseconds, that event will take ms
*
mul milliseconds during model execution, where mul is the
current execution time multiplier. |
default LogLevel |
getLogLevel()
A shorthand operation for
getSettings() .
logLevel . |
java.lang.String |
getName() |
ModelScheduler |
getScheduler()
Returns the model scheduler belonging to this model executor.
|
Execution.Settings |
getSettings()
Returns the current settings of this model executor; the returned
settings object is a copy: its modification has no effect on this
executor.
|
ModelExecutor.Status |
getStatus() |
ModelExecutor |
removeErrorListener(ErrorListener listener)
Removes the given error listener.
|
ModelExecutor |
removeTerminationBlocker(java.lang.Object blocker)
Removes the specified termination blocker from this model executor's set
of blockers.
|
ModelExecutor |
removeTerminationListener(java.lang.Runnable listener)
Removes the specified
Runnable if it was previously added to the
list of actions which are performed when the model execution is
terminated. |
ModelExecutor |
removeTraceListener(TraceListener listener)
Removes the given trace listener.
|
ModelExecutor |
removeWarningListener(WarningListener listener)
Removes the given warning listener.
|
default void |
run()
Starts this model executor, calls its
shutdown() method and awaits
its termination. |
default void |
run(java.lang.Runnable initialization)
Sets the initialization of this model executor then starts it, calls its
shutdown() method and awaits its termination (optional operation). |
ModelExecutor |
set(java.util.function.Consumer<Execution.Settings> consumer)
Enables the modification of this model executor's settings.
|
ModelExecutor |
setCheckLevel(CheckLevel checkLevel)
Sets which level of dynamic checks should be performed during the model
execution.
|
ModelExecutor |
setExecutionTimeMultiplier(double newMultiplier)
The model execution time helps testing txtUML models in the following
way: when any time-related event inside the model is set to take
ms milliseconds, that event will take ms
*
mul milliseconds during model execution, where mul is the
current execution time multiplier. |
ModelExecutor |
setInitialization(java.lang.Runnable initialization)
The given initialization will run as part of the model on a model
executor thread as the first step of the model execution (optional
operation).
|
ModelExecutor |
setLogLevel(LogLevel logLevel)
Sets which level of model execution logs should be shown.
|
ModelExecutor |
shutdown()
Sets the model executor to be shut down after the currently running and
all scheduled actions have been performed, every non-external event
caused by them have been processed and all termination blockers of
this model executor have been removed.
|
ModelExecutor |
shutdownNow()
Shuts down the model executor without waiting for any currently running
or scheduled actions to perform (it does not wait for termination
blockers of this model executor to be removed either).
|
ModelExecutor |
start()
Starts a model execution with the previously specified initialization,
sets the status of this executor to
ModelExecutor.Status.ACTIVE and awaits its
initialization to complete. |
ModelExecutor |
start(java.lang.Runnable initialization)
Sets the initialization of this model executor then starts it and awaits
its initialization to complete (optional operation).
|
ModelExecutor |
startNoWait()
Starts a model execution with the previously specified initialization and
sets the status of this executor to
ModelExecutor.Status.ACTIVE . |
ModelExecutor |
startNoWait(java.lang.Runnable initialization)
Sets the initialization of this model executor then starts it and awaits
its initialization to complete (optional operation).
|
current, getFeature, getOrCreateFeature, setFeature
static ModelExecutor create()
Note: Instantiates the
DefaultModelExecutor
class.
static ModelExecutor create(java.lang.String name)
Note: Instantiates the
DefaultModelExecutor
class.
java.lang.String getName()
ModelExecutor.Status getStatus()
ModelScheduler getScheduler() throws java.lang.IllegalStateException
BaseModelExecutor
Thread-safe.
getScheduler
in interface BaseModelExecutor
java.lang.IllegalStateException
- if this executor has not been started yet and therefore has
no schedulerModelExecutor start() throws LockedModelExecutorException
ModelExecutor.Status.ACTIVE
and awaits its
initialization to complete.
Note: A shorthand operation for startNoWait()
.
awaitInitialization()
.
LockedModelExecutorException
- if the model execution has already been startedModelExecutor start(java.lang.Runnable initialization) throws LockedModelExecutorException
Supported iff setInitialization(Runnable)
is supported.
Note: A shorthand operation for
setInitialization(Runnable)
.start()
.
initialization
- the initialization to runLockedModelExecutorException
- if the model execution has already been startedModelExecutor setInitialization(java.lang.Runnable initialization) throws LockedModelExecutorException
The initialization may do any actions that are valid in the model, like creating model objects, linking, sending signals, etc.
As certain model executor implementations may initialize themselves based on some given parameters, this is an optional operation.
initialization
- the initialization to runLockedModelExecutorException
- if the model execution has already been startedModelExecutor shutdown()
shutdownNow()
.
This method does not await the termination of the executor, it returns instantly.
awaitTermination()
,
addTerminationBlocker(Object)
,
removeTerminationBlocker(Object)
ModelExecutor shutdownNow()
shutdown()
should be called instead.
This method does not await the termination of the executor, it returns instantly.
awaitTermination()
ModelExecutor awaitInitialization()
awaitInitializationNoCatch()
if this is
not the desired behavior.ModelExecutor awaitInitializationNoCatch() throws java.lang.InterruptedException
java.lang.InterruptedException
- if the current thread is interrupted while waitingawaitInitialization()
ModelExecutor startNoWait() throws LockedModelExecutorException
ModelExecutor.Status.ACTIVE
.
This method returns instantly, without waiting for the initialization or
the termination of this executor. Therefore in most cases,
start()
or run()
should be used.
LockedModelExecutorException
- if the model execution has already been startedModelExecutor startNoWait(java.lang.Runnable initialization) throws LockedModelExecutorException
Supported iff setInitialization(Runnable)
is supported.
This method returns instantly, without waiting for the initialization or
the termination of this executor. Therefore in most cases,
start(Runnable)
or run(Runnable)
should be used.
Note: A shorthand operation for
setInitialization(Runnable)
.startNoWait()
.
initialization
- the initialization to runLockedModelExecutorException
- if the model execution has already been starteddefault void awaitTermination()
awaitTerminationNoCatch()
if this is not the desired behavior.void awaitTerminationNoCatch() throws java.lang.InterruptedException
java.lang.InterruptedException
- if the current thread is interrupted while waitingawaitTermination()
default void run() throws LockedModelExecutorException
shutdown()
method and awaits
its termination.
Note: A shorthand operation for
startNoWait()
.shutdown()
.
awaitTermination()
.
run
in interface java.lang.Runnable
LockedModelExecutorException
- if the model execution has already been starteddefault void run(java.lang.Runnable initialization) throws LockedModelExecutorException
shutdown()
method and awaits its termination (optional operation).
Supported iff setInitialization(Runnable)
is supported.
Note: A shorthand operation for
setInitialization(Runnable)
.run()
.
initialization
- the initialization to runLockedModelExecutorException
- if the model execution has already been startedModelExecutor addTerminationListener(java.lang.Runnable listener)
BaseModelExecutor
Runnable
to be run when the model
execution is terminated. If the model execution is already terminated,
the listener will run instantly, before this method returns.
The listener will not necessarily run on the caller's thread.
Thread-safe.
addTerminationListener
in interface BaseModelExecutor
listener
- the action to be run when the executor is terminatedModelExecutor removeTerminationListener(java.lang.Runnable listener)
BaseModelExecutor
Runnable
if it was previously added to the
list of actions which are performed when the model execution is
terminated.
Thread-safe.
removeTerminationListener
in interface BaseModelExecutor
listener
- the action to be removedModelExecutor addTerminationBlocker(java.lang.Object blocker)
BaseModelExecutor
Thread-safe.
addTerminationBlocker
in interface BaseModelExecutor
blocker
- the blocker to be addedModelExecutor removeTerminationBlocker(java.lang.Object blocker)
BaseModelExecutor
Thread-safe.
removeTerminationBlocker
in interface BaseModelExecutor
blocker
- the blocker to be removedModelExecutor addTraceListener(TraceListener listener) throws LockedModelExecutorException
TraceListener
to be called when certain (valid) events
happen during the model execution.listener
- the listener to addLockedModelExecutorException
- if the model execution has already been startedModelExecutor addErrorListener(ErrorListener listener) throws LockedModelExecutorException
ErrorListener
to be called when errors are raised
during the model execution.listener
- the listener to addLockedModelExecutorException
- if the model execution has already been startedModelExecutor addWarningListener(WarningListener listener) throws LockedModelExecutorException
WarningListener
to be called when warnings are raised
during the model execution.listener
- the listener to addLockedModelExecutorException
- if the model execution has already been startedModelExecutor removeTraceListener(TraceListener listener) throws LockedModelExecutorException
listener
- the listener to removeLockedModelExecutorException
- if the model execution has already been startedModelExecutor removeErrorListener(ErrorListener listener) throws LockedModelExecutorException
listener
- the listener to removeLockedModelExecutorException
- if the model execution has already been startedModelExecutor removeWarningListener(WarningListener listener) throws LockedModelExecutorException
listener
- the listener to removeLockedModelExecutorException
- if the model execution has already been startedModelExecutor set(java.util.function.Consumer<Execution.Settings> consumer) throws LockedModelExecutorException
consumer
represents the current state of
this model executor's settings and therefore only those fields have to be
set which should be modified.
Note that the object received in the consumer
action will be
copied, that is, its modification after the execution of this method will
have no effect on this model executor.
consumer
- an action which modifies the settings of this model executorLockedModelExecutorException
- if the model execution has already been startedModelExecutor setLogLevel(LogLevel logLevel) throws LockedModelExecutorException
Log level is LogLevel.WARNING
by default.
logLevel
- the new log levelLockedModelExecutorException
- if the model execution has already been startedModelExecutor setCheckLevel(CheckLevel checkLevel) throws LockedModelExecutorException
Check level is CheckLevel.OPTIONAL
by default.
checkLevel
- the new check levelLockedModelExecutorException
- if the model execution has already been startedModelExecutor setExecutionTimeMultiplier(double newMultiplier) throws LockedModelExecutorException
*
mul milliseconds during model execution, where mul is the
current execution time multiplier. This way, txtUML models might be
tested at the desired speed.
Execution time multiplier is 1 by default.
newMultiplier
- the new execution time multiplierLockedModelExecutorException
- if the model execution has already been startedExecution.Settings getSettings()
Thread-safe.
default LogLevel getLogLevel()
getSettings()
.
logLevel
.default CheckLevel getCheckLevel()
getSettings()
.
checkLevel
.default double getExecutionTimeMultiplier()
*
mul milliseconds during model execution, where mul is the
current execution time multiplier. This way, txtUML models might be
tested at the desired speed.