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.
- Add the Addon Classes to the library by doing one of the following:
- add the jars to the
- refer to a JNLP file for the addon jars
- add the addon as source to the Griffon application
- add the jars to the
- create an addon entry in the
The syntax is just the same as adding a builder, but if you are not providing any injections you can use the
addon=truevalue as a placeholder.
What's in an Addon Class File?
Three types of things:
- stuff to add to builders
- MVC Group definitions
- 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.
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
The node names are prepended with the addon prefix. The registration group is the name of the addon.
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
Explicit methods are enumerated in the
methods field as a map of Strings to closures
Explicit properties are enumerated in the
props field as a map to a map of closures. Only two values are meaningful in the map,
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