Class ScriptContext

java.lang.Object
com.inductiveautomation.ignition.common.script.ScriptContext

public class ScriptContext extends 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 Details

  • Constructor Details

    • ScriptContext

      public ScriptContext()
  • Method Details

    • get

      public static Object get(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(String key, 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 String defaultTagProvider()
    • setDefaultTagProvider

      public static void setDefaultTagProvider(String value)
    • defaultDatasource

      public static String defaultDatasource()
    • setDefaultDatasource

      public static void setDefaultDatasource(String value)
    • relativeTagPathRoot

      public static TagPath relativeTagPathRoot()
    • description

      public static String description()
    • setDescription

      public static void setDescription(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(String project)
    • defaultProject

      public static String defaultProject()
    • setTagReferenceLocation

      public static void setTagReferenceLocation(com.inductiveautomation.ignition.common.tags.config.model.TagReferenceLocation location)
    • getTagReferenceLocation

      public static com.inductiveautomation.ignition.common.tags.config.model.TagReferenceLocation getTagReferenceLocation()