Class GremlinLangScriptEngine
- java.lang.Object
- 
- javax.script.AbstractScriptEngine
- 
- org.apache.tinkerpop.gremlin.jsr223.GremlinLangScriptEngine
 
 
- 
- All Implemented Interfaces:
- ScriptEngine,- GremlinScriptEngine
 
 public class GremlinLangScriptEngine extends AbstractScriptEngine implements GremlinScriptEngine AGremlinScriptEngineimplementation that evaluates Gremlin scripts usinggremlin-language. As it usesgremlin-languageand thus the ANTLR parser, it is not capable of process arbitrary scripts as theGremlinGroovyScriptEnginecan and is therefore a more secure Gremlin evaluator. It is obviously restricted to the capabilities of the ANTLR grammar so therefore syntax that includes things like lambdas are not supported. For bytecode evaluation it simply uses theJavaTranslator. As an internal note, technically, this is an incomplete implementation of theGremlinScriptEnginein the traditional sense as a drop-in replacement for something like theGremlinGroovyScriptEngine. As a result, thisGremlinScriptEnginecannot pass theGremlinScriptEngineSuitetests in full. On the other hand, this limitation is precisely what makes this implementation better from a security perspective. Ultimately, this implementation represents the first step to changes in what it means to have aGremlinScriptEngine. In some sense, there is question why aGremlinScriptEngineapproach is necessary at all except for easily plugging into the existing internals of Gremlin Server or more specifically theGremlinExecutor.
- 
- 
Field Summary- 
Fields inherited from class javax.script.AbstractScriptEnginecontext
 - 
Fields inherited from interface org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineHIDDEN_G
 - 
Fields inherited from interface javax.script.ScriptEngineARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME
 
- 
 - 
Constructor SummaryConstructors Constructor Description GremlinLangScriptEngine()Creates a new instance using noCustomizer.GremlinLangScriptEngine(Customizer... customizers)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description BindingscreateBindings()Objecteval(Reader reader, ScriptContext context)Objecteval(String script, ScriptContext context)Gremlin scripts evaluated by the grammar must be bound to "g" and should evaluate to a "g" in theScriptContextthat is of typeTraversalSourceTraversal.Admineval(Bytecode bytecode, Bindings bindings, String traversalSource)Bytecode is evaluated by theJavaTranslator.GremlinScriptEngineFactorygetFactory()protected ScriptContextgetScriptContext(Bindings nn)Creates theScriptContextusing aGremlinScriptContextwhich avoids a significant amount of additional object creation on script evaluation.- 
Methods inherited from class javax.script.AbstractScriptEngineeval, eval, eval, eval, get, getBindings, getContext, put, setBindings, setContext
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineeval
 - 
Methods inherited from interface javax.script.ScriptEngineeval, eval, eval, eval, get, getBindings, getContext, put, setBindings, setContext
 
- 
 
- 
- 
- 
Constructor Detail- 
GremlinLangScriptEnginepublic GremlinLangScriptEngine() Creates a new instance using noCustomizer.
 - 
GremlinLangScriptEnginepublic GremlinLangScriptEngine(Customizer... customizers) 
 
- 
 - 
Method Detail- 
getFactorypublic GremlinScriptEngineFactory getFactory() - Specified by:
- getFactoryin interface- GremlinScriptEngine
- Specified by:
- getFactoryin interface- ScriptEngine
 
 - 
evalpublic Traversal.Admin eval(Bytecode bytecode, Bindings bindings, String traversalSource) throws ScriptException Bytecode is evaluated by theJavaTranslator.- Specified by:
- evalin interface- GremlinScriptEngine
- Throws:
- ScriptException
 
 - 
evalpublic Object eval(String script, ScriptContext context) throws ScriptException Gremlin scripts evaluated by the grammar must be bound to "g" and should evaluate to a "g" in theScriptContextthat is of typeTraversalSource- Specified by:
- evalin interface- ScriptEngine
- Throws:
- ScriptException
 
 - 
evalpublic Object eval(Reader reader, ScriptContext context) throws ScriptException - Specified by:
- evalin interface- ScriptEngine
- Throws:
- ScriptException
 
 - 
createBindingspublic Bindings createBindings() - Specified by:
- createBindingsin interface- ScriptEngine
 
 - 
getScriptContextprotected ScriptContext getScriptContext(Bindings nn) Creates theScriptContextusing aGremlinScriptContextwhich avoids a significant amount of additional object creation on script evaluation.- Overrides:
- getScriptContextin class- AbstractScriptEngine
 
 
- 
 
-