public class XatkitCore extends Object
This class is constructed from an ExecutionModel, that defines the Intent to Action bindings that are
executed by the application. Constructing an instance of this class will load the RuntimePlatforms used by
the provided ExecutionModel, and enable the corresponding RuntimeActions. It also creates an
instance of EventDefinitionRegistry that can be accessed to retrieve and manage EventDefinition .
| Modifier and Type | Field and Description |
|---|---|
static String |
ABSTRACT_PLATFORM_BINDINGS_PREFIX
The
Configuration key prefix to store the abstract platform bindings. |
static String |
CONFIGURATION_FOLDER_PATH_KEY
The
Configuration key to store the configuration folder path. |
static String |
CUSTOM_LIBRARIES_KEY_PREFIX
The
Configuration key prefix to store the custom library paths. |
static String |
CUSTOM_PLATFORMS_KEY_PREFIX
The
Configuration key prefix to store the custom platform paths. |
static String |
EXECUTION_MODEL_KEY
The
Configuration key to store the ExecutionModel to use. |
protected ResourceSet |
executionResourceSet
The
ResourceSet used to load the ExecutionModel and the referenced models. |
protected ExecutionService |
executionService
|
| Constructor and Description |
|---|
XatkitCore(Configuration configuration)
Constructs a new
XatkitCore instance from the provided configuration. |
| Modifier and Type | Method and Description |
|---|---|
void |
clearXatkitSessions()
Invalidates all the
XatkitSessions and clear the session registry. |
protected void |
finalize()
Logs a warning message and stops the running services if the
XatkitCore hasn't been closed properly. |
EventDefinitionRegistry |
getEventDefinitionRegistry()
Returns the
EventDefinitionRegistry associated to this instance. |
protected com.xatkit.execution.ExecutionModel |
getExecutionModel(Configuration configuration)
Retrieves the
ExecutionModel from the provided property. |
ExecutionService |
getExecutionService()
Returns the underlying
ExecutionService. |
Formatter |
getFormatter(String formatterName)
Returns the
Formatter associated to the provided formatterName. |
IntentRecognitionProvider |
getIntentRecognitionProvider()
Returns the underlying
IntentRecognitionProvider. |
XatkitSession |
getOrCreateXatkitSession(String sessionId)
Retrieves or creates the
XatkitSession associated to the provided sessionId. |
RuntimePlatformRegistry |
getRuntimePlatformRegistry()
Returns the
RuntimePlatformRegistry associated to this instance. |
XatkitServer |
getXatkitServer()
Returns the
XatkitServer used to capture incoming webhooks. |
XatkitSession |
getXatkitSession(String sessionId)
Returns the
XatkitSession associated to the provided sessionId |
Iterable<XatkitSession> |
getXatkitSessions() |
boolean |
isShutdown()
Returns whether the
XatkitCore client is shutdown. |
void |
registerFormatter(String formatterName,
Formatter formatter)
Registers the provided
formatter with the given formatterName. |
void |
shutdown()
Shuts down the
XatkitCore and the underlying engines. |
public static String EXECUTION_MODEL_KEY
Configuration key to store the ExecutionModel to use.XatkitCore(Configuration)public static String CONFIGURATION_FOLDER_PATH_KEY
Configuration key to store the configuration folder path.public static String CUSTOM_PLATFORMS_KEY_PREFIX
Configuration key prefix to store the custom platform paths.
This prefix is used to specify the paths of the custom platforms that are needed by the provided
ExecutionModel. Note that custom platform path properties are only required if the
ExecutionModel defines an alias for the imported platform models. ExecutionModels
relying on absolute paths are directly loaded from the file system, but are not portable.
Custom platform properties must be set following this pattern: CUSTOM_PLATFORMS_KEY_PREFIX + <platform
alias> = <platform path>.
public static String CUSTOM_LIBRARIES_KEY_PREFIX
Configuration key prefix to store the custom library paths.
This prefix is used to specify the paths of the custom libraries that are needed by the provided
ExecutionModel. Note that custom library path properties are only required if the
ExecutionModel defines an alias for the imported library models. ExecutionModels
relying on absolute paths are directly loaded from the file system, but are not portable.
Custom library properties must be set following this pattern: CUSTOM_LIBRARIES_KEY_PREFIX + <library
alias> = <library path>.
public static String ABSTRACT_PLATFORM_BINDINGS_PREFIX
Configuration key prefix to store the abstract platform bindings.
This prefix is used to specify the path of the concrete RuntimePlatform to bind to their abstract
definition in the provided execution model. Note that each used abstract platform needs to be bound
separately, following this pattern ABSTRACT_PLATFORM_BINDINGS_PREFIX + <abstract platform name> =
<concrete platform path>.
protected ResourceSet executionResourceSet
ResourceSet used to load the ExecutionModel and the referenced models.
The executionResourceSet is initialized with the initializeExecutionResourceSet()
method, that loads the core platforms models from the classpath, and dynamically retrieves the custom
platforms and library models.
protected ExecutionService executionService
public XatkitCore(Configuration configuration)
XatkitCore instance from the provided configuration.
The provided configuration must provide values for the following key (note that additional values may
be required according to the used RuntimeEventProviders and RuntimePlatforms):
ExecutionModel defining the Intent to
Action bindings (or the string representing its location)configuration - the Configuration to construct the instance fromNullPointerException - if the provided configuration or one of the mandatory values is nullXatkitException - if the framework is not able to retrieve the ExecutionModelExecutionModelpublic void registerFormatter(String formatterName, Formatter formatter)
formatter with the given formatterName.formatterName - the name of the formatterformatter - the Formatter to registerpublic Formatter getFormatter(String formatterName)
Formatter associated to the provided formatterName.formatterName - the name of the Formatter to retrieveFormatterXatkitException - if there is no Formatter associated to the provided formatterName.protected com.xatkit.execution.ExecutionModel getExecutionModel(Configuration configuration)
ExecutionModel from the provided property.
This method checks if the provided property is already an in-memory ExecutionModel
instance, or if it is defined by a String or an URI representing the path of the model. In
that case, the method attempts to load the model at the provided location and returns it.
This method supports loading of model path defined by Strings and URIs. Support for additional
types is planned in the next releases.
configuration - the Configuration to retrieve the ExecutionModel fromExecutionModel from the provided propertyXatkitException - if the provided property type is not handled, if the
underlying Resource cannot be loaded or if it does not contain an
ExecutionModel top-level element, or if the loaded
ExecutionModel is empty.NullPointerException - if the provided property is nullpublic ExecutionService getExecutionService()
ExecutionService.ExecutionServicepublic IntentRecognitionProvider getIntentRecognitionProvider()
IntentRecognitionProvider.
Note: this method is designed to ease debugging and testing, direct interactions with the
IntentRecognitionProvider API may create consistency issues. In particular, xatkit does not ensure
that RuntimeActions will be triggered in case of direct queries to the
IntentRecognitionProvider API.
IntentRecognitionProviderpublic EventDefinitionRegistry getEventDefinitionRegistry()
EventDefinitionRegistry associated to this instance.
This registry is used to cache EventDefinitions and IntentDefinitions from the input
ExecutionModel and provides utility methods to retrieve specific EventDefinition and
IntentDefinition and clear the cache.
EventDefinitionRegistry associated to this instancepublic RuntimePlatformRegistry getRuntimePlatformRegistry()
RuntimePlatformRegistry associated to this instance.
This registry is used to cache loaded RuntimePlatforms, and provides utility method to retrieve,
unregister, and clear them.
RuntimePlatformRegistry associated to this instancepublic XatkitServer getXatkitServer()
XatkitServer used to capture incoming webhooks.XatkitServer used to capture incoming webhookspublic void shutdown()
XatkitCore and the underlying engines.
This method shuts down the underlying IntentRecognitionProvider, unloads and shuts down all the
RuntimePlatforms associated to this instance, unregisters the EventDefinition from the associated
EventDefinitionRegistry, shuts down the ExecutionService, and stops the XatkitServer.
Note: calling this method invalidates the IntentRecognitionProvider connection, and thus shuts
down intent recognition features. New RuntimeActions cannot be processed either.
public boolean isShutdown()
XatkitCore client is shutdown.
This class is considered as shutdown if its underlying ExecutionService,
IntentRecognitionProvider, and XatkitServer are shutdown.
true if the XatkitCore client is shutdown, false otherwisepublic XatkitSession getOrCreateXatkitSession(String sessionId)
XatkitSession associated to the provided sessionId.
If the XatkitSession does not exist a new one is created using
IntentRecognitionProvider.createSession(String).
sessionId - the identifier to get or retrieve a session fromXatkitSession associated to the provided sessionIdNullPointerException - if the provided sessionId is nullpublic XatkitSession getXatkitSession(String sessionId)
XatkitSession associated to the provided sessionIdsessionId - the identifier to retrieve the session fromXatkitSession associated to the provided sessionIdNullPointerException - if the provided sessionId is nullpublic Iterable<XatkitSession> getXatkitSessions()
public void clearXatkitSessions()
XatkitSessions and clear the session registry.protected void finalize()
throws Throwable
XatkitCore hasn't been closed properly.Copyright © 2020 SOM Research Lab. All rights reserved.