Interface ScriptExtensionProvider
- All Known Implementing Classes:
LifecycleScriptExtensionProvider
@NonNullByDefault
public interface ScriptExtensionProvider
A
ScriptExtensionProvider
can provide variable and types on ScriptEngine instance basis.- Author:
- Simon Merschjohann - Initial contribution
-
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.
-
Method Details
-
getDefaultPresets
Collection<String> getDefaultPresets()These presets will always get injected into the ScriptEngine on instance creation.- Returns:
- collection of presets
-
getPresets
Collection<String> getPresets()Returns the provided Presets which are supported by this ScriptExtensionProvider. Presets define imports which will be injected into the ScriptEngine if called by "importPreset".- Returns:
- provided presets
-
getTypes
Collection<String> getTypes()Returns the supported types which can be received by the given ScriptExtensionProvider- Returns:
- provided types
-
get
This method should return an Object of the given type. Note: get can be called multiple times in the scripts use caching where appropriate.- 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
This method should return variables and types of the concrete type which will be injected into the ScriptEngines scope.- Parameters:
scriptIdentifier
- the identifier of the script that receives the preset- Returns:
- the presets, must be non-null (use an empty map instead)
-
unload
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.- Parameters:
scriptIdentifier
- the identifier of the script that is unloaded
-