[Introduction to XDoclet Basics]

XDoclet can automatically generate configuration files, source code, etc. for you through some special annotation information in the java source code, such as the deployment description files of web and ejb, and the struts-config.xml configuration file that generates struts for you, javascript validation, etc.

 

XDoclet can automatically generate configuration files, source code, etc. for you through some special annotation information in the java source code, such as the deployment description files of web and ejb, and the struts-config.xml configuration file that generates struts for you, javascript validation, etc.

 

As said in the Chinese version of some chapters of "XDoclet in Action", "In the beginning, XDoclet gained a reputation for automatically generating EJB complex interfaces and deployment description files. However, now XDoclet has developed into a full-featured, oriented A code generation framework for properties. J2EE code generation is just one application aspect of XDoclet that can do things well beyond J2EE and project documentation generation."

 

The current version can generate description files, source code, etc. for web, ejb, struts, webwork, hibernate, jdo, jmx, etc. XDoclet provides ant task target support, and completes tasks through ant.

 

XDoclet is a general-purpose code generation utility, an extended Javadoc Doclet engine that allows you to add metadata to language features such as classes, methods, and fields using things like JavaDoc tags. It then utilizes this additional metadata to generate related files such as deployment descriptors and source code. Allows you to create your own javadoc @tags and then use Templet enging in XDoclet to generate source code or other files (such as xml deployment descriptors) based on these @tags.

 

XDoclet inherits ideas from the JavaDoc engine, allowing code and other files to be generated from custom JavaDoc tags. Of course, XDoclet also has access to the entire parse tree. This way, it has access to the class, the class's package structure, and the class's methods.

 

Xdoclet consists of three main components, Xjavadoc engine, Xdoclet engine and modules. Modules in turn consist of tasks, subtasks, tag handlers, and templates.

 

XJavaDoc engine: XJavaDoc parses Java source files and then builds a tree of information about class and language features (packages, methods, and fields) and metadata. The XJavaDoc engine provides access through an easy-to-use API. The API provides the same class information as the JavaDoc API with some additional features associated with storing and reading metadata and other structures. XJavaDoc adds the ability to modify JavaDoc markup at runtime. This way the metadata can be inferred and its default value set to a more reasonable value.

 

XDoclet engine: The XJavaDoc engine reads the tags that make up the metadata and structure of the class. The XDoclet engine uses information from the XJavaDoc engine to generate supporting files (source code and deployment descriptors). XDoclet provides an excellent template generation engine that converts templates into one or more supporting files. XDoclet has a module loader that dynamically loads XDoclet modules specified in the xdoclet.xml file (included in the module's jar file).

 

You can create templates without creating modules. Each top-level XDoclet Ant task has the ability to execute arbitrary templates in place of the templates provided with the module.

 

Module Engine: Modules consist of tasks, subtasks, tag handlers, and templates.

 

XDoclet provides ant's task target support, and completes tasks entirely through ant.

 

Xdoclet is actually an automatic code generation tool, which can generate all kinds of code or configuration files (if you know xdoclet well, you can also extend it). By default, xdoclet has provided us with a lot of solutions. These solutions are called plugins, or plug-ins. On the official website of xdoclet: http://xdoclet.codehaus.org, we can get information about all the plugins it supports.  

Xdoclet supports automatic code generation through plugins. We are going to use xdoclet, which can be defined as a task of ant (as above). Then you can use xdoclet. Use xdoclet inside the <xdoclet> tag. Since xdoclet is usually used to scan source files, read comments in source files, and then generate corresponding configuration files based on these comments, we usually need to define which source code files are scanned by xdoclet.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327094924&siteId=291194637