A guide to the new XDoclet development tool that eliminates programming busy work by automatically generating code and other deployment artifacts, this book enables developers who place metadata in a single source code file to use XDoclet to generate additional source code and other files that are required in a project. Both smaller code examples and a full-scale J2EE example illustrate everything needed to employ XDoclet code generation into a development cycle. In addition to the typical uses of XDoclet in J2EE development, the uses of XDoclet with non-J2EE technologies such as JDO, Hibernate, JMX, SOAP, and MockObjects are also detailed. Information on how to extend XDoclet to generate practically any code a programmer is furnished.
When I first heard of XDoclet (then it was called EJBDoclet), I thought the whole idea was nonsense. The comment blocks in my Java code were for documentation, not for programming. Why would I ever put anything in a comment block that impacted the functionality of my program? How absurd! Besides, at the time I wasn’t doing much with EJBs, so what use did I have for XDoclet?
But XDoclet wouldn’t leave me alone. It kept crossing my path, with its name mentioned in web-logs, presentations, and mailing lists. I was being haunted by XDoclet.
Finally I gave in to those ghosts and gave XDoclet another look. And I’m glad I did. I found out that XDoclet was for more than just EJBs and that it addressed many of the code maintenance headaches I dealt with every day. It freed me from Deployment Descriptor Hell.
I eventually got past my hang-up with putting code in comment blocks. After all, javadoc comments aren’t the real documentation—they’re merely metadata used to generate the real documentation. In that light, metadata used to generate deployment descriptors and interfaces is just as appropriate in comment blocks as javadoc documentation.
Newly enlightened, I dove in head first to learn as much as possible about XDoclet. I sought out every book and every article I could find. But in my quest for XDoclet knowledge, I came up short. Unfortunately, very little had been written about XDoclet. Even XDoclet’s own documentation was sparse (and, in some cases, inaccurate).