Package io.deephaven.engine.util
Class GroovyDeephavenSession
- All Implemented Interfaces:
LogOutputAppendable,LivenessManager,LivenessNode,LivenessReferent,ReleasableLivenessManager,ScriptSession,VariableProvider,Serializable
public class GroovyDeephavenSession
extends AbstractScriptSession<GroovyDeephavenSession.GroovySnapshot>
Groovy
ScriptSession. Not safe for concurrent use.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic interfaceRepresents an import that can be added to an ImportCustomizer, as a valid return fromcreateImport(String).protected static classstatic interfacestatic classNested classes/interfaces inherited from class io.deephaven.engine.util.AbstractScriptSession
AbstractScriptSession.ScriptSessionQueryScope, AbstractScriptSession.Snapshot, AbstractScriptSession.SynchronizedScriptSessionQueryScope, AbstractScriptSession.UnsynchronizedScriptSessionQueryScopeNested classes/interfaces inherited from interface io.deephaven.engine.util.ScriptSession
ScriptSession.Changes, ScriptSession.Listener -
Field Summary
FieldsFields inherited from class io.deephaven.engine.util.AbstractScriptSession
executionContext -
Constructor Summary
ConstructorsConstructorDescriptionGroovyDeephavenSession(UpdateGraph updateGraph, OperationInitializer operationInitializer, ObjectTypeLookup objectTypeLookup, @Nullable ScriptSession.Listener changeListener, GroovyDeephavenSession.RunScripts runScripts) GroovyDeephavenSession(UpdateGraph updateGraph, OperationInitializer operationInitializer, ObjectTypeLookup objectTypeLookup, GroovyDeephavenSession.RunScripts runScripts) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddScriptImportClass(Class<?> c) voidvoidaddScriptImportStatic(Class<?> c) voidprotected ScriptSession.ChangescreateDiff(GroovyDeephavenSession.GroovySnapshot from, GroovyDeephavenSession.GroovySnapshot to, RuntimeException e) createImport(String importString) Ensure that the given importString is valid.protected GroovyDeephavenSession.GroovySnapshotprotected voidEvaluates command in the context of the current ScriptSession.static InputStreamfindScript(String relativePath) groovy.lang.Bindingstatic byte[]getDynamicClass(String name) groovy.lang.GroovyShellgetShell()@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 scopeRetrieves all of the variables present in the session's scope (e.g., Groovy binding, Python globals()).booleanhasExecutedScript(String scriptName) booleanhasVariableName(String name) Check if the scope has the given variable namestatic StringRemove comments from an import statement.voidvoidrunScriptOnce(String script) If this script session can throw unserializable exceptions, this method is responsible for turning those exceptions into something suitable for sending back to a client.voidsetVariable(String name, @Nullable Object newValue) Inserts a value into the script's scope.protected GroovyDeephavenSession.GroovySnapshotMethods inherited from class io.deephaven.engine.util.AbstractScriptSession
applyVariableChangeToDiff, createScriptCache, destroy, evaluateScript, evaluateScript, getExecutionContext, getTableDefinition, getVariableProvider, getVariableType, observeScopeChanges, publishInitialMethods inherited from class io.deephaven.engine.liveness.LivenessScope
release, transferToMethods inherited from class io.deephaven.engine.liveness.ReferenceCountedLivenessNode
getWeakReference, initializeTransientFieldsForLiveness, onReferenceCountAtZero, tryManage, tryUnmanage, tryUnmanageMethods inherited from class io.deephaven.engine.liveness.ReferenceCountedLivenessReferent
dropReference, tryRetainReferenceMethods inherited from class io.deephaven.util.referencecounting.ReferenceCounted
append, decrementReferenceCount, forceReferenceCountToZero, getReferenceCountDebug, incrementReferenceCount, resetReferenceCount, toString, tryDecrementReferenceCount, tryIncrementReferenceCountMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.deephaven.engine.liveness.LivenessManager
manage, tryManageMethods inherited from interface io.deephaven.engine.liveness.LivenessNode
tryUnmanage, tryUnmanage, unmanage, unmanageMethods inherited from interface io.deephaven.engine.liveness.LivenessReferent
dropReference, getReferentDescription, getWeakReference, retainReference, tryRetainReferenceMethods inherited from interface io.deephaven.engine.liveness.ReleasableLivenessManager
releaseMethods inherited from interface io.deephaven.engine.util.ScriptSession
evaluateScript, unwrapObject
-
Field Details
-
SCRIPT_TYPE
- See Also:
-
-
Constructor Details
-
GroovyDeephavenSession
public GroovyDeephavenSession(UpdateGraph updateGraph, OperationInitializer operationInitializer, ObjectTypeLookup objectTypeLookup, GroovyDeephavenSession.RunScripts runScripts) throws IOException - Throws:
IOException
-
GroovyDeephavenSession
public GroovyDeephavenSession(UpdateGraph updateGraph, OperationInitializer operationInitializer, ObjectTypeLookup objectTypeLookup, @Nullable @Nullable ScriptSession.Listener changeListener, GroovyDeephavenSession.RunScripts runScripts) throws IOException - Throws:
IOException
-
-
Method Details
-
newQueryScope
- Specified by:
newQueryScopein classAbstractScriptSession<GroovyDeephavenSession.GroovySnapshot>- Returns:
- a query scope for this session; only invoked during construction
-
findScript
- Throws:
IOException
-
runScript
- Throws:
IOException
-
hasExecutedScript
-
runScriptOnce
- Throws:
IOException
-
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.- 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.- 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
-
evaluate
Description copied from class:AbstractScriptSessionEvaluates command in the context of the current ScriptSession.- Specified by:
evaluatein classAbstractScriptSession<GroovyDeephavenSession.GroovySnapshot>- Parameters:
command- the command to evaluatescriptName- an optional script name, which may be ignored by the implementation, or used improve error messages or for other internal purposes
-
removeComments
Remove comments from an import statement. /* comments take precedence over eol (//) comments. This ignores escaping and quoting, as they are not valid in an import statement.- Parameters:
s- import statement string from which to remove comments- Returns:
- the input string with comments removed, and whitespace trimmed
-
createImport
@VisibleForTesting public Optional<GroovyDeephavenSession.GroovyImport> createImport(String importString) Ensure that the given importString is valid. Return a canonical version of the import string if it is valid.- Parameters:
importString- the string to check. importString is "[import] [static] package.class[.innerclass...][.field|.method][.*][;]".- Returns:
- null if importString is not valid, else a string of the form "import [static] package.class.part.part[.*];"
-
addScriptImportClass
-
addScriptImportClass
-
addScriptImportStatic
-
addScriptImportStatic
-
getDynamicClass
-
getVariables
Description copied from interface:ScriptSessionRetrieves all of the variables present in the session's scope (e.g., Groovy binding, Python globals()).- Returns:
- an unmodifiable map with variable names as the keys, and the Objects as the result
-
emptySnapshot
- Specified by:
emptySnapshotin classAbstractScriptSession<GroovyDeephavenSession.GroovySnapshot>
-
takeSnapshot
- Specified by:
takeSnapshotin classAbstractScriptSession<GroovyDeephavenSession.GroovySnapshot>
-
createDiff
protected ScriptSession.Changes createDiff(GroovyDeephavenSession.GroovySnapshot from, GroovyDeephavenSession.GroovySnapshot to, RuntimeException e) - Specified by:
createDiffin classAbstractScriptSession<GroovyDeephavenSession.GroovySnapshot>
-
getVariableNames
Description copied from interface:ScriptSessionRetrieves all of the variable names present in the session's scope- Returns:
- an unmodifiable set of variable names
-
hasVariableName
Description copied from interface:ScriptSessionCheck if the scope has the given variable name- 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.- Parameters:
name- the variable name to setnewValue- the new value of the variable
-
getBinding
public groovy.lang.Binding getBinding() -
getShell
public groovy.lang.GroovyShell getShell() -
scriptType
- Returns:
- a textual description of this script session's language for use in messages.
-
sanitizeThrowable
Description copied from interface:ScriptSessionIf this script session can throw unserializable exceptions, this method is responsible for turning those exceptions into something suitable for sending back to a client.- Parameters:
e- the exception to (possibly) sanitize- Returns:
- the sanitized exception
-