Wiki

Clone wiki

neo4j-databridge / 9. Plugin architecture

9. Plugin architecture

Plugins are small user-defined scripts written in Groovy that are loaded at runtime and that allow you to customise certain aspects of the importer's behaviour. A typical use for plugins is to perform data conversions, although their use is not limited to this.


The bind() method

Every plugin must define a method bind() which returns an anonymous function (a.k.a closure) implementing the interface 'Plugin.Converter'.


Naming conventions

The plugin's name as used in the schema JSON files is derived from its filename. For example, the core plugin unix_date, is maintained in a file called "unix_date.groovy".


Plugin loading mechanism

When the importer starts up, it loads all the core plugin scripts as well as any custom plugins you have registered yourself and invokes the bind() method on each of them. The Plugins Manager than installs each plugin into the import process as a runtime-compiled component, as described below.


Runtime compilation

The returned closure from the script's bind() method gets wrapped by the Plugins Manager into a runtime-compiled instance of an anonymous class that implements the interface specified by the closure. The loader then maps the name of the plugin (using the script's filename minus its extension as mentioned above) to this compiled implementation. This allows the implementation to be called directly rather than via reflection, which improves performance.

Updated