Template-Based Code Generation with Apache Velocity, Part 2
As described in part one of this series, code generation typically uses a template engine to transform some kind of "model" into compilable code, given the formatting specified by a template.
Tutorial Details:
In this second part of the series, I will show how to use Velocity inside of a code generator that is based on a well-defined Internal Object Model (IOM). You will see two different strategies:
1. Using the Internal Object Model as the data model for the Velocity transformation.
2. Using a Platform-Specific Model (PSM) in order to balance the logic between generator and template.
You can see three different modules in the code generator:
1. Importer: Reads the data model as input and translates it into a platform-independent internal format based on an object model.
2. Internal Object Model: Is the platform-independent internal format and could be considered the core of the code-generator architecture. IOM contains a set of classes that make it easy to manipulate the information coming from the model to generate outputs. The structure of the object model is a very important issue -- when well designed, it can be a powerful representation, independent of the target technology (Java, C++, etc.), that can easily be converted into source code.
3. Exporter: Accesses the IOM and takes the relevant information to generate code. As we will see, it can use templates in order to drive the generation process.
Read
Tutorial at: Click here to view the tutorial
Rate Tutorial: Template-Based Code Generation with Apache Velocity, Part 2
View Tutorial: Template-Based Code Generation with Apache Velocity, Part 2
Related
Tutorials:
Program your Palm in Java, Part 1: The PalmOS
Emulator - JavaWorld November
1999
Program your Palm in Java, Part 1: The PalmOS
Emulator - JavaWorld November
1999 |
Program your Palm in Java, Part 1: The PalmOS
Emulator - JavaWorld November
1999
Program your Palm in Java, Part 1: The PalmOS
Emulator - JavaWorld November
1999 |
Code generation using Javadoc - JavaWorld August
2000
Code generation using Javadoc - JavaWorld August
2000 |
Mapping XML to Java, Part 1 - JavaWorld August 2000
Mapping XML to Java, Part 1 - JavaWorld August 2000 |
Solve your
servlet-based presentation problems - JavaWorld November
2000
Solve your
servlet-based presentation problems - JavaWorld November
2000 |
Breathe intelligence into Java - JavaWorld April 2001
Breathe intelligence into Java - JavaWorld April 2001 |
Clean up your wire protocol with SOAP, Part 2 - JavaWorld April 2001
Clean up your wire protocol with SOAP, Part 2 - JavaWorld April 2001 |
Clean up your wire protocol with SOAP, Part 3 - JavaWorld June
2001
Clean up your wire protocol with SOAP, Part 3 - JavaWorld June
2001 |
Axis: The next generation of Apache SOAP
Axis: The next generation of Apache SOAP |
Integrate Java and C++ with Jace
Integrate Java and C++ with Jace |
Take the sting out of SAX
Take the sting out of SAX |
Introducing the
Portlet Specification, Part 2
Introducing the
Portlet Specification, Part 2 |
Template-Based Code Generation with Apache Velocity, Part 1
Template-Based Code Generation with Apache Velocity, Part
I'm going to discuss template-based code generation, explain basic concepts related to templates and transformations, and demonstrate the huge benefits they can bring in code generation. |
Apache Geronimo
Apache Geronimo
Welcome to Apache Geronimo, the J2EE server project of the Apache Software Foundation. Please help us make this a world class, certified J2EE container! |
Extensible Code Generation with Java, Part 1
Extensible Code Generation with Java, Part 1
Code generation is a key new trend in engineering, one that you need to understand well. The reason is simple: today's modern frameworks are extremely code-intensive. Using a code generator to build the code |
Template-Based Code Generation with Apache Velocity, Part 2
Template-Based Code Generation with Apache Velocity, Part 2
As described in part one of this series, code generation typically uses a template engine to transform some kind of "model" into compilable code, given the formatting specified by a template. |
Extensible Code Generation with Java
Extensible Code Generation with Java Part 2
In part 1 of this series, we looked at the idea of generated code, which is code written not by hand but by another application. The appeal of generated code is that it can eliminate drudgery (and mistakes) i |
Reduce code bloat with XDoclet
Reduce code bloat with XDoclet
XDoclet can easily be one of the more versatile cross-technology code-generation tools in your Java programming toolbox. Unfortunately, developers often overlook XDoclet's general utility and use it only when it's bundled a |
What is Persistence Framework?
What is Persistence Framework?
What is Persistence Framework?
A persistence framework moves the program data in its most natural form (in memory objects) to and from a permanent data store the database. The persistence framework manages the |
Open Source Web Frameworks in Java
Open Source Web Frameworks in Java
Open Source Web Frameworks in Java
Struts
Struts Frame work is the implementation of Model-View-Controller (MVC) design pattern for the JSP. Struts is maintained as a part of Apache Jakarta project and is open |
|
|
|