Class ScriptExecutorFactory

  • Direct Known Subclasses:
    GroovyScriptExecutorFactory

    public abstract class ScriptExecutorFactory
    extends Object
    Abstraction for finding script executors to allow us to invoke scripts from java.

    NOTE: This is intended purely for executing java-embedable scripting languages. That is, the execution model is assumed to be same-JVM, so scripts can have side effects on objects passed to the script. This is used internally by the connector framework in its implementation of ScriptOnConnectorApiOp and should be used by connectors should they need to have a custom implementation of ScriptOnConnectorOp. This is not intended for use by connectors that implement ScriptOnResourceOp.

    • Constructor Detail

      • ScriptExecutorFactory

        public ScriptExecutorFactory()
    • Method Detail

      • getSupportedLanguages

        public static Set<String> getSupportedLanguages()
        Returns the set of supported languages.
        Returns:
        The set of supported languages.
      • newInstance

        public static ScriptExecutorFactory newInstance​(String language)
        Creates a ScriptExecutorFactory for the given language.
        Parameters:
        language - The name of the language
        Returns:
        The script executor factory
        Throws:
        IllegalArgumentException - If the given language is not supported.
      • newScriptExecutor

        public abstract ScriptExecutor newScriptExecutor​(ClassLoader loader,
                                                         String script,
                                                         boolean compile)
        Creates a script executor for the given script.
        Parameters:
        loader - The classloader that contains the java classes that the script should have access to.
        script - The script text.
        compile - A hint to tell the script executor whether or not to compile the given script. This need not be implemented by all script executors. If true, the caller is saying that they intend to call the script multiple times with different arguments, so compile if possible.
        Returns:
        A script executor.
      • getLanguageName

        public abstract String getLanguageName()
        Returns the name of the language supported by this factory.
        Returns:
        the name of the language.