Extensions and Gremlin

spmallette edited this page May 19, 2011 · 3 revisions

Its possible to write Gremlin based extensions. To do so, you will need to make sure to make use of GMaven in your pom.xml. For example:


Next you can then create a Gremlin-based extension.

@ExtensionNaming(namespace = "ex", name = "gremlinExample")
public class GremlinBasedExtension extends AbstractRexsterExtension {

    static {

    @ExtensionDefinition(extensionPoint = ExtensionPoint.VERTEX)
    @ExtensionDescriptor(description = "Traversal with native Gremlin")
    public ExtensionResponse evaluate(@RexsterContext RexsterResourceContext context,
                                      @RexsterContext Vertex v) {

        JSONObject results = new JSONObject();
        results.put("foaf count", v.out('knows').out('knows').count())
        return ExtensionResponse.ok(results);

NOTE Like all extensions, don’t forget to add the extension’s full class name to your


Please see Deploying an Extension for more details