Skip to content

Instantly share code, notes, and snippets.

@okram
Created May 1, 2013 20:07
Show Gist options
  • Save okram/5497959 to your computer and use it in GitHub Desktop.
Save okram/5497959 to your computer and use it in GitHub Desktop.
@ExtensionNaming(namespace = "egosystem", name = "faunus")
class FaunusExtension extends AbstractRexsterExtension {
private static FaunusGremlinScriptEngine engine = new FaunusGremlinScriptEngine();
static {
Configuration configuration = new Configuration();
Properties properties = new Properties();
properties.load(FaunusExtension.class.getResourceAsStream("titan-cassandra-input.properties"));
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
configuration.set(entry.getKey().toString(), entry.getValue().toString());
}
FaunusGraph graph = new FaunusGraph(configuration);
engine.put("g", graph);
}
@ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, method = HttpMethod.GET)
@ExtensionDescriptor(description = "Execute a discovery algorithm")
public ExtensionResponse evaluate(@RexsterContext RexsterResourceContext context,
@RexsterContext Graph g) {
((FaunusPipeline) engine.eval((String) context.getRequestObject().get('script'))).submit();
return ExtensionResponse.ok(new JSONObject("{ 'status' : 'done' }"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment