public class ExecutionService
extends org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter
EventInstances and executes the corresponding RuntimeActions defined in the
provided ExecutionModel.
This class defines Xatkit' execution logic: RuntimeEventProviders typically call the
handleEventInstance(EventInstance, XatkitSession) method to process a retrieved EventInstance,
and trigger the RuntimeActions 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 RuntimeActions. |
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 RuntimeActions 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, wrapOrUnwrapArraypublic 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 RuntimeActions
to executeconfiguration - the Xatkit configurationNullPointerException - if the provided executionModel or runtimePlatformRegistry is
nullprotected ExecutorService getExecutorService()
ExecutorService used to process RuntimeActions.
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
RuntimeActions.
ExecutorService used to process RuntimeActionspublic com.xatkit.execution.ExecutionModel getExecutionModel()
ExecutionModel associated to this ExecutionService.ExecutionModel associated to this ExecutionServicepublic RuntimePlatformRegistry getRuntimePlatformRegistry()
RuntimePlatformRegistry associated to this ExecutionService.RuntimePlatformRegistry associated to this ExecutionServicepublic void handleEventInstance(com.xatkit.intent.EventInstance eventInstance,
XatkitSession session)
eventInstance and executes the corresponding RuntimeActions defined in the
ExecutionModel.
This method creates an asynchronous task that retrieves the RuntimeActions to execute from the
ExecutionModel, and executes them sequentially. Note that all the RuntimeActions 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 RuntimeActions 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 nullexecuteExecutionRule(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 XExpressions, excepted
XMemberFeatureCalls 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.XbaseInterpreterexpression - 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
RuntimeActions.
public boolean isShutdown()
ExecutionService is shutdown.ExecutionService is shutdownCopyright © 2020 SOM Research Lab. All rights reserved.