You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Fred Eisele <fr...@gmail.com> on 2022/01/31 18:19:57 UTC

Dynamic Loading of Other Groovy Functions

I have a driver class (currently written in python) that

·       reads a csv file of command records which describe functions, the
driver

·       loads groovy functions (as text strings)

·       the driver edits (textually) the groovy functions to add parameters

·       passes that groovy command to a database server (gremlin-server) which

·       processes the request and

·       returns the result.  
  

I would like to make a few changes to this process.

  * replace python driver with a groovy script (python gremlin driver is missing some features)
  * dynamically load the groovy functions (not as text strings)
  * communicate with the database server in the binary format (not as text)



To do this I need to know…

Is possible to dynamically load groovy scripts?  
  
e.g. if I have a groovy script ‘foo.groovy’ and a variable `x = ‘foo’` can I
use the variable `x` to invoke a function in `foo.groovy`?  
I know I can run `foo.groovy`.execute() as a separate process but I need to
capture the result, plus I do not want to incur the added computational cost.

  
  
  


Re: Dynamic Loading of Other Groovy Functions

Posted by Guillaume Laforge <gl...@gmail.com>.
Hi Fred,

You might want to have a look at the documentation, in particular this
section:
https://docs.groovy-lang.org/docs/latest/html/documentation/#_integrating_groovy_in_a_java_application

It covers the various ways of integrating Groovy.
There are different mechanisms available, you should find one that suit
your needs.

Guillaume


On Mon, Jan 31, 2022 at 7:20 PM Fred Eisele <fr...@gmail.com>
wrote:

> I have a driver class (currently written in python) that
>
> ·       reads a csv file of command records which describe functions, the
> driver
>
> ·       loads groovy functions (as text strings)
>
> ·       the driver edits (textually) the groovy functions to add
> parameters
>
> ·       passes that groovy command to a database server (gremlin-server)
> which
>
> ·       processes the request and
>
> ·       returns the result.
>
> I would like to make a few changes to this process.
>
>    - replace python driver with a groovy script (python gremlin driver is
>    missing some features)
>    - dynamically load the groovy functions (not as text strings)
>    - communicate with the database server in the binary format (not as
>    text)
>
>
>
> To do this I need to know…
>
> Is possible to dynamically load groovy scripts?
>
> e.g. if I have a groovy script ‘foo.groovy’ and a variable `x = ‘foo’` can
> I use the variable `x` to invoke a function in `foo.groovy`?
> I know I can run `foo.groovy`.execute() as a separate process but I need
> to capture the result, plus I do not want to incur the added computational
> cost.
>
>
>
>
>

-- 
Guillaume Laforge
Apache Groovy committer
Developer Advocate @ Google Cloud Platform

Blog: http://glaforge.appspot.com/
Twitter: @glaforge <http://twitter.com/glaforge>