Hi all,

  We are using the @GremlinDsl annotation to extend the Gremlin language into 
our own DSL.   I’ve run into two issues with anonymous traversals so far that 
I’d like to bring up.  One has a work-around, the other, I have not yet found a 
work-around.

First (the one with the work-around):  The <DSL>TraversalSource class that is 
generated does not override the ‘getAnonymousTraversalClass()’ method of 
GraphTraversalSource, so the returned class is 
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__   rather than the 
auto-generated, DSL-specific version of ‘__’.    This can be worked around by 
specifying your own base class that implementes ‘getAnonymousTraversalClass()’. 
  However, this still requires some oddities, as the code generator interprets 
the method as a method to be auto-generated.   My solution was to create two 
levels of inheritance:

  1.  MyDSLTraversalSourceDsl0 extends GraphTraversalSource, and implements 
‘getAnonymousTraversalClass()’
  2.  MyDSLTraversalSourceDsl1 extends MyDSLTraversalSourceDsl0, but does 
nothing else
  3.  MyDSLTraversalDSL extends GraphTRaversal.Admin<S,E>, and uses the 
@GremlinDsl(traversalSource = “MyDSLTraversalDSL1”)



The second issue, for which I have not yet found a work-around, is that when 
using the Gremlin-Groovy scriptEngine as a Gremlin Server, and sending 
“gremlin” to the server (rather than bytecode), anonymous traversals do not 
find my DSL’s implementation of __, but rather the TinkerPop __.     I’ve added 
my ‘__’ to the ImportGremlinPlugin’s classImports.  This is sufficient for 
sending bytecode and having my __ found.   However, when sending “gremlin” to 
the Session Processor, with “eval” as the OP, the groovy class cache finds 
TinkerPop’s __ rather than my __.    This is appears to be because in 
GremlinGroovyScriptEngine, the CoreGremlinPlugin’s customizers get added last 
to the list of ImportCustomizers.  As it is processed last, when building the 
map of class names to fully-qualified class names, the Gremlin ‘__’ key 
overwrites the ‘__’ key which was specified to be imported in the server’s 
YAML.   I also came across an interesting comment in ‘ImportGroovyCustomizer’ 
which forces an import of Tinkerpop’s ‘__’ as well.

It's quite possible that I’m missing something, if so, could you please point 
me to how one is supposed to enable a custom DSL with the Gremlin-Groovy script 
engine?

Thanks much,

  *   Branden

Reply via email to