Skip to end of metadata
Go to start of metadata


The Riak plugin enables lightweight access to database functionality using riak. This plugin does NOT provide domain classes nor dynamic finders like GORM does.


The current version of griffon-riak is 0.3
To install just issue the following command


Upon installation the plugin will generate the following artifacts at $appdir/griffon-app/conf:

  • RiakConfig.groovy - contains the datasource definition.
  • BootstrapRiak.groovy - defines init/destroy hooks for data to be manipulated during app startup/shutdown.

A new dynamic method named withRiak will be injected into all controllers, giving you access to a com.basho.riak.client.RiakClient object, with which you'll be able to make calls to the database. Remember to make all calls to the database off the EDT otherwise your application may appear unresponsive when doing long computations inside the EDT.
This method is aware of multiple datasources. If no datasourceName is specified when calling it then the default dataSource will be selected. Here are two example usages, the first queries against the default datasource while the second queries a datasource whose name has been configured as 'internal'

This method is also accessible to any component through the singleton griffon.plugins.riak.RiakConnector. You can inject these methods to non-artifacts via metaclasses. Simply grab hold of a particular metaclass and call RiakConnector.enhance(metaClassInstance).


Dynamic method injection

The withRiak() dynamic method will be added to controllers by default. You can change this setting by adding a configuration flag in Config.groovy


The following events will be triggered by this addon

  • RiakConnectStart[config, clientName] - triggered before connecting to the datastore
  • RiakConnectEnd[clientName, riakClient] - triggered after connecting to the datastore
  • RiakDisconnectStart[config, clientName, riakClient] - triggered before disconnecting from the datastore
  • RiakDisconnectEnd[config, clientName] - triggered after disconnecting from the datastore

Multiple DataSources

The config file RiakConfig.groovy defines a default dataSource block. As the name implies this is the dataSource used by default, however you can configure named dataSources by adding a new config block. For example connecting to a dataSource whose name is 'internal' can be done in this way

This block can be used inside the environments() block in the same way as the default client block is used.


A trivial sample application can be found at







Release sync with Griffon 0.9.4



Fix a metaclass problem when injecting dynamic methods



Release sync with Griffon 0.9.1



Initial release

  • No labels