S
- a subtype of this interface which will be returned by the
chainable methodspublic interface CastedModelExecutor<S extends CastedModelExecutor<S>> extends ModelExecutor
ModelExecutor
s which can
still be subtyped.
This overrides all the ModelExecutor
interface's chainable methods to
have a return type of S
(a parameter of this interface). Therefore a
specialized model executor interface does not have to override these methods
again to ensure that the user may chain over the specialized type instead of
the base (ModelExecutor
).
This interface also helps in case of abstract implementor classes. If the
abstract class has a type parameter S
and extends
CastedModelExecutor<S>
, then in the implementation of these chainable
methods, it may return the value of self()
. This way only the
self()
method has to be implemented in a concrete subclass to support
method chaining.
See the documentation of Model
for an overview on modeling in
JtxtUML.
ModelExecutor.Status
Modifier and Type | Method and Description |
---|---|
S |
addErrorListener(ErrorListener listener)
Adds a new
ErrorListener to be called when errors are raised
during the model execution. |
S |
addTerminationBlocker(java.lang.Object blocker)
Adds a termination blocker to this model executor's set of blockers.
|
S |
addTerminationListener(java.lang.Runnable listener)
Registers the specified
Runnable to be run when the model
execution is terminated. |
S |
addTraceListener(TraceListener listener)
Adds a new
TraceListener to be called when certain (valid) events
happen during the model execution. |
S |
addWarningListener(WarningListener listener)
Adds a new
WarningListener to be called when warnings are raised
during the model execution. |
default S |
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.
|
S |
awaitInitializationNoCatch()
Awaits the model execution to finish the specified initialization and
only returns after; throws an exception if interrupted.
|
S |
removeErrorListener(ErrorListener listener)
Removes the given error listener.
|
S |
removeTerminationBlocker(java.lang.Object blocker)
Removes the specified termination blocker from this model executor's set
of blockers.
|
S |
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. |
S |
removeTraceListener(TraceListener listener)
Removes the given trace listener.
|
S |
removeWarningListener(WarningListener listener)
Removes the given warning listener.
|
S |
self() |
S |
setCheckLevel(CheckLevel checkLevel)
Sets which level of dynamic checks should be performed during the model
execution.
|
S |
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. |
S |
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).
|
S |
setLogLevel(LogLevel logLevel)
Sets which level of model execution logs should be shown.
|
S |
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.
|
S |
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).
|
default S |
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. |
default S |
start(java.lang.Runnable initialization)
Sets the initialization of this model executor then starts it and awaits
its initialization to complete (optional operation).
|
S |
startNoWait()
Starts a model execution with the previously specified initialization and
sets the status of this executor to
ModelExecutor.Status.ACTIVE . |
default S |
startNoWait(java.lang.Runnable initialization)
Sets the initialization of this model executor then starts it and awaits
its initialization to complete (optional operation).
|
awaitTermination, awaitTerminationNoCatch, create, create, getCheckLevel, getExecutionTimeMultiplier, getLogLevel, getName, getScheduler, getSettings, getStatus, run, run, set
current, getFeature, getOrCreateFeature, setFeature
default S start() throws LockedModelExecutorException
ModelExecutor
ModelExecutor.Status.ACTIVE
and awaits its
initialization to complete.
Note: A shorthand operation for ModelExecutor.startNoWait()
.
ModelExecutor.awaitInitialization()
.
start
in interface ModelExecutor
LockedModelExecutorException
- if the model execution has already been starteddefault S start(java.lang.Runnable initialization) throws LockedModelExecutorException
ModelExecutor
Supported iff ModelExecutor.setInitialization(Runnable)
is supported.
Note: A shorthand operation for
ModelExecutor.setInitialization(Runnable)
.ModelExecutor.start()
.
start
in interface ModelExecutor
initialization
- the initialization to runLockedModelExecutorException
- if the model execution has already been startedS setInitialization(java.lang.Runnable initialization) throws LockedModelExecutorException
ModelExecutor
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.
setInitialization
in interface ModelExecutor
initialization
- the initialization to runLockedModelExecutorException
- if the model execution has already been startedS shutdown()
ModelExecutor
ModelExecutor.shutdownNow()
.
This method does not await the termination of the executor, it returns instantly.
shutdown
in interface ModelExecutor
ModelExecutor.awaitTermination()
,
ModelExecutor.addTerminationBlocker(Object)
,
ModelExecutor.removeTerminationBlocker(Object)
S shutdownNow()
ModelExecutor
ModelExecutor.shutdown()
should be called instead.
This method does not await the termination of the executor, it returns instantly.
shutdownNow
in interface ModelExecutor
ModelExecutor.awaitTermination()
S 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
addTerminationListener
in interface ModelExecutor
listener
- the action to be run when the executor is terminatedS 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
removeTerminationListener
in interface ModelExecutor
listener
- the action to be removedS addTerminationBlocker(java.lang.Object blocker)
BaseModelExecutor
Thread-safe.
addTerminationBlocker
in interface BaseModelExecutor
addTerminationBlocker
in interface ModelExecutor
blocker
- the blocker to be addedS removeTerminationBlocker(java.lang.Object blocker)
BaseModelExecutor
Thread-safe.
removeTerminationBlocker
in interface BaseModelExecutor
removeTerminationBlocker
in interface ModelExecutor
blocker
- the blocker to be removeddefault S awaitInitialization()
ModelExecutor
ModelExecutor.awaitInitializationNoCatch()
if this is
not the desired behavior.awaitInitialization
in interface ModelExecutor
S awaitInitializationNoCatch() throws java.lang.InterruptedException
ModelExecutor
awaitInitializationNoCatch
in interface ModelExecutor
java.lang.InterruptedException
- if the current thread is interrupted while waitingModelExecutor.awaitInitialization()
S startNoWait() throws LockedModelExecutorException
ModelExecutor
ModelExecutor.Status.ACTIVE
.
This method returns instantly, without waiting for the initialization or
the termination of this executor. Therefore in most cases,
ModelExecutor.start()
or ModelExecutor.run()
should be used.
startNoWait
in interface ModelExecutor
LockedModelExecutorException
- if the model execution has already been starteddefault S startNoWait(java.lang.Runnable initialization) throws LockedModelExecutorException
ModelExecutor
Supported iff ModelExecutor.setInitialization(Runnable)
is supported.
This method returns instantly, without waiting for the initialization or
the termination of this executor. Therefore in most cases,
ModelExecutor.start(Runnable)
or ModelExecutor.run(Runnable)
should be used.
Note: A shorthand operation for
ModelExecutor.setInitialization(Runnable)
.ModelExecutor.startNoWait()
.
startNoWait
in interface ModelExecutor
initialization
- the initialization to runLockedModelExecutorException
- if the model execution has already been startedS addTraceListener(TraceListener listener) throws LockedModelExecutorException
ModelExecutor
TraceListener
to be called when certain (valid) events
happen during the model execution.addTraceListener
in interface ModelExecutor
listener
- the listener to addLockedModelExecutorException
- if the model execution has already been startedS addErrorListener(ErrorListener listener) throws LockedModelExecutorException
ModelExecutor
ErrorListener
to be called when errors are raised
during the model execution.addErrorListener
in interface ModelExecutor
listener
- the listener to addLockedModelExecutorException
- if the model execution has already been startedS addWarningListener(WarningListener listener) throws LockedModelExecutorException
ModelExecutor
WarningListener
to be called when warnings are raised
during the model execution.addWarningListener
in interface ModelExecutor
listener
- the listener to addLockedModelExecutorException
- if the model execution has already been startedS removeTraceListener(TraceListener listener) throws LockedModelExecutorException
ModelExecutor
removeTraceListener
in interface ModelExecutor
listener
- the listener to removeLockedModelExecutorException
- if the model execution has already been startedS removeErrorListener(ErrorListener listener) throws LockedModelExecutorException
ModelExecutor
removeErrorListener
in interface ModelExecutor
listener
- the listener to removeLockedModelExecutorException
- if the model execution has already been startedS removeWarningListener(WarningListener listener) throws LockedModelExecutorException
ModelExecutor
removeWarningListener
in interface ModelExecutor
listener
- the listener to removeLockedModelExecutorException
- if the model execution has already been startedS setLogLevel(LogLevel logLevel) throws LockedModelExecutorException
ModelExecutor
Log level is LogLevel.WARNING
by default.
setLogLevel
in interface ModelExecutor
logLevel
- the new log levelLockedModelExecutorException
- if the model execution has already been startedS setCheckLevel(CheckLevel checkLevel) throws LockedModelExecutorException
ModelExecutor
Check level is CheckLevel.OPTIONAL
by default.
setCheckLevel
in interface ModelExecutor
checkLevel
- the new check levelLockedModelExecutorException
- if the model execution has already been startedS setExecutionTimeMultiplier(double newMultiplier) throws LockedModelExecutorException
ModelExecutor
*
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.
setExecutionTimeMultiplier
in interface ModelExecutor
newMultiplier
- the new execution time multiplierLockedModelExecutorException
- if the model execution has already been startedS self()