Skip to: Site menu | Main content

A Grails-like Rich Application Platform

Addons Print

What are addons?

Addons are the runtime analog to plugins. Whereas a plugin exists, operates, and interacts with the build time aspect of Griffin, and addon exists, operates, and interacts with the runtime portion of the frame work.

There is some connection with addons and plugins. Plugins can add the addons to the distribution and some addons and plugins interact with each other, since some tasks have both a runtime and build time interaction (databases scaffolding, for instance).

What can an addon do?

An addon can do the following things:

  • Add items to the builder much like additions to the Buidler.groovy file
  • Add MVC Groups
  • Add runtime events (such as listening to lifecycle events)

How do I use an addon?

Some addons are added by plugins that package them. You can also hand load the addons yourself.

  1. Add the Addon Classes to the library by doing one of the following:
    1. add the jars to the lib directory
    2. refer to a JNLP file for the addon jars
    3. add the addon as source to the Griffon application
  2. create an addon entry in the griffon-app/conf/Builders.groovy file.

    The syntax is just the same as adding a builder, but if you are not providing any injections you can use the addon=true value as a placeholder.

What's in an Addon Class File?

Three types of things:

  1. stuff to add to builders
  2. MVC Group definitions
  3. events to add to the runtime event handler

Each of these is represented by a field that contains the relevant data.

Stuff to add to builders

Note that addon items are added before anything in Builders.groovy, so if there is a naming collision the items in Builders.groovy will will. To avoid naming collisions use a prefix in the addon definition.

New Nodes

A factories field can add nodes. The field is a map with the value being an instance of Factory. If the class is a Factory it is registered as a normal factory, otherwise it will be registered via registerBeanFactory

The node names are prepended with the addon prefix. The registration group is the name of the addon.

Builder Delegates

One of several fields corresponding to various builder delegate methods can be declared. The value is a list of closures to be added as delegages. The fields are attributeDelegates, preInstantiateDelegates, postInstantiateDelegates, and postNodeCompletionDelegates.

Explicit Methods

Explicit methods are enumerated in the methods field as a map of Strings to closures

Explicit Properties

Explicit properties are enumerated in the props field as a map to a map of closures. Only two values are meaningful in the map, get and set, which define the read and write cosure. (The name props was chosen instead of properties because the properties property has special meaning to Groovy objects.)

MVC Group Definitions

MVC Group Definitions are added via the mvcGroups field. It is a Map<String, Map<String, String>>. The first key is the MVC type name. The second key is the portion, the value is the class name. Builder group injections are not supported currently. (?? just need a good syntax ??)


Events are added via a field events which is a Map<String, Closure>. The will be added as though they are in the Events.groovy file.