T
- the concrete RuntimePlatform
subclass type containing the actionpublic abstract class RuntimeAction<T extends RuntimePlatform> extends Object implements Callable<RuntimeActionResult>
ActionDefinition
definition.
A RuntimeAction
represents an atomic action that are automatically executed by the
ExecutionService
component. Instances of this class are created by the associated RuntimePlatform
from an input
RecognizedIntent
.
Note that RuntimeAction
s implementations must be stored in the action package of their associated
concrete RuntimePlatform
implementation to enable their automated loading. For example, the action
MyAction defined in the platform myPlatformPackage.MyPlatform should be stored in the package
myPlatformPackage.action
ActionDefinition
,
ExecutionService
,
RuntimePlatform
Modifier and Type | Field and Description |
---|---|
protected T |
runtimePlatform
The
RuntimePlatform subclass containing this action. |
protected XatkitSession |
session
The
XatkitSession associated to this action. |
Constructor and Description |
---|
RuntimeAction(T runtimePlatform,
XatkitSession session)
|
Modifier and Type | Method and Description |
---|---|
RuntimeActionResult |
call()
Runs the
RuntimeAction and returns its result wrapped in a RuntimeActionResult . |
protected abstract Object |
compute()
The concrete implementation of the
RuntimeAction 's computation. |
XatkitSession |
getSession()
Returns the
XatkitSession used to compute this action. |
void |
init()
A hook method that is called after
RuntimeAction . |
protected T extends RuntimePlatform runtimePlatform
RuntimePlatform
subclass containing this action.protected XatkitSession session
XatkitSession
associated to this action.public RuntimeAction(T runtimePlatform, XatkitSession session)
runtimePlatform
- the RuntimePlatform
containing this actionsession
- the XatkitSession
associated to this actionNullPointerException
- if the provided runtimePlatform
or session
is null
public void init()
RuntimeAction
.
This method can be extended by subclasses to add post-construction computation, such as setting additional
fields, checking invariants once the RuntimeAction
has been initialized, etc.
public RuntimeActionResult call()
RuntimeAction
and returns its result wrapped in a RuntimeActionResult
.
This method should not be called manually, and is handled by the ExecutionService
component that
manages and executes RuntimeAction
s.
This method does not throw any Exception
if the underlying RuntimeAction
's computation does not
complete. Exceptions thrown during the RuntimeAction
's computation can be accessed through the
RuntimeActionResult.getThrownException()
method.
call
in interface Callable<RuntimeActionResult>
RuntimeActionResult
containing the raw result of the computation and monitoring informationExecutionService
,
RuntimeActionResult
public XatkitSession getSession()
XatkitSession
used to compute this action.
The returned XatkitSession
can be different from the one provided in the constructor if the
RuntimeAction
needs to create a dedicated session. This is for example the case with messaging
actions, that typically need to create a session representing the channel
to send messages to.
XatkitSession
used to compute this actionprotected abstract Object compute() throws Exception
RuntimeAction
's computation.
This method is internally called by the call()
method to perform the raw computation and wrap the
results in a RuntimeActionResult
. Note that compute()
can return raw computation result, and
do not have to deal with setting the monitoring information of the created RuntimeActionResult
.
This method should be overriden by subclasses to implement the RuntimeAction
's computation logic.
RuntimeAction
's computationException
- if an error occurred when computing the RuntimeAction
Copyright © 2020 SOM Research Lab. All rights reserved.