org.springframework.scripting

Interface ScriptFactory

    • Method Detail

      • getScriptInterfaces

        @Nullable
        java.lang.Class<?>[] getScriptInterfaces()
        Return the business interfaces that the script is supposed to implement.

        Can return null if the script itself determines its Java interfaces (such as in the case of Groovy).

        Returns:
        the interfaces for the script
      • requiresConfigInterface

        boolean requiresConfigInterface()
        Return whether the script requires a config interface to be generated for it. This is typically the case for scripts that do not determine Java signatures themselves, with no appropriate config interface specified in getScriptInterfaces().
        Returns:
        whether the script requires a generated config interface
        See Also:
        getScriptInterfaces()
      • getScriptedObject

        @Nullable
        java.lang.Object getScriptedObject(ScriptSource scriptSource,
                                                     @Nullable
                                                     java.lang.Class<?>... actualInterfaces)
                                              throws java.io.IOException,
                                                     ScriptCompilationException
        Factory method for creating the scripted Java object.

        Implementations are encouraged to cache script metadata such as a generated script class. Note that this method may be invoked concurrently and must be implemented in a thread-safe fashion.

        Parameters:
        scriptSource - the actual ScriptSource to retrieve the script source text from (never null)
        actualInterfaces - the actual interfaces to expose, including script interfaces as well as a generated config interface (if applicable; may be null)
        Returns:
        the scripted Java object
        Throws:
        java.io.IOException - if script retrieval failed
        ScriptCompilationException - if script compilation failed
      • getScriptedObjectType

        @Nullable
        java.lang.Class<?> getScriptedObjectType(ScriptSource scriptSource)
                                                    throws java.io.IOException,
                                                           ScriptCompilationException
        Determine the type of the scripted Java object.

        Implementations are encouraged to cache script metadata such as a generated script class. Note that this method may be invoked concurrently and must be implemented in a thread-safe fashion.

        Parameters:
        scriptSource - the actual ScriptSource to retrieve the script source text from (never null)
        Returns:
        the type of the scripted Java object, or null if none could be determined
        Throws:
        java.io.IOException - if script retrieval failed
        ScriptCompilationException - if script compilation failed
        Since:
        2.0.3