Skip to end of metadata
Go to start of metadata


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


The current version of griffon-berkeleydb is 0.5
To install just issue the following command


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

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

Remember to make all calls to the database off the EDT otherwise your application may appear unresponsive when doing long computations
inside the EDT. The following dynamic methods will be added

  • withBerkeleyEnv { Environment env -> ... } - direct access to the current Berkeley DB environment.
  • withBerkeleyDB(Map args) { Database db, Transaction txn -> ... }
  • withBerkeleyCursor(Map args) { Cursor cursor, Transaction txn -> ... }
  • withEntityStore(Map args) { EntityStore store, Transaction txn -> ... }

The last 3 methods accept an optional Map argument that may contain the following keys:

  • id - name of a database or entityStore. Will pull configuration from BerlekeydbConfig if the id matches a configured database or entityStore.
  • txnConfig - a TransactionConfig instance that overrides any transaction settings available BerlekeydbConfig for a matching id.
  • cursorConfig - a CursorConfig instance that overrides any cursor settings available BerlekeydbConfig for a matching id.

All these methods are also accessible to any component through the singleton griffon.plugins.berkeleydb.BerkeleydbConnector. You can inject these methods to non-artifacts via metaclasses. Simply grab hold of a particular metaclass and call BerkeleydbConnector.enhance(metaClassInstance).


This plugin provides the following scripts

  • create-berkeleydb-entity - creates a new class (and its Accessor) that be used with the EntityStore.


Dynamic method injection

Dynamic methods 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

  • BerkeleydbConnectStart[config] - triggered before connecting to the datastore
  • BerkeleydbConnectEnd[env] - triggered after connecting to the datastore
  • BerkeleydbDisconnectStart[config, env] - triggered before disconnecting from the datastore
  • BerkeleydbDisconnectEnd[] - triggered after disconnecting from the datastore

Database Settings

The following BerlekeydbConfig.groovy exemplifies what you may configure


Follow these steps to create a simple application that displays data stored inside a database.

1. Create a new application named 'sample'


Following steps must be executed inside the application's directory

2. Install the Berkeleydb plugin

5. Create an entity class in src/main/sample/Person.groovy. Edit the class to add a property named 'lastname'

Java based templates are available too, just use -fileType=java at the command prompt.

4. Setup bootstrapping data. Edit griffon-app/conf/BootstrapBerkeleydb.groovy (We'll use the Griffon's team roster, feel free to input your own data)

5. Make sure BerkeleydbConfig.groovy has an entityStore named 'person'

6. Download a copy of GlazedLists' latest stable release. Place it under $appdir/lib. Or install the Glazedlists Plugin (recommended!).

7. Edit griffon-app/models/sample/SampleModel.groovy by adding a personList property.

GlazedLists' EventList simplifies working with JList, JTable and their models as you will soon find out.

8. Edit griffon-app/views/sample/SampleView.groovy. We'll add a scrollPane and a table. The Table's model will be tied to model.people.

9. Finally edit griffon-app/controllers/sample/SampleController.groovy. The controller will react to an application event, load the data into a temporary List then update model.people inside the EDT.

10. Run the application by typing

Full source code for this sample application can be found at







Release sync with Griffon 0.9.4



Release sync with Griffon 0.9.3



Fix a metaclass problem when injecting dynamic methods



Release sync with Griffon 0.9.1



Release sync with Griffon 0.9



Initial release

  • No labels