type safe templating

Overview

Within a Java program, each Jamon template is represented as an instance of a class specific to that template. In order for your program to compile, Jamon templates need to be translated into Java source classes, and those generated Java sources need to be included in the build of your project.

Assumptions

Building with Ant

First, ensure you have the Jamon task properly defined, which could be accomplished by including the following in the build.xml file:
  <path id="jamontaskcp">
    <pathelement file="/path/to/jamon-runtime.jar"/>
    <pathelement file="/path/to/jamon-api.jar"/>
    <pathelement file="/path/to/jamon-procesor.jar"/>
    <pathelement file="/path/to/jamon-anttask.jar"/>
  </path>
  <taskdef name="jamon"
           classname="org.jamon.ant.JamonTask"
           classpathref="${jamontaskcp}"/>
To generate the Java sources, include the following target:
  <target name="templates">
    <mkdir dir="tempsrc" />
    <jamon destdir="tempsrc" srcdir="templates" />
  </target>
To compile the project:
  <target name="compile"  depends="templates">
    <javac destdir="classes" classpath="/path/to/jamon-runtime.jar" >
      <src path="src"/>
      <src path="tempsrc"/>
    </javac>
  </target>