[prev in list] [next in list] [prev in thread] [next in thread] 

List:       groovy-user
Subject:    [groovy-user] Re: Writing Groovy Closures in Jython?
From:       James Thornton <james () jamesthornton ! com>
Date:       2011-08-22 23:38:12
Message-ID: CANva_A07LauZ1MAuGas-=wugia64dCi3drs9=SbKK_VjEWE2AA () mail ! gmail ! com
[Download RAW message or body]

On Sun, Aug 21, 2011 at 4:51 AM, James Thornton <james@jamesthornton.com> wrote:
> Is it possible to write Groovy closures in any JVM language?
>
> Gremlin (https://github.com/tinkerpop/gremlin/wiki) is a DSL for
> graphs written in Groovy, and I am trying to determine if you can
> write custom Gremlin closures in Jython

Ok, I got this working and created a library that provides an example
for how to create Groovy closures in Jython.

You should be able to adapt it for any JVM language.

The library is called mogwai, and it's on Github
(https://github.com/espeed/mogwai). It shows how to create the Groovy
closure and then how to use it to create a Gremlin step (obviously you
can skip this step if you're not using Gremlin).

Here's the example code:

Jython module:
https://github.com/espeed/mogwai/blob/master/mogwai/steps/jython/Gizmo.py

Java Interface:
https://github.com/espeed/mogwai/blob/master/mogwai/interfaces/GizmoType.java

Java Factory you can reuse for each Jython module:
https://github.com/espeed/mogwai/blob/master/mogwai/factories/JythonFactory.java

Groovy script that create the Gremlin steps:
https://github.com/espeed/mogwai/blob/master/examples/gizmo.groovy

Instructions on how to make this work:
https://github.com/espeed/mogwai/blob/master/README

- James

-- 
Bulbflow: A Python framework for graph databases (http://bulbflow.com)

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic