Java Tutorial - Java Scipt : Generating Interface Files with X-Doclet

Java Tutorial - Java Scipt :

Generating Interface Files with X-Doclet


When creating an EJB you will create the EJB class, a home interface, at least one remote or local interfaces and an XML deployment descriptor. Furthermore specific containers may require additional files beyond the basic deployment descriptor to support the EJB deployment in that container. If you think  that the specification of an EJB seems to be spread throughout far too many files, you’re right. Making a single change to an EJB can often require modification to three or four files. It is a tedious, and therefore error-prone, process to write an EJB by hand. Rest assured that there have historically been good reasons for this modularity. When the EJB drafts were first written, Java reflection and dynamic proxies were not in standard use. As a result, the J2EE container had to insert management code into the EJB classes. At that time, this was done through an additional compilation step where the container deduced what code to generate by examining interfaces and deployment descriptors. Because each container had to generate its own management code that sat between the client and the code written by the developer, this was a necessary evil. The spec writers expected much of this housekeeping to be done through
tools, such as might be found in an IDE. Luckily, managing the myriad of files is easier today because these types of tools do exist. One of our favorites is XDoclet, which can be integrated into the build process to automatically generate the various interface files as well as the descriptors from metadata encoded throughout Javadoc comments in a single class file. This makes the management and development of EJBs much less painstaking. The following
Most EJB containers have also adopted dynamic proxy generation to skip the extra compilation step. This is a welcome change and simplifies the development process. (As a historical note, this approach was first utilized by
JBoss.)