Class ScriptContext
java.lang.Object
com.inductiveautomation.ignition.common.script.ScriptContext
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
clear()
Clears all properties set in the current thread local.static String
static String
static String
static String
static Object
Gets the value of a key set on the script context.static com.inductiveautomation.ignition.common.tags.config.model.TagReferenceLocation
static boolean
isSet()
static TagPath
static void
Sets the value of of a property on the script context.static void
setDefaultDatasource
(String value) static void
setDefaultProject
(String project) static void
setDefaultTagProvider
(String value) static void
setDescription
(String desc) static void
Sets the root tag path for relative path calculations.static void
setTagReferenceLocation
(com.inductiveautomation.ignition.common.tags.config.model.TagReferenceLocation location)
-
Field Details
-
KEY_DEFAULT_DATASOURCE
- See Also:
-
KEY_DEFAULT_TAGPROVIDER
- See Also:
-
KEY_PARENT_PATH
- See Also:
-
KEY_PARENT_PATH2
- See Also:
-
KEY_DEFAULT_PROJECT
- See Also:
-
KEY_DESCRIPTION
- See Also:
-
KEY_TAG_REFERENCE_LOCATION
- See Also:
-
-
Constructor Details
-
ScriptContext
public ScriptContext()
-
-
Method Details
-
get
Gets the value of a key set on the script context. Returns null if the key is not defined. -
set
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
-
setDefaultTagProvider
-
defaultDatasource
-
setDefaultDatasource
-
relativeTagPathRoot
-
description
-
setDescription
-
setRelativeTagPathRoot
Sets the root tag path for relative path calculations. Should be the path to the folder which would contain the virtual tag. -
setDefaultProject
-
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()
-