Skip to content

Factories and Modules

Bryn Cooke edited this page Nov 4, 2013 · 5 revisions

Factories

To obtain a framed graph use a FramedGraphFactory.

FramedGraphFactory factory = new FramedGraphFactory();
FramedGraph framedGraph = factory.create(baseGraph);

TransactionalFramedGraph can be created from a TransactionalGraph
FramedGraphFactory factory = new FramedGraphFactory();
TransactionalFramedGraph transactionalFramedGraph = factory.create(baseTransactionalGraph);

A factory should be reused to create many graphs. Under the hood it may share resources between graphs where appropriate. This can make a big difference to performance and memory footprint.

Modules

Modules are used to extend the capability of FramedGraph. They are registered in the constructor of the FramedGraphFactory.

In this example the framed graph will now support the @GremlinGroovy annotation on frames.

FramedGraphFactory factory = new FramedGraphFactory(new GremlinGroovyModule());
FramedGraph framedGraph = factory.create(baseGraph);

Any number of modules can be added to the factory, but a FramedGraph will always support the Core Annotations.
Clone this wiki locally