Writing a PluginThis document describes how to write a plugin for XDoclet2. XDoclet2 provides several mini-frameworks for plugins. These are:
Deciding what framework to useWhat plugin framework to use depends on what kind of file(s) the plugin will generate.
Velocity and JellyWhen you write a plugin based on Velocity or Jelly you must write two files: A plugin class and a template file. The template file is a Velocity or Jelly script. These scripts will have access to various context variables. What context variables are available to the template depends on the generation mode of the associated plugin. Available if fileName has {0} in it (generate one file per metadata object - typically per java source file). Keep in mind that in this case the template will be rendered once for each object in the metadata collection.
Available if fileName doesn't have {0} in it (generate one file for all metadata objects):
Always available:
BetwixtWhen you write a plugin based on Betwixt, you typically only write one file: A plugin class that extends from xdoclet.plugins.BetwixtPlugin. (There is no template file!) You should use XDoclet SDK's xgg plugin to generate Java Beans. The XGG plugin accepts one or more DTD and/or XSD files describing the structure of the XML your plugin will generate. The XGG plugin generates one Java Bean per XML element type, and your plugin class should populate these beans with data. Look at the hibernate plugin's source for an example about how this is done. |