Class ScriptContext


  • public class ScriptContext
    extends java.lang.Object
    The ScriptContext class provides a particular set of functions that can be used to pass default or assumed values to scripts, based on the context of the call. For example, it allows us to provide the default database connection name to gateway side scripts, which can differ based on where the call is coming from.

    It is built around a threadlocal. The entity that is executing the scripting call can set any desired values, and then execute the call. Important: after the call, the caller should invoke clear(), in order to erase all settings, preventing any bleedover to other calls on the same thread.

    Although any arbitrary properties can be set on the script context, a few common properties have been defined directly on the class with convenience functions for getting and setting them.

    • Field Detail

      • KEY_DEFAULT_DATASOURCE

        public static final java.lang.String KEY_DEFAULT_DATASOURCE
        See Also:
        Constant Field Values
      • KEY_DEFAULT_TAGPROVIDER

        public static final java.lang.String KEY_DEFAULT_TAGPROVIDER
        See Also:
        Constant Field Values
      • KEY_PARENT_PATH2

        public static final java.lang.String KEY_PARENT_PATH2
        See Also:
        Constant Field Values
      • KEY_DEFAULT_PROJECT

        public static final java.lang.String KEY_DEFAULT_PROJECT
        See Also:
        Constant Field Values
    • Constructor Detail

      • ScriptContext

        public ScriptContext()
    • Method Detail

      • get

        public static java.lang.Object get​(java.lang.String key)
        Gets the value of a key set on the script context. Returns null if the key is not defined.
      • set

        public static void set​(java.lang.String key,
                               java.lang.Object value)
        Sets the value of of a property on the script context.
      • clear

        public static void clear()
        Clears all properties set in the current thread local. Entities using this class should be sure to call this function in a finally block to make sure all settings get cleaned up.
      • isSet

        public static boolean isSet()
      • defaultTagProvider

        public static java.lang.String defaultTagProvider()
      • setDefaultTagProvider

        public static void setDefaultTagProvider​(java.lang.String value)
      • defaultDatasource

        public static java.lang.String defaultDatasource()
      • setDefaultDatasource

        public static void setDefaultDatasource​(java.lang.String value)
      • relativeTagPathRoot

        public static TagPath relativeTagPathRoot()
      • description

        public static java.lang.String description()
      • setDescription

        public static void setDescription​(java.lang.String desc)
      • setRelativeTagPathRoot

        public static void setRelativeTagPathRoot​(TagPath path)
        Sets the root tag path for relative path calculations. Should be the path to the folder which would contain the virtual tag.
      • setDefaultProject

        public static void setDefaultProject​(java.lang.String project)
      • defaultProject

        public static java.lang.String defaultProject()