Specifications
Maintaining global data
The data accessed by these functions is stored in a global repository that is part of the persistent
state of the flow execution engine. Access to the repository is serialized (to avoid conflicts caused
by access in multiple threads) and the contents of the repository persist across invocations of
the flow engine.
It is the script programmer’s responsibility to maintain distinct namespaces for different
applications (including those written by other programmers), and to determine the extent to
which the data is global. This can be accomplished by providing an appropriate value for the
scope argument in the access functions.
The following table lists some examples for the value of the scope argument. The table assumes
that the variable myOrg contains a URI (unique resource identifier) that uniquely identifies the
programmer’s organization, and that myApp contains a string that uniquely identifies the overall
application under consideration (which may involve several cooperating scripts).
The data can be accessed byValue of scope argument
Any script that belongs to this application anywhere in the
execution engine
myOrg + myApp
Any script that belongs to this application and that resides in
the same flow
myOrg + myApp +
Switch.getFlowName()
All copies of this script (even if used in different script elements
in the same flow or in different flows)
myOrg +
Switch.getScriptName()
The copy of this script for this script element (if the same script
is used twice, there is a separate copy of the data for each script
element)
Switch.getFlowName() +
Switch.getElementName()
Sets the value of the global data with the specified scope and tag
to the specified string.
setGlobalData( scope :
String, tag : String, value
: String )
Returns the value of the global data with the specified scope and
tag, or the empty string if no global data with that scope and tag
was set.
getGlobalData(scope :
String, tag : String ) :
String
Acquires a global data lock on the specified scope so that multiple
related get/set operations can be performed in the scope without
lockGlobalData( scope :
String)
interference from other scripts running in concurrent threads. (It is
not necessary to lock global data for a single set or get operation or
for multiple unrelated set and get operations).
This function blocks until the requested lock can be obtained.
A script can acquire only a single lock at a time, that is, nested locks
are not allowed. While a lock is in effect, the script is allowed to
access global data only in the scope on which a lock was acquired.
Acquiring a nested lock (even on the same scope) or accessing data
outside of the locked scope has undefined (and almost certainly
undesirable) results.
451
Enfocus Switch 10