I've been doing a bit of work on the TINKERPOP-1278 branch and have been
mostly focused on generalizing/expanding the ScriptEngine infrastructure to
gremlin-core. Seems like a weird place for ScriptEngine stuff to live as
we've largely relegated such things to gremlin-groovy, but now that there
are GLVs ScriptEngines have a role to play there that is core to TinkerPop
and we rely on ScriptEngine instances in gremlin-core itself and as a
result, it doesn't work too well if important aspects of ScriptEngines are
left to gremlin-groovy.

The first important concept introduced in this work is the notion of a
Gremlin-enabled ScriptEngine. Up until this point, the
GremlinGroovyScriptEngine was just another ScriptEngine implementation,
meaning that when loading it through the ScriptEngineManager, you got
gremlin-groovy, nashorn, jython, etc. I've now established a separate
GremlinScriptEngineManager:

https://github.com/apache/tinkerpop/blob/073910598b8840a8e25f072371b304af322324f5/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineManager.java

This class very closely mimics the java ScriptEngineManager, but it only
loads Gremlin-enabled ScriptEngine instance. It is worth noting that the
java ScriptEngineManager will no longer load GremlinGroovyScriptEngine. As
a result, I've removed "nashorn" from all the Gremlin Server config files
as it creates errors otherwise.

Now a Gremlin-enabled ScriptEngine is one that implements this interface
(which is what makes it different than a regular java ScriptEngine):

https://github.com/apache/tinkerpop/blob/073910598b8840a8e25f072371b304af322324f5/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngine.java

I'm not sure that this will be the the final look of the interface, but
just know that it's there. I also introduced the concept of a Customizer:

https://github.com/apache/tinkerpop/blob/073910598b8840a8e25f072371b304af322324f5/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/Customizer.java

which is similar to the concept of a groovy CompilerCustomizer and allows
us to provide a general way to supply configurations across all
ScriptEngines (even those that are less robust that the groovy script
engine).

Gremlin Server is hooked up against all these changes at this point. The
branch currently passes all integration tests so stuff appears to be
working nicely. I did have to @Ignore a few unit tests because they used
Nashorn and I was not sure of how to rectify that (tests  probably just
need to move elsewhere - I've made a note to come back to deal with that
along with a whole ton of other notes - consider this a work in progress
atm).

Doing this work without breaking change has been hard as ScripEngine
infrastructure is so critical to the upper end of the stack with both the
console and gremlin server.  I suspect that for 3.3.x there will be a wide
batch of breaking change a'comin' to get this right.

Thoughts/questions?

Reply via email to