Class 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
    • Constructor Detail

      • LifecycleScriptExtensionProvider

        public LifecycleScriptExtensionProvider()
    • Method Detail

      • getPresets

        public Collection<String> 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 interface ScriptExtensionProvider
        Returns:
        provided presets
      • get

        public @Nullable Object get​(String scriptIdentifier,
                                    String type)
                             throws IllegalArgumentException
        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 interface ScriptExtensionProvider
        Parameters:
        scriptIdentifier - the identifier of the script that requests the given type
        type - 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

        public Map<String,​Object> importPreset​(String scriptIdentifier,
                                                     String preset)
        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 interface ScriptExtensionProvider
        Parameters:
        scriptIdentifier - the identifier of the script that receives the preset
        Returns:
        the presets, must be non-null (use an empty map instead)
      • unload

        public void unload​(String scriptIdentifier)
        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 interface ScriptExtensionProvider
        Parameters:
        scriptIdentifier - the identifier of the script that is unloaded