9.1 Introduction

XDoclet, available from http://xdoclet.sourceforge.net, is an open source tool that extends the Javadoc Doclet API, allowing for the creation of files based on Javadoc @ tags and template files (.xdt).

This chapter uses XDoclet Version 1.2 beta 1, which can be found at http://xdoclet.sourceforge.net/1.2beta/index.html. Be sure to check their web site for updated XDoclet releases.

XDoclet provides direct support for generating many different types of files. The most popular use of XDoclet is to generate EJB files such as deployment descriptors, remote and home interfaces, and even vendor-specific deployment descriptors. If XDoclet does not provide what you need, you may define your own @ tags and template files. For ultimate flexibility, new Ant XDoclet tasks and new XDoclet tag handlers may be created, allowing for practically any kind of content.

One of the main goals of XDoclet is providing an active code-generation system through Ant. This means that XDoclet works directly with your Ant buildfile to generate the necessary files your project needs. For example, let's say you are working on an EJB called CustomerBean. Normally, you would have to write a minimum of four files: the bean implementation, remote interface, home interface, and the deployment descriptor. If a new public method is introduced, all four files must be kept in sync or the deployment of the bean fails. With XDoclet you simply write the bean implementation class and mark it up with XDoclet @ tags. During the build process an XDoclet Ant task generates the remaining three files for you. Since all files are based on the single bean implementation class, the files are always in sync.