Package io.deephaven.engine.util
Class GroovyDeephavenSession
- All Implemented Interfaces:
LogOutputAppendable,LivenessManager,LivenessNode,LivenessReferent,ScriptSession,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.SnapshotNested 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
classCacheDirectory, executionContext -
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) getAllValues(@Nullable Function<Object, T> valueMapper, QueryScope.ParamFilter<T> filter) Returns a mutable map with all known variables and their values.groovy.lang.Bindinggroovy.lang.GroovyShellgetShell()protected <T> TgetVariable(String name) Retrieve a variable from the script session's bindings.Retrieves all variable names present in the session's scope.booleanhasExecutedScript(String scriptName) protected booleanhasVariable(String name) Check if the scope has the given variable name.static GroovyDeephavenSessionof(UpdateGraph updateGraph, OperationInitializer operationInitializer, ObjectTypeLookup objectTypeLookup, @Nullable ScriptSession.Listener changeListener, GroovyDeephavenSession.RunScripts runScripts) static GroovyDeephavenSessionof(UpdateGraph updateGraph, OperationInitializer operationInitializer, ObjectTypeLookup objectTypeLookup, GroovyDeephavenSession.RunScripts runScripts) static 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.protected ObjectsetVariable(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, cleanup, createScriptCache, destroy, evaluateScript, evaluateScript, getExecutionContext, getQueryScope, newClassCacheLocation, observeScopeChanges, publishInitialMethods inherited from class io.deephaven.engine.liveness.LivenessArtifact
manageWithCurrentScopeMethods 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, tryManage, tryUnmanage, tryUnmanage, unmanage, unmanageMethods inherited from interface io.deephaven.engine.liveness.LivenessReferent
dropReference, getReferentDescription, getWeakReference, retainReference, tryRetainReferenceMethods inherited from interface io.deephaven.engine.util.ScriptSession
evaluateScript, unwrapObject
-
Field Details
-
SCRIPT_TYPE
- See Also:
-
-
Method Details
-
of
public static GroovyDeephavenSession of(UpdateGraph updateGraph, OperationInitializer operationInitializer, ObjectTypeLookup objectTypeLookup, GroovyDeephavenSession.RunScripts runScripts) throws IOException - Throws:
IOException
-
of
public static GroovyDeephavenSession of(UpdateGraph updateGraph, OperationInitializer operationInitializer, ObjectTypeLookup objectTypeLookup, @Nullable @Nullable ScriptSession.Listener changeListener, GroovyDeephavenSession.RunScripts runScripts) throws IOException - Throws:
IOException
-
findScript
- Throws:
IOException
-
runScript
- Throws:
IOException
-
hasExecutedScript
-
runScriptOnce
- Throws:
IOException
-
getVariable
Description copied from class:AbstractScriptSessionRetrieve a variable from the script session's bindings. Values may need to be unwrapped.- Specified by:
getVariablein classAbstractScriptSession<GroovyDeephavenSession.GroovySnapshot>- Parameters:
name- the name of the variable to retrieve- Returns:
- the variable value
-
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
-
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 class:AbstractScriptSessionRetrieves all variable names present in the session's scope.- Specified by:
getVariableNamesin classAbstractScriptSession<GroovyDeephavenSession.GroovySnapshot>- Returns:
- a caller-owned mutable set of variable names
-
hasVariable
Description copied from class:AbstractScriptSessionCheck if the scope has the given variable name.- Specified by:
hasVariablein classAbstractScriptSession<GroovyDeephavenSession.GroovySnapshot>- Parameters:
name- the variable name- Returns:
- True iff the scope has the given variable name
-
setVariable
Description copied from class:AbstractScriptSessionInserts a value into the script's scope.- Specified by:
setVariablein classAbstractScriptSession<GroovyDeephavenSession.GroovySnapshot>- Parameters:
name- the variable name to setnewValue- the new value of the variable- Returns:
- the old value for this name, if any. As with
AbstractScriptSession.getVariable(String), may need to be unwrapped.
-
getAllValues
protected <T> Map<String,T> getAllValues(@Nullable @Nullable Function<Object, T> valueMapper, @NotNull QueryScope.ParamFilter<T> filter) Description copied from class:AbstractScriptSessionReturns a mutable map with all known variables and their values.Callers may want to pass in a valueMapper of
ScriptSession.unwrapObject(Object)which would unwrap values before filtering. The returned map is owned by the caller.- Specified by:
getAllValuesin classAbstractScriptSession<GroovyDeephavenSession.GroovySnapshot>- Type Parameters:
T- the type of the mapped values- Parameters:
valueMapper- a function to map the valuesfilter- a predicate to filter the map entries- Returns:
- a caller-owned mutable map with all known variables and their mapped values. As with
AbstractScriptSession.getVariable(String), values may need to be unwrapped.
-
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
-