Where to Keep Your Generated Code
There are several ways of managing generated source files. Some developers encourage you mix your generated source in with your own source code. We prefer to keep all the generated code in a completely separate source folder. The way that you do it will probably be based on your personal preference and circumstances. As seen in Figure 2
, we put the source code in a directory called src and we set up the XDoclet configurations to generate the XDoclet files in a directory called gen_src.
The attribute-oriented programming paradigm has gained a huge amount of attention in the software development community. For example, the C# language has a built-in facility for adding metadata. The Java community is recognizing the need for adding metadata as part of the Java language definition. JSR175 (see http://www.jcp.org/en/jsr/detail?id=175) will allow for "annotating fields, methods, and classes as having particular attributes that indicate they should be processed in special ways by development tools, deployment tools, or run-time libraries. We call such annotations metadata." JSR 175 will implement the equivalent of XDoclet's JavaDoc metadata definition. The XDoclet project will likely adopt the JSR 175 standard for defining metadata, and continue to develop its generation tools using that standard.
In this article you were introduced to XDoclet, a code generation engine which implements a concept known as Attribute-Oriented Programming. XDoclet has found a huge following, as it can reduce the amount of code that a developer must hand write. Though we focused on the ejbdoclet and webdoclet doclets in particular, XDoclet can be used to generate a myriad of other files needed for such leading technologies as JDO and Struts.