Class ScriptContext
- java.lang.Object
-
- com.inductiveautomation.ignition.common.script.ScriptContext
-
public class ScriptContext extends java.lang.ObjectThe 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 Summary
Fields Modifier and Type Field Description static java.lang.StringKEY_DEFAULT_DATASOURCEstatic java.lang.StringKEY_DEFAULT_PROJECTstatic java.lang.StringKEY_DEFAULT_TAGPROVIDERstatic java.lang.StringKEY_DESCRIPTIONstatic java.lang.StringKEY_PARENT_PATHstatic java.lang.StringKEY_PARENT_PATH2
-
Constructor Summary
Constructors Constructor Description ScriptContext()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclear()Clears all properties set in the current thread local.static java.lang.StringdefaultDatasource()static java.lang.StringdefaultProject()static java.lang.StringdefaultTagProvider()static java.lang.Stringdescription()static java.lang.Objectget(java.lang.String key)Gets the value of a key set on the script context.static booleanisSet()static TagPathrelativeTagPathRoot()static voidset(java.lang.String key, java.lang.Object value)Sets the value of of a property on the script context.static voidsetDefaultDatasource(java.lang.String value)static voidsetDefaultProject(java.lang.String project)static voidsetDefaultTagProvider(java.lang.String value)static voidsetDescription(java.lang.String desc)static voidsetRelativeTagPathRoot(TagPath path)Sets the root tag path for relative path calculations.
-
-
-
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_PATH
public static final java.lang.String KEY_PARENT_PATH
- 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
-
KEY_DESCRIPTION
public static final java.lang.String KEY_DESCRIPTION
- See Also:
- Constant Field Values
-
-
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()
-
-