Class DelegatingScriptSession

java.lang.Object
io.deephaven.engine.util.DelegatingScriptSession
All Implemented Interfaces:
LivenessManager, LivenessNode, LivenessReferent, ReleasableLivenessManager, ScriptSession

public class DelegatingScriptSession extends Object implements 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.
  • Constructor Details

    • DelegatingScriptSession

      public DelegatingScriptSession(ScriptSession delegate)
  • Method Details

    • getExecutionContext

      public ExecutionContext getExecutionContext()
      Description copied from interface: ScriptSession
      Obtain an ExecutionContext instance for the current script session. This is the execution context that is used when executing scripts.
      Specified by:
      getExecutionContext in interface ScriptSession
    • observeScopeChanges

      public void observeScopeChanges()
      Description copied from interface: ScriptSession
      Observe (and report via onScopeChanges) any changes to this ScriptSession's QueryScope that may have been made externally, rather than during script evaluation.
      Specified by:
      observeScopeChanges in interface ScriptSession
    • getVariable

      @NotNull public @NotNull Object getVariable(String name) throws QueryScope.MissingVariableException
      Description copied from interface: ScriptSession
      Retrieve a variable from the script session's bindings.

      Please use ScriptSession.getVariable(String, Object) if you expect the variable may not exist.

      Specified by:
      getVariable in interface ScriptSession
      Parameters:
      name - the variable to retrieve
      Returns:
      the variable
      Throws:
      QueryScope.MissingVariableException - if the variable does not exist
    • getVariable

      public <T> T getVariable(String name, T defaultValue)
      Description copied from interface: ScriptSession
      Retrieve 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:
      getVariable in interface ScriptSession
      Type Parameters:
      T - the type of the variable
      Parameters:
      name - the variable to retrieve
      defaultValue - 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

      public VariableProvider getVariableProvider()
      Description copied from interface: ScriptSession
      A VariableProvider instance, for services like autocomplete which may want a limited "just the variables" view of our session state.
      Specified by:
      getVariableProvider in interface ScriptSession
      Returns:
      a VariableProvider instance backed by the global/binding context of this script session.
    • evaluateScript

      public ScriptSession.Changes evaluateScript(String script, @Nullable @Nullable String scriptName)
      Description copied from interface: ScriptSession
      Evaluates 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:
      evaluateScript in interface ScriptSession
      Parameters:
      script - the code to execute
      scriptName - 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

      public ScriptSession.Changes evaluateScript(Path scriptPath)
      Description copied from interface: ScriptSession
      Evaluates 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:
      evaluateScript in interface ScriptSession
      Parameters:
      scriptPath - the path to the script to execute
      Returns:
      the changes made to the exportable objects
    • getVariables

      public Map<String,Object> getVariables()
      Description copied from interface: ScriptSession
      Retrieves all of the variables present in the session's scope (e.g., Groovy binding, Python globals()).
      Specified by:
      getVariables in interface ScriptSession
      Returns:
      an unmodifiable map with variable names as the keys, and the Objects as the result
    • getVariableNames

      public Set<String> getVariableNames()
      Description copied from interface: ScriptSession
      Retrieves all of the variable names present in the session's scope
      Specified by:
      getVariableNames in interface ScriptSession
      Returns:
      an unmodifiable set of variable names
    • hasVariableName

      public boolean hasVariableName(String name)
      Description copied from interface: ScriptSession
      Check if the scope has the given variable name
      Specified by:
      hasVariableName in interface ScriptSession
      Parameters:
      name - the variable name
      Returns:
      True iff the scope has the given variable name
    • setVariable

      public void setVariable(String name, Object value)
      Description copied from interface: ScriptSession
      Inserts a value into the script's scope.
      Specified by:
      setVariable in interface ScriptSession
      Parameters:
      name - the variable name to set
      value - the new value of the variable
    • scriptType

      public String scriptType()
      Specified by:
      scriptType in interface ScriptSession
      Returns:
      a textual description of this script session's language for use in messages.
    • tryManage

      public boolean tryManage(@NotNull @NotNull LivenessReferent referent)
      Description copied from interface: LivenessManager
      Attempt to add referent to this manager. Will succeed if referent is live and if this manager is not a LivenessReferent or is live.
      Specified by:
      tryManage in interface LivenessManager
      Parameters:
      referent - The referent to add
      Returns:
      Whether the referent was in fact added
    • tryUnmanage

      public boolean tryUnmanage(@NotNull @NotNull LivenessReferent referent)
      Description copied from interface: LivenessNode
      If this node is still live and manages referent one or more times, drop one such reference.
      Specified by:
      tryUnmanage in interface LivenessNode
      Parameters:
      referent - The referent to drop
      Returns:
      Whether this node was live and thus in fact tried to drop a reference
    • tryUnmanage

      public boolean tryUnmanage(@NotNull @NotNull Stream<? extends LivenessReferent> referents)
      Description copied from interface: LivenessNode
      For each referent in referents, if this node is still live and manages referent one or more times, drop one such reference.
      Specified by:
      tryUnmanage in interface LivenessNode
      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: LivenessReferent
      If this referent is "live", behave as LivenessReferent.retainReference() and return true. Otherwise, returns false rather than throwing an exception.
      Specified by:
      tryRetainReference in interface LivenessReferent
      Returns:
      True if this referent was retained, false otherwise
    • dropReference

      public void dropReference()
      Description copied from interface: LivenessReferent
      Drop a previously-retained reference to this referent.
      Specified by:
      dropReference in interface LivenessReferent
    • getWeakReference

      public WeakReference<? extends LivenessReferent> getWeakReference()
      Description copied from interface: LivenessReferent
      Get a WeakReference to this referent. This may be cached, or newly created.
      Specified by:
      getWeakReference in interface LivenessReferent
      Returns:
      A new or cached reference to this referent
    • release

      public void release()
      Description copied from interface: ReleasableLivenessManager
      Release ownership of this ReleasableLivenessManager, allowing any retained LivenessReferents to cleanup if they no longer have outstanding references.
      Specified by:
      release in interface ReleasableLivenessManager