org.springframework.scripting.bsh

Class BshScriptUtils

  • java.lang.Object
    • org.springframework.scripting.bsh.BshScriptUtils


  • public abstract class BshScriptUtils
    extends java.lang.Object
    Utility methods for handling BeanShell-scripted objects.
    Since:
    2.0
    Author:
    Rob Harrop, Juergen Hoeller
    • Constructor Summary

      Constructors 
      Constructor and Description
      BshScriptUtils() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.lang.Object createBshObject(java.lang.String scriptSource)
      Create a new BeanShell-scripted object from the given script source.
      static java.lang.Object createBshObject(java.lang.String scriptSource, java.lang.Class<?>... scriptInterfaces)
      Create a new BeanShell-scripted object from the given script source, using the default ClassLoader.
      static java.lang.Object createBshObject(java.lang.String scriptSource, java.lang.Class<?>[] scriptInterfaces, java.lang.ClassLoader classLoader)
      Create a new BeanShell-scripted object from the given script source.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BshScriptUtils

        public BshScriptUtils()
    • Method Detail

      • createBshObject

        public static java.lang.Object createBshObject(java.lang.String scriptSource)
                                                throws bsh.EvalError
        Create a new BeanShell-scripted object from the given script source.

        With this createBshObject variant, the script needs to declare a full class or return an actual instance of the scripted object.

        Parameters:
        scriptSource - the script source text
        Returns:
        the scripted Java object
        Throws:
        bsh.EvalError - in case of BeanShell parsing failure
      • createBshObject

        public static java.lang.Object createBshObject(java.lang.String scriptSource,
                                                       @Nullable
                                                       java.lang.Class<?>... scriptInterfaces)
                                                throws bsh.EvalError
        Create a new BeanShell-scripted object from the given script source, using the default ClassLoader.

        The script may either be a simple script that needs a corresponding proxy generated (implementing the specified interfaces), or declare a full class or return an actual instance of the scripted object (in which case the specified interfaces, if any, need to be implemented by that class/instance).

        Parameters:
        scriptSource - the script source text
        scriptInterfaces - the interfaces that the scripted Java object is supposed to implement (may be null or empty if the script itself declares a full class or returns an actual instance of the scripted object)
        Returns:
        the scripted Java object
        Throws:
        bsh.EvalError - in case of BeanShell parsing failure
        See Also:
        createBshObject(String, Class[], ClassLoader)
      • createBshObject

        public static java.lang.Object createBshObject(java.lang.String scriptSource,
                                                       @Nullable
                                                       java.lang.Class<?>[] scriptInterfaces,
                                                       @Nullable
                                                       java.lang.ClassLoader classLoader)
                                                throws bsh.EvalError
        Create a new BeanShell-scripted object from the given script source.

        The script may either be a simple script that needs a corresponding proxy generated (implementing the specified interfaces), or declare a full class or return an actual instance of the scripted object (in which case the specified interfaces, if any, need to be implemented by that class/instance).

        Parameters:
        scriptSource - the script source text
        scriptInterfaces - the interfaces that the scripted Java object is supposed to implement (may be null or empty if the script itself declares a full class or returns an actual instance of the scripted object)
        classLoader - the ClassLoader to use for evaluating the script
        Returns:
        the scripted Java object
        Throws:
        bsh.EvalError - in case of BeanShell parsing failure