Package io.deephaven.engine.util
Class DelegatingScriptSession
java.lang.Object
io.deephaven.engine.util.DelegatingScriptSession
- All Implemented Interfaces:
LivenessManager,LivenessNode,LivenessReferent,ReleasableLivenessManager,ScriptSession
The delegating script session delegates all calls to another script session. When evaluating a script it massages the
Changes to the QueryScope so that any modifications that are being seen for the first time by the api-client come
across as new entries and not as modified entries.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.deephaven.engine.util.ScriptSession
ScriptSession.Changes, ScriptSession.Listener -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDrop a previously-retained reference to this referent.evaluateScript(String script, @Nullable String scriptName) Evaluates the script and manages liveness of objects that are exported to the user.evaluateScript(Path scriptPath) Evaluates the script and manages liveness of objects that are exported to the user.Obtain anExecutionContextinstance for the current script session.@NotNull ObjectgetVariable(String name) Retrieve a variable from the script session's bindings.<T> TgetVariable(String name, T defaultValue) Retrieve a variable from the script session's bindings.Retrieves all of the variable names present in the session's scopeAVariableProviderinstance, for services like autocomplete which may want a limited "just the variables" view of our session state.Retrieves all of the variables present in the session's scope (e.g., Groovy binding, Python globals()).WeakReference<? extends LivenessReferent>Get aWeakReferenceto this referent.booleanhasVariableName(String name) Check if the scope has the given variable namevoidObserve (and report viaonScopeChanges) any changes to this ScriptSession'sQueryScopethat may have been made externally, rather than duringscript evaluation.voidrelease()Release ownership of thisReleasableLivenessManager, allowing any retainedLivenessReferents to cleanup if they no longer have outstanding references.voidsetVariable(String name, Object value) Inserts a value into the script's scope.booleantryManage(@NotNull LivenessReferent referent) Attempt to addreferentto this manager.booleanIf this referent is "live", behave asLivenessReferent.retainReference()and return true.booleantryUnmanage(@NotNull LivenessReferent referent) If this node is still live and manages referent one or more times, drop one such reference.booleantryUnmanage(@NotNull Stream<? extends LivenessReferent> referents) For each referent in referents, if this node is still live and manages referent one or more times, drop one such reference.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.deephaven.engine.liveness.LivenessManager
manageMethods inherited from interface io.deephaven.engine.liveness.LivenessNode
unmanage, unmanageMethods inherited from interface io.deephaven.engine.liveness.LivenessReferent
getReferentDescription, retainReferenceMethods inherited from interface io.deephaven.engine.util.ScriptSession
evaluateScript, sanitizeThrowable, unwrapObject
-
Constructor Details
-
DelegatingScriptSession
-
-
Method Details
-
getExecutionContext
Description copied from interface:ScriptSessionObtain anExecutionContextinstance for the current script session. This is the execution context that is used when executing scripts.- Specified by:
getExecutionContextin interfaceScriptSession
-
observeScopeChanges
public void observeScopeChanges()Description copied from interface:ScriptSessionObserve (and report viaonScopeChanges) any changes to this ScriptSession'sQueryScopethat may have been made externally, rather than duringscript evaluation.- Specified by:
observeScopeChangesin interfaceScriptSession
-
getVariable
Description copied from interface:ScriptSessionRetrieve a variable from the script session's bindings. Please useScriptSession.getVariable(String, Object)if you expect the variable may not exist.- Specified by:
getVariablein interfaceScriptSession- Parameters:
name- the variable to retrieve- Returns:
- the variable
- Throws:
QueryScope.MissingVariableException- if the variable does not exist
-
getVariable
Description copied from interface:ScriptSessionRetrieve a variable from the script session's bindings. If the variable is not present, return defaultValue. If the variable is present, but is not of type (T), a ClassCastException may result.- Specified by:
getVariablein interfaceScriptSession- Type Parameters:
T- the type of the variable- Parameters:
name- the variable to retrievedefaultValue- the value to use when no value is present in the session's scope- Returns:
- the value of the variable, or defaultValue if not present
-
getVariableProvider
Description copied from interface:ScriptSessionAVariableProviderinstance, for services like autocomplete which may want a limited "just the variables" view of our session state.- Specified by:
getVariableProviderin interfaceScriptSession- Returns:
- a VariableProvider instance backed by the global/binding context of this script session.
-
evaluateScript
Description copied from interface:ScriptSessionEvaluates the script and manages liveness of objects that are exported to the user. This method should be called from the serial executor as it manipulates static state.- Specified by:
evaluateScriptin interfaceScriptSession- Parameters:
script- the code to executescriptName- an optional script name, which may be ignored by the implementation, or used improve error messages or for other internal purposes- Returns:
- the changes made to the exportable objects
-
evaluateScript
Description copied from interface:ScriptSessionEvaluates the script and manages liveness of objects that are exported to the user. This method should be called from the serial executor as it manipulates static state.- Specified by:
evaluateScriptin interfaceScriptSession- Parameters:
scriptPath- the path to the script to execute- Returns:
- the changes made to the exportable objects
-
getVariables
Description copied from interface:ScriptSessionRetrieves all of the variables present in the session's scope (e.g., Groovy binding, Python globals()).- Specified by:
getVariablesin interfaceScriptSession- Returns:
- an unmodifiable map with variable names as the keys, and the Objects as the result
-
getVariableNames
Description copied from interface:ScriptSessionRetrieves all of the variable names present in the session's scope- Specified by:
getVariableNamesin interfaceScriptSession- Returns:
- an unmodifiable set of variable names
-
hasVariableName
Description copied from interface:ScriptSessionCheck if the scope has the given variable name- Specified by:
hasVariableNamein interfaceScriptSession- Parameters:
name- the variable name- Returns:
- True iff the scope has the given variable name
-
setVariable
Description copied from interface:ScriptSessionInserts a value into the script's scope.- Specified by:
setVariablein interfaceScriptSession- Parameters:
name- the variable name to setvalue- the new value of the variable
-
scriptType
- Specified by:
scriptTypein interfaceScriptSession- Returns:
- a textual description of this script session's language for use in messages.
-
tryManage
Description copied from interface:LivenessManagerAttempt to addreferentto this manager. Will succeed ifreferentis live and if this manager is not aLivenessReferentor is live.- Specified by:
tryManagein interfaceLivenessManager- Parameters:
referent- The referent to add- Returns:
- Whether the referent was in fact added
-
tryUnmanage
Description copied from interface:LivenessNodeIf this node is still live and manages referent one or more times, drop one such reference.- Specified by:
tryUnmanagein interfaceLivenessNode- Parameters:
referent- The referent to drop- Returns:
- Whether this node was live and thus in fact tried to drop a reference
-
tryUnmanage
Description copied from interface:LivenessNodeFor each referent in referents, if this node is still live and manages referent one or more times, drop one such reference.- Specified by:
tryUnmanagein interfaceLivenessNode- Parameters:
referents- The referents to drop- Returns:
- Whether this node was live and thus in fact tried to drop a reference
-
tryRetainReference
public boolean tryRetainReference()Description copied from interface:LivenessReferentIf this referent is "live", behave asLivenessReferent.retainReference()and return true. Otherwise, returns false rather than throwing an exception.- Specified by:
tryRetainReferencein interfaceLivenessReferent- Returns:
- True if this referent was retained, false otherwise
-
dropReference
public void dropReference()Description copied from interface:LivenessReferentDrop a previously-retained reference to this referent.- Specified by:
dropReferencein interfaceLivenessReferent
-
getWeakReference
Description copied from interface:LivenessReferentGet aWeakReferenceto this referent. This may be cached, or newly created.- Specified by:
getWeakReferencein interfaceLivenessReferent- Returns:
- A new or cached reference to this referent
-
release
public void release()Description copied from interface:ReleasableLivenessManagerRelease ownership of thisReleasableLivenessManager, allowing any retainedLivenessReferents to cleanup if they no longer have outstanding references.- Specified by:
releasein interfaceReleasableLivenessManager
-