org.springframework.scripting.bsh

## Class BshScriptEvaluator

- java.lang.Object
- - org.springframework.scripting.bsh.BshScriptEvaluator

- All Implemented Interfaces:
    Aware, BeanClassLoaderAware, ScriptEvaluator

      public class BshScriptEvaluator
      extends Object
      implements ScriptEvaluator, BeanClassLoaderAware

  BeanShell-based implementation of Spring's `ScriptEvaluator` strategy interface.
  Since:
    4.0
  Author:
    Juergen Hoeller
  See Also:
    `Interpreter.eval(String)`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BshScriptEvaluator()` Construct a new BshScriptEvaluator.
    `BshScriptEvaluator(ClassLoader classLoader)` Construct a new BshScriptEvaluator.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Object` | `evaluate(ScriptSource script)` Evaluate the given script.
    `Object` | `evaluate(ScriptSource script, Map<String,Object> arguments)` Evaluate the given script with the given arguments.
    `void` | `setBeanClassLoader(ClassLoader classLoader)` Callback that supplies the bean `class loader` to a bean instance.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BshScriptEvaluator

          public BshScriptEvaluator()

      Construct a new BshScriptEvaluator.

    - #### BshScriptEvaluator

          public BshScriptEvaluator(ClassLoader classLoader)

      Construct a new BshScriptEvaluator.
      Parameters:
        `classLoader` - the ClassLoader to use for the `Interpreter`

  - ### Method Detail

    - #### setBeanClassLoader

          public void setBeanClassLoader(ClassLoader classLoader)

      Description copied from interface: `BeanClassLoaderAware`
      Callback that supplies the bean `class loader` to a bean instance.

      Invoked after the population of normal bean properties but before an initialization callback such as `InitializingBean's` `InitializingBean.afterPropertiesSet()` method or a custom init-method.

      Specified by:
        `setBeanClassLoader` in interface `BeanClassLoaderAware`
      Parameters:
        `classLoader` - the owning class loader

    - #### evaluate

          @Nullable
          public Object evaluate(ScriptSource script)

      Description copied from interface: `ScriptEvaluator`
      Evaluate the given script.
      Specified by:
        `evaluate` in interface `ScriptEvaluator`
      Parameters:
        `script` - the ScriptSource for the script to evaluate
      Returns:
        the return value of the script, if any

    - #### evaluate

          @Nullable
          public Object evaluate(ScriptSource script,
                                           @Nullable
                                           Map<String,Object> arguments)

      Description copied from interface: `ScriptEvaluator`
      Evaluate the given script with the given arguments.
      Specified by:
        `evaluate` in interface `ScriptEvaluator`
      Parameters:
        `script` - the ScriptSource for the script to evaluate
        `arguments` - the key-value pairs to expose to the script, typically as script variables (may be `null` or empty)
      Returns:
        the return value of the script, if any