public class ExecutionService
extends org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter
EventInstance
s and executes the corresponding RuntimeAction
s defined in the
provided ExecutionModel
.
This class defines Xatkit' execution logic: RuntimeEventProvider
s typically call the
handleEventInstance(EventInstance, XatkitSession)
method to process a retrieved EventInstance
,
and trigger the RuntimeAction
s that are associated to it in the ExecutionModel
.
The ExecutionService
is initialized by the XatkitCore
instance, that loads the
ExecutionModel
and initializes the RuntimePlatformRegistry
.
EventInstance
,
XatkitCore
Modifier and Type | Field and Description |
---|---|
static String |
MATCHED_EVENT_SESSION_KEY
The
XatkitSession key used to store the matched event. |
Constructor and Description |
---|
ExecutionService(com.xatkit.execution.ExecutionModel executionModel,
RuntimePlatformRegistry runtimePlatformRegistry,
Configuration configuration)
|
Modifier and Type | Method and Description |
---|---|
protected Object |
doEvaluate(org.eclipse.xtext.xbase.XExpression expression,
org.eclipse.xtext.xbase.interpreter.IEvaluationContext context,
org.eclipse.xtext.util.CancelIndicator indicator)
Evaluates the provided
expression . |
com.xatkit.execution.ExecutionModel |
getExecutionModel()
Returns the
ExecutionModel associated to this ExecutionService . |
protected ExecutorService |
getExecutorService()
Returns the
ExecutorService used to process RuntimeAction s. |
RuntimePlatformRegistry |
getRuntimePlatformRegistry()
Returns the
RuntimePlatformRegistry associated to this ExecutionService . |
void |
handleEventInstance(com.xatkit.intent.EventInstance eventInstance,
XatkitSession session)
Handles the provided
eventInstance and executes the corresponding RuntimeAction s defined in the
ExecutionModel . |
boolean |
isShutdown()
Returns whether the
ExecutionService is shutdown. |
void |
shutdown()
Shuts down the underlying
ExecutorService . |
_assignValueTo, _assignValueTo, _assignValueTo, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _doEvaluate, _invokeFeature, _invokeFeature, _invokeFeature, applyGetAndAssignOperator, assignValueTo, castToPrimitiveType, coerceArgumentType, createContext, eq, evaluate, evaluate, evaluateArgumentExpressions, evaluateGetAndAssign, featureCallField, getActualArguments, getActualReceiver, getClass, getClassFinder, getDefaultObjectValue, getJavaReflectAccess, getJavaType, getReceiver, internalEvaluate, invokeFeature, invokeOperation, invokeOperation, isGetAndAssign, isInstanceoOf, isType, resolveType, setClassLoader, setFeatureNameProvider, throwClassCastException, throwNullPointerException, translateJvmTypeToResult, wrapOrUnwrapArray
public static final String MATCHED_EVENT_SESSION_KEY
XatkitSession
key used to store the matched event.
The value associated to this key is an EventInstance
.
public ExecutionService(com.xatkit.execution.ExecutionModel executionModel, RuntimePlatformRegistry runtimePlatformRegistry, Configuration configuration)
ExecutionService
based on the provided executionModel
and runtimePlatformRegistry
.
This constructor also takes care of resolving all the proxies in the provided ExecutionModel
,
ensuring that concurrent accesses of the model will not produce unexpected behaviors (see
this post)
executionModel
- the ExecutionModel
representing the intent-to-action bindings to useruntimePlatformRegistry
- the RuntimePlatformRegistry
used to create the RuntimeAction
s
to executeconfiguration
- the Xatkit configurationNullPointerException
- if the provided executionModel
or runtimePlatformRegistry
is
null
protected ExecutorService getExecutorService()
ExecutorService
used to process RuntimeAction
s.
Note: this method is designed to ease testing, and should not be accessed by client applications.
Manipulating XatkitCore
's ExecutorService
may create consistency issues on currently executed
RuntimeAction
s.
ExecutorService
used to process RuntimeAction
spublic com.xatkit.execution.ExecutionModel getExecutionModel()
ExecutionModel
associated to this ExecutionService
.ExecutionModel
associated to this ExecutionService
public RuntimePlatformRegistry getRuntimePlatformRegistry()
RuntimePlatformRegistry
associated to this ExecutionService
.RuntimePlatformRegistry
associated to this ExecutionService
public void handleEventInstance(com.xatkit.intent.EventInstance eventInstance, XatkitSession session)
eventInstance
and executes the corresponding RuntimeAction
s defined in the
ExecutionModel
.
This method creates an asynchronous task that retrieves the RuntimeAction
s to execute from the
ExecutionModel
, and executes them sequentially. Note that all the RuntimeAction
s are
executed in the same Thread
, in order to ensure that their pre-conditions are respected (i.e. the
context variables defined by an action are available for the next ones).
Exceptions thrown from the computed RuntimeAction
s are logged and ignored, so the calling
RuntimeEventProvider
does not have to handle the exception, and can process the next event.
The created task also registers the output context values to the provided session
, making them
available for the computed actions.
eventInstance
- the EventInstance
to handlesession
- the XatkitSession
used to define and access context variablesNullPointerException
- if the provided eventInstance
or session
is null
executeExecutionRule(ExecutionRule, XatkitSession)
protected Object doEvaluate(org.eclipse.xtext.xbase.XExpression expression, org.eclipse.xtext.xbase.interpreter.IEvaluationContext context, org.eclipse.xtext.util.CancelIndicator indicator)
expression
.
This methods delegates to the XbaseInterpreter
the computation of all XExpression
s, excepted
XMemberFeatureCall
s representing platform's action call. For these specific expressions the
interpreter takes care of constructing the corresponding RuntimeAction
, evaluates its parameters, and
invoke it.
doEvaluate
in class org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter
expression
- the XExpression
to evaluatecontext
- the IEvaluationContext
containing the information already computed during the
evaluationindicator
- the indicatorexecuteRuntimeAction(RuntimeAction)
public void shutdown()
ExecutorService
.
Shutting down the ExecutionService
invalidates it and does not allow to process new
RuntimeAction
s.
public boolean isShutdown()
ExecutionService
is shutdown.ExecutionService
is shutdownCopyright © 2020 SOM Research Lab. All rights reserved.