| <html> |
| <head> |
| <meta http-equiv="content-type" content=""> |
| <title></title> |
| </head> |
| |
| <body> |
| <h1>ADB Tweaking Guide</h1> |
| |
| <h2>Introduction</h2> |
| |
| <p>ADB is written with future extensions in mind, with a clear and flexible |
| way to extend or modify it's functionality. This document explains available |
| mechanisms to extend ADB and possibly adopt it to compile schemas to support |
| other languages.</p> |
| |
| <h2>Know the Configuration</h2> |
| |
| <p>The configuration for the ADB framework is in the |
| <strong>schema-compile.properties</strong> file found in the |
| <strong>org.apache.axis2.databinding.schema</strong> package. This properties |
| file has the following important properties</p> |
| <ul> |
| <li>schema.bean.writer.class |
| <p>This is the writer class. This is used by the schema compiler to write |
| the beans and should implement the |
| <strong>org.apache.axis2.schema.writer.BeanWriter</strong> inteface. The |
| schema compiler delegates the bean writing task to the specified instance |
| of the BeanWriter.</p> |
| </li> |
| <li>schema.bean.writer.template |
| <p>This specifies the template to be used in the BeanWriter. The |
| beanWriter author is free to use any mechanism to write the classes but |
| the default mechanism is to use a xsl template. This property may be left |
| blank if the BeanWriter implementation does not require a template.</p> |
| </li> |
| <li>schema.bean.typemap |
| <p>This is the type map to be used by the schema compiler. it should be |
| an implementation of the <strong>org.apache.axis2.schema.typemap</strong> |
| interface. The default typemap implementation encapsulates a hashmap with |
| type QName to Class name string mapping.</p> |
| </li> |
| </ul> |
| |
| <h2>The First Tweak - Generate Plain Java Beans</h2> |
| |
| <p>The first, most simple tweak for the code generator could be to switch to |
| plain bean generation. The default behavior of the ADB framework is to |
| generate ADBBeans, but most users, if they want to use ADB as a standalone |
| compiler, would love to have plain java beans. This can infact be done by |
| simply changing the template used.</p> |
| |
| <p>The template for plain java beans is already available in the |
| <strong>org.apache.axis2.schema.template </strong>package. To make this work |
| replace the |
| <strong>/org/apache/axis2/databinding/schema/template/ADBBeanTemplate.xsl |
| </strong>with the |
| <strong>/org/apache/axis2/databinding/schema/template/PlainBeanTemplate.xsl |
| </strong>in the schema-compile.properties<strong>.</strong> </p> |
| |
| <p>Congratualtions! You just tweaked ADB to generate plain java beans.</p> |
| |
| <p>To generate custom formats, the templates need to be modified. The schema |
| for the xml generated by the JavaBeanWriter is availble in the source tree |
| under the Other directory in the codegen module. Advanced users with |
| knowledge of XSLT can easily modify the templates to generate code in their |
| own formats.</p> |
| |
| <h2>A More Advanced Tweak - Generate Code for Another Language</h2> |
| |
| <p>To generate code for another language, there are two main components are |
| to be written.</p> |
| <ul> |
| <li>The BeanWriter |
| <p>Implement the BeanWriter interface for this class. A nice example is |
| the <strong>org.apache.axis2.schema.writer.JavaBeanWriter</strong> which |
| has a lot of reusable code. Infact if the language is OOP based (such as |
| C# or even C++), one would even be able to extend the JavaBeanWriter |
| itself.</p> |
| </li> |
| <li>The TypeMap |
| <p>Implement the TypeMap interface for this class. The |
| <strong>org.apache.axis2.schema.typemap.JavaTypeMap</strong> class is a |
| simple implementation for the typemap where the QName to class name |
| strings are kept inside a hashmap instance. This technique is fairly |
| sufficient and only the type names would need to change to support |
| another language.</p> |
| </li> |
| </ul> |
| |
| <p>Surprisngly this is enough to have other language support for ADB. Change |
| the configuration and you are ready to generate code for other lanuages!</p> |
| |
| <p>This tweaking guide is supposed to be a simple guideline for anyone who |
| wishes to dig deep into the mechanics of the ADB code generator. Users are |
| free experiment with it and modify the schema compiler accordingly to their |
| needs.</p> |
| <hr> |
| </body> |
| </html> |