Class LifecycleScriptExtensionProvider
java.lang.Object
org.openhab.core.automation.module.script.LifecycleScriptExtensionProvider
- All Implemented Interfaces:
ScriptExtensionProvider
@NonNullByDefault
public class LifecycleScriptExtensionProvider
extends Object
implements ScriptExtensionProvider
ScriptExtensionProvider which providers a 'lifecycleTracker' object allowing scripts to register for disposal events.
- Author:
- Jonathan Gilbert - Initial contribution
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@Nullable Object
This method should return an Object of the given type.These presets will always get injected into the ScriptEngine on instance creation.Returns the provided Presets which are supported by this ScriptExtensionProvider.getTypes()
Returns the supported types which can be received by the given ScriptExtensionProviderimportPreset
(String scriptIdentifier, String preset) This method should return variables and types of the concrete type which will be injected into the ScriptEngines scope.void
This will be called when the ScriptEngine will be unloaded (e.g.
-
Constructor Details
-
LifecycleScriptExtensionProvider
public LifecycleScriptExtensionProvider()
-
-
Method Details
-
getDefaultPresets
Description copied from interface:ScriptExtensionProvider
These presets will always get injected into the ScriptEngine on instance creation.- Specified by:
getDefaultPresets
in interfaceScriptExtensionProvider
- Returns:
- collection of presets
-
getPresets
Description copied from interface:ScriptExtensionProvider
Returns the provided Presets which are supported by this ScriptExtensionProvider. Presets define imports which will be injected into the ScriptEngine if called by "importPreset".- Specified by:
getPresets
in interfaceScriptExtensionProvider
- Returns:
- provided presets
-
getTypes
Description copied from interface:ScriptExtensionProvider
Returns the supported types which can be received by the given ScriptExtensionProvider- Specified by:
getTypes
in interfaceScriptExtensionProvider
- Returns:
- provided types
-
get
Description copied from interface:ScriptExtensionProvider
This method should return an Object of the given type. Note: get can be called multiple times in the scripts use caching where appropriate.- Specified by:
get
in interfaceScriptExtensionProvider
- Parameters:
scriptIdentifier
- the identifier of the script that requests the given typetype
- the type that is requested (must be part of the collection returned by the#getTypes()
method- Returns:
- the requested type or null
- Throws:
IllegalArgumentException
- if the given type does not match to one returned by the#getTypes()
method
-
importPreset
Description copied from interface:ScriptExtensionProvider
This method should return variables and types of the concrete type which will be injected into the ScriptEngines scope.- Specified by:
importPreset
in interfaceScriptExtensionProvider
- Parameters:
scriptIdentifier
- the identifier of the script that receives the preset- Returns:
- the presets, must be non-null (use an empty map instead)
-
unload
Description copied from interface:ScriptExtensionProvider
This will be called when the ScriptEngine will be unloaded (e.g. if the Script is deleted or updated). Every Context information stored in the ScriptExtensionProvider should be removed.- Specified by:
unload
in interfaceScriptExtensionProvider
- Parameters:
scriptIdentifier
- the identifier of the script that is unloaded
-