Print
XDoclet2, A Code Generation tool

XDoclet2, A Code Generation tool

XDoclet is a template based code generation tool. The template operates on a certain context/metadata made available to it by a metadata provider. QDox (qdox.codehaus.org) is one such provider. The source of the metadata is immaterial. Typically they are annotated java source files. QDox parses the java source files looking for the annotations/metadata and makes it available in the form of simple java classes that mirror the java type system. In the context of the XDoclet2 architecure, XDoclet just extends Generama and registers QDoxMetadataProvider by default in addition to many other things.

A XDoclet plugin is a 'pluggable unit' that handles code generation. Anything that needs to get generated requires a plugin to be present. For eg - EJB Plugin generates EJBHome/Local, Remote/Local interfaces from a bean definition, Struts Plugin generates Struts related artifacts ,namely struts-config.xml from the Action class etc. You use only those plugins whose services you require.

A Plugin (part of Generama) ties the Metadata provider and the Template engine together.

All XDoclet Plugins extend the abstract org.generama.Plugin class either directly or indirectly. This class in turn implements Pico's Startable interface. Thus, all XDoclet plugins are components registered within Pico, waiting for the container to start them so that they can do something meaningful. Earlier we saw what start() does when invoked on the Container instance : it kicked off the Formula-One race. In this case it triggers the code generation routine. The metadata that is typically specified at the java source code level needs to be extracted first. QDox does exactly that and is discussed next.

Powered by Atlassian Confluence