public abstract class RuntimePlatform extends Object
PlatformDefinition.
A RuntimePlatform manages a set of RuntimeActions that represent the concrete actions that can
be executed by the platform. This class provides primitives to enable/disable specific actions, and construct
RuntimeAction instances from a given EventInstance.
Note that enabling a RuntimeAction will load the corresponding class, that must be stored in the
action package of the concrete RuntimePlatform implementation. For example, enabling the action
MyAction from the RuntimePlatform myPlatformPackage.MyPlatform will attempt to load the class
myPlatformPackage.action.MyAction.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
RuntimePlatform.EventProviderThread
The
Thread class used to start RuntimeEventProviders. |
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,Class<? extends RuntimeAction>> |
actionMap
The
Map containing the RuntimeAction associated to this platform. |
protected Configuration |
configuration
The
Configuration used to initialize this class. |
protected Map<String,RuntimePlatform.EventProviderThread> |
eventProviderMap
The
Map containing the RuntimePlatform.EventProviderThreads associated to this platform. |
protected XatkitCore |
xatkitCore
The
XatkitCore instance containing this platform. |
| Constructor and Description |
|---|
RuntimePlatform(XatkitCore xatkitCore)
Constructs a new
RuntimePlatform from the provided XatkitCore. |
RuntimePlatform(XatkitCore xatkitCore,
Configuration configuration)
|
| Modifier and Type | Method and Description |
|---|---|
RuntimeAction |
createRuntimeAction(org.eclipse.xtext.xbase.XMemberFeatureCall actionCall,
List<Object> arguments,
XatkitSession session)
Creates a new
RuntimeAction instance from the provided XMemberFeatureCall. |
void |
disableAction(com.xatkit.platform.ActionDefinition actionDefinition)
Disables the
RuntimeAction defined by the provided ActionDefinition. |
void |
disableAllActions()
Disables all the
RuntimeActions of the RuntimePlatform. |
void |
enableAction(com.xatkit.platform.ActionDefinition actionDefinition)
Retrieves and loads the
RuntimeAction defined by the provided ActionDefinition. |
Collection<Class<? extends RuntimeAction>> |
getActions()
|
Configuration |
getConfiguration()
Returns the platform's
Configuration. |
protected Map<String,RuntimePlatform.EventProviderThread> |
getEventProviderMap()
Returns
Map containing the RuntimePlatform.EventProviderThreads associated to this platform. |
String |
getName()
Returns the name of the platform.
|
XatkitCore |
getXatkitCore()
Returns the
XatkitCore instance associated to this platform. |
void |
shutdown()
Shuts down the
RuntimePlatform. |
void |
startEventProvider(com.xatkit.platform.EventProviderDefinition eventProviderDefinition)
Starts the
RuntimeEventProvider corresponding to the provided eventProviderDefinition. |
String |
toString()
Returns a
String representation of this platform. |
protected XatkitCore xatkitCore
XatkitCore instance containing this platform.protected Configuration configuration
Configuration used to initialize this class.
This Configuration is used by the RuntimePlatform to initialize the
RuntimeEventProviders and
RuntimeActions.
protected Map<String,Class<? extends RuntimeAction>> actionMap
Map containing the RuntimeAction associated to this platform.
This Map is used as a cache to retrieve RuntimeAction that have been previously loaded.
protected Map<String,RuntimePlatform.EventProviderThread> eventProviderMap
Map containing the RuntimePlatform.EventProviderThreads associated to this platform.
This Map filled when new RuntimeEventProviders are started (see
startEventProvider(EventProviderDefinition)), and is used to cache
RuntimePlatform.EventProviderThreads and stop them when the platform is shutdown().
shutdown()public RuntimePlatform(XatkitCore xatkitCore, Configuration configuration)
RuntimePlatform from the provided XatkitCore and Configuration.
Note: this constructor will be called by xatkit internal engine when initializing the
RuntimePlatforms. Subclasses implementing this constructor typically need additional parameters to be
initialized, that can be provided in the configuration.
xatkitCore - the XatkitCore instance associated to this platformconfiguration - the Configuration used to initialize the RuntimePlatformNullPointerException - if the provided xatkitCore or configuration is nullRuntimePlatform(XatkitCore)public RuntimePlatform(XatkitCore xatkitCore)
RuntimePlatform from the provided XatkitCore.
Note: this constructor should be used by RuntimePlatforms that do not require additional
parameters to be initialized. In that case see RuntimePlatform(XatkitCore, Configuration).
NullPointerException - if the provided xatkitCore is nullRuntimePlatform(XatkitCore, Configuration)public final String getName()
This method returns the value of Class.getSimpleName(), and can not be overridden by concrete
subclasses. RuntimePlatform's names are part of xatkit's naming convention, and are used to dynamically
load platforms and actions.
public final XatkitCore getXatkitCore()
XatkitCore instance associated to this platform.XatkitCore instance associated to this platformpublic final Configuration getConfiguration()
Configuration.Configurationpublic final void startEventProvider(com.xatkit.platform.EventProviderDefinition eventProviderDefinition)
RuntimeEventProvider corresponding to the provided eventProviderDefinition.
This method dynamically loads the RuntimeEventProvider corresponding to the provided eventProviderDefinition, and starts it in a dedicated Thread.
This method also registers WebhookEventProviders to the underlying XatkitServer (see
XatkitServer.registerWebhookEventProvider(WebhookEventProvider)).
eventProviderDefinition - the EventProviderDefinition representing the
RuntimeEventProvider to
startNullPointerException - if the provided eventProviderDefinition or xatkitCore is nullRunnable.run(),
XatkitServer.registerWebhookEventProvider(WebhookEventProvider)protected Map<String,RuntimePlatform.EventProviderThread> getEventProviderMap()
Map containing the RuntimePlatform.EventProviderThreads associated to this platform.
Note: this method is protected for testing purposes, and should not be called by client code.Map containing the RuntimePlatform.EventProviderThreads associated to this platformpublic void enableAction(com.xatkit.platform.ActionDefinition actionDefinition)
RuntimeAction defined by the provided ActionDefinition.
This method loads the corresponding RuntimeAction based on xatkit's naming convention. The
RuntimeAction must be located under the actionDefinition sub-package of the
RuntimePlatform
concrete subclass package.
actionDefinition - the ActionDefinition representing the RuntimeAction to enableLoader.loadClass(String, Class)public void disableAction(com.xatkit.platform.ActionDefinition actionDefinition)
RuntimeAction defined by the provided ActionDefinition.actionDefinition - the ActionDefinition representing the RuntimeAction to disablepublic final void disableAllActions()
RuntimeActions of the RuntimePlatform.public final Collection<Class<? extends RuntimeAction>> getActions()
RuntimeAction Classes associated to this RuntimePlatform.
This method returns the Classes describing the RuntimeActions associated to this platform. To
construct a new RuntimeAction see createRuntimeAction(XMemberFeatureCall, List, XatkitSession).
RuntimeAction Classes associated to this RuntimePlatformcreateRuntimeAction(XMemberFeatureCall, List, XatkitSession)public RuntimeAction createRuntimeAction(org.eclipse.xtext.xbase.XMemberFeatureCall actionCall, List<Object> arguments, XatkitSession session)
RuntimeAction instance from the provided XMemberFeatureCall.
This methods attempts to construct a RuntimeAction defined by the provided actionCall by
matching the provided arguments to the ActionDefinition's parameters.
actionCall - the XMemberFeatureCall representing the RuntimeAction to createarguments - the List of computed values used as arguments for the created RuntimeActionsession - the XatkitSession associated to the actionRuntimeAction instance from the provided actionCallNullPointerException - if the provided actionCall, arguments, or session is
nullXatkitException - if the provided actionCall does not match any RuntimeAction,
or if an error occurred when building the RuntimeActionpublic void shutdown()
RuntimePlatform.
This method attempts to terminate all the running RuntimeEventProvider threads, close the corresponding
RuntimeEventProviders, and disables all the platform's actions.
RuntimeEventProvider.close(),
disableAllActions()public String toString()
String representation of this platform.
Platforms are singletons in Xatkit: we can safely return their type (see Class.getSimpleName()) as a
way to identify them in logs.
Copyright © 2020 SOM Research Lab. All rights reserved.