With Ant, you can easily compile and manage the entire project. So, especially the code generator suitable for your own project requirements, using xdoclets seem many times from the project reality. Let those data packages, commonly used The operation class is unfolded, about this, I have made some attempts, but I feel a more versatile thing, but also more time, my idea is first is a class description XML file, After all, the class is the foundation of everything, can generate a class, does not represent the generated code, the following is the preliminary description of this XML file, and many places borrowed Ant, of course, how to define this XML file can be the most complete, The most intuitive, I have to think about a while, especially in the definition of src XML Version = "1.0" eNCoding = "GB2312"?>
MethodBody> construct> Dynamic> MethodBody> method> class> classfile> is like a production line, here is a code production plant, XML above The document is the definition of the production line, handed over this production line to the factory, the factory can be like a milking, a little squeezing out the code you want, there is a production line, with a factory, what is the lack of raw materials? It turned out that the SRC definition SRC describes the source of the factory, and the SRC has a "from" attribute. He defines the source of the SRC. In the above example, the value of the From is "External", he means that this SRC is specified from the outside, You can also specify from a file, from a database query, and others, etc. .. Of course, these specific source types need to be defined in XML, such as "External" and "Query" definition, such as one Data table package, his SRC comes from some description information of the table in the database, the latter Variable and some Method can dynamically generate according to this SRC