org.springframework.scripting

## 接口 ScriptFactory

- 所有已知实现类:
    BshScriptFactory, GroovyScriptFactory, StandardScriptFactory

      public interface ScriptFactory

  Script definition interface, encapsulating the configuration of a specific script as well as a factory method for creating the actual scripted Java `Object`.
  从以下版本开始:
    2.0
  作者:
    Juergen Hoeller, Rob Harrop
  另请参阅:
    `getScriptSourceLocator()`, `getScriptedObject(org.springframework.scripting.ScriptSource, java.lang.Class<?>...)`

- - ### 方法概要

    所有方法 实例方法 抽象方法
    限定符和类型 | 方法和说明
    --- | ---
    `Object` | `getScriptedObject(ScriptSource scriptSource, Class<?>... actualInterfaces)` Factory method for creating the scripted Java object.
    `Class<?>` | `getScriptedObjectType(ScriptSource scriptSource)` Determine the type of the scripted Java object.
    `Class<?>[]` | `getScriptInterfaces()` Return the business interfaces that the script is supposed to implement.
    `String` | `getScriptSourceLocator()` Return a locator that points to the source of the script.
    `boolean` | `requiresConfigInterface()` Return whether the script requires a config interface to be generated for it.
    `boolean` | `requiresScriptedObjectRefresh(ScriptSource scriptSource)` Determine whether a refresh is required (e.g. through ScriptSource's `isModified()` method).

- - ### 方法详细资料

    - #### getScriptSourceLocator

          String getScriptSourceLocator()

      Return a locator that points to the source of the script. Interpreted by the post-processor that actually creates the script.

      Typical supported locators are Spring resource locations (such as "file:C:/myScript.bsh" or "classpath:myPackage/myScript.bsh") and inline scripts ("inline:myScriptText...").

      返回:
        the script source locator
      另请参阅:
        `ScriptFactoryPostProcessor.convertToScriptSource(java.lang.String, java.lang.String, org.springframework.core.io.ResourceLoader)`, `ResourceLoader`

    - #### getScriptInterfaces

          @Nullable
          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).

      返回:
        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()`.
      返回:
        whether the script requires a generated config interface
      另请参阅:
        `getScriptInterfaces()`

    - #### getScriptedObject

          @Nullable
          Object getScriptedObject(ScriptSource scriptSource,
                                              @Nullable
                                              Class<?>... actualInterfaces)
                                       throws 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.

      参数:
        `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`)
      返回:
        the scripted Java object
      抛出:
        `IOException` - if script retrieval failed
        `ScriptCompilationException` - if script compilation failed

    - #### getScriptedObjectType

          @Nullable
          Class<?> getScriptedObjectType(ScriptSource scriptSource)
                                             throws 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.

      参数:
        `scriptSource` - the actual ScriptSource to retrieve the script source text from (never `null`)
      返回:
        the type of the scripted Java object, or `null` if none could be determined
      抛出:
        `IOException` - if script retrieval failed
        `ScriptCompilationException` - if script compilation failed
      从以下版本开始:
        2.0.3

    - #### requiresScriptedObjectRefresh

          boolean requiresScriptedObjectRefresh(ScriptSource scriptSource)

      Determine whether a refresh is required (e.g. through ScriptSource's `isModified()` method).
      参数:
        `scriptSource` - the actual ScriptSource to retrieve the script source text from (never `null`)
      返回:
        whether a fresh `getScriptedObject(org.springframework.scripting.ScriptSource, java.lang.Class<?>...)` call is required
      从以下版本开始:
        2.5.2
      另请参阅:
        `ScriptSource.isModified()`