RE: GremlinGroovyScriptEngine

30 views
Skip to first unread message

Pieter Martin

unread,
Apr 21, 2014, 7:16:49 AM4/21/14
to gremli...@googlegroups.com
Hi,

I am using gremlin's GremlinGroovyScriptEngine in my application.

However I would like to use the groovy scripting feature of setting a base script class.
This is done on the CompilerConfiguration class.

Currently this object is not accessible in GremlinGroovyScriptEngine. I have, for now copied your implementation adding in

    public UmlgGremlinGroovyScriptEngine(final String scriptBaseClass, final ImportCustomizerProvider importCustomizerProvider) {
        Gremlin.load();
        final CompilerConfiguration conf = new CompilerConfiguration();
        conf.setScriptBaseClass(scriptBaseClass);
        conf.addCompilationCustomizers(importCustomizerProvider.getImportCustomizer());
        this.loader = new GroovyClassLoader(getParentLoader(), conf);
    }

Is it possible to refactor GremlinGroovyScriptEngine a tad to allow users to set the ScriptBaseClass ?

Thanks
Pieter

Stephen Mallette

unread,
Apr 21, 2014, 7:46:16 AM4/21/14
to gremli...@googlegroups.com
I would think so.  I could see that being useful. Is it possible for you to provide a pull request for that?  If not, please create an issue in Github.


--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marko Rodriguez

unread,
Apr 21, 2014, 9:01:36 AM4/21/14
to gremli...@googlegroups.com
Hi,

What dose the "baseScriptClass" do?

Marko.

Pieter Martin

unread,
Apr 21, 2014, 9:11:48 AM4/21/14
to gremli...@googlegroups.com
Hi,

Its a place to put generic groovy stuff that will be available to the scripting engine.
I'll push a pull request shortly.

My particular usecase is to filter out soft deleted vertexes from g.V
I can do this with a groovy interceptor. For groovy interceptors I need to define,

    def useInterceptor= { Class theClass, Class theInterceptor, Closure theCode->
        def proxy= ProxyMetaClass.getInstance( theClass )
        def interceptor= theInterceptor.newInstance()
        proxy.interceptor= interceptor
        proxy.use( theCode )
    }

It seemed to me the best place to put this is in the base script.

If there is a better way then I am all ears.

Thanks
Pieter

Stephen Mallette

unread,
Apr 21, 2014, 9:13:36 AM4/21/14
to gremli...@googlegroups.com
see the "Evaluate Scripts with a Common Base Class" section here:

http://groovy.codehaus.org/Embedding+Groovy

Pieter Martin

unread,
Apr 21, 2014, 9:20:12 AM4/21/14
to gremli...@googlegroups.com
Ok, I created the pull request. It includes a test case that uses the script base class for my interceptor vibe.
Regards
Pieter
Reply all
Reply to author
Forward
0 new messages