XDoclet is a tool for attribute- oriented work in Java. It is not to be confused with annotations, because XDoclet will not be translated by the compiler into usable attributes at runtime, but Java code is generated, which is translated into executable code. For this, the Javadoc comments are added newly defined tags using XDoclet and the doclet processed to then generate additional files from the source code in addition to the actual program.
XDoclet is used in particular in the context of J2EE and can - used correctly - represent a major workload for the programmer.
Example: XDoclet in J2EE context
( Under EJB 2.0 ) at least the bean implementation, and the home interface are necessary for the creation of an Enterprise JavaBean. Depending on requirements, you still need a remote, a local and a local home interface. Depending on the application server is still required in addition to a deployment descriptor, an assembly descriptor, or both. The descriptors may differ from application server to application server or even from job to job. Overall, therefore, the following files are available:
- Bean implementation
- Remote interface
- Home interface
- Local interface
- Local home interface
- Deployment descriptor
- Assembly - descriptor
Using XDoclet the programmer must write in the simplest case, only the bean implementation itself, providing them with new tags. XDoclet generates the remaining files automatically.
This example shows a use of XDoclet tags a code fragment from an EJB.
/ ** * Here the comment or description of the class could be. * * XDoclet beginning * @ Ejb.bean name = " NameDerBean " * Display-name = " bean 123" * Description = " This bean is used for XY " * Jndi - name = " ejb / NameDerBean " * Type = " Stateless " * View -type = "both" * XDoclet end * / view
With the introduction of annotations in Java 1.5 the future of XDoclet is uncertain. Annotations replace the need for XDoclet almost completely, but must first be correctly implemented by the tool vendors or third party. Remains to be seen whether the implementations of the manufacturer can be just as easily and flexibly adapted or extended, as is the case with the XDoclet Open Source project. Porting the XDoclet tags after annotation is possible in a relatively simple manner.