org.codehaus.enunciate.modules
Class FreemarkerDeploymentModule

java.lang.Object
  extended by org.codehaus.enunciate.modules.BasicDeploymentModule
      extended by org.codehaus.enunciate.modules.FreemarkerDeploymentModule
All Implemented Interfaces:
EnunciateModelAware, DeploymentModule
Direct Known Subclasses:
AMFDeploymentModule, BasicAppModule, CDeploymentModule, CSharpDeploymentModule, CXFDeploymentModule, DocumentationDeploymentModule, GWTDeploymentModule, JavaClientDeploymentModule, JAXWSRIDeploymentModule, JAXWSSupportDeploymentModule, JBossDeploymentModule, JerseyDeploymentModule, ObjCDeploymentModule, PHPDeploymentModule, RubyDeploymentModule, SpringAppDeploymentModule, SwaggerDeploymentModule, XMLDeploymentModule

public abstract class FreemarkerDeploymentModule
extends BasicDeploymentModule
implements EnunciateModelAware

Basic module that processes a freemarker template when generating, handling the TemplateException that occurs.

Author:
Ryan Heaton

Field Summary
 
Fields inherited from class org.codehaus.enunciate.modules.BasicDeploymentModule
enunciate
 
Constructor Summary
FreemarkerDeploymentModule()
           
 
Method Summary
 void close()
          Default implementation is a no-op.
abstract  void doFreemarkerGenerate()
          Generate using Freemarker.
protected  void doGenerate()
          Processes the template.
protected  freemarker.template.Configuration getConfiguration()
          Get the freemarker configuration.
 EnunciateFreemarkerModel getModel()
          Gets the model for processing.
protected  EnunciateFreemarkerModel getModelInternal()
           
protected  freemarker.template.ObjectWrapper getObjectWrapper()
          The object wrapper to use for the model.
protected  freemarker.template.TemplateExceptionHandler getTemplateExceptionHandler()
          Get the template exception handler.
protected  freemarker.cache.URLTemplateLoader getTemplateLoader()
          Get the template loader for the freemarker configuration.
 void initModel(EnunciateFreemarkerModel model)
          Initialize the model.
 void processTemplate(freemarker.template.Template template, java.lang.Object model)
          Processes the specified template with the given model.
 void processTemplate(freemarker.template.Template template, java.lang.Object model, java.io.PrintStream out)
          Processes the specified template to the specified output stream.
 void processTemplate(java.net.URL templateURL, java.lang.Object model)
          Processes the specified template with the given model.
 void processTemplate(java.net.URL templateURL, java.lang.Object model, java.io.PrintStream out)
          Processes the specified template with the given model.
 
Methods inherited from class org.codehaus.enunciate.modules.BasicDeploymentModule
debug, doBuild, doCompile, doPackage, getAliases, getBuildDir, getCompileDir, getConfigurationRules, getEnunciate, getGenerateDir, getName, getOrder, getPackageDir, getValidator, info, init, isDisabled, setBuildDir, setCompileDir, setDisabled, setGenerateDir, setPackageDir, step, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FreemarkerDeploymentModule

public FreemarkerDeploymentModule()
Method Detail

doGenerate

protected final void doGenerate()
                         throws EnunciateException,
                                java.io.IOException
Processes the template. Declared final because we don't ever want to do more than process the template so it can be safe to call the processTemplate() method directly (e.g. in the EnunciateAnnotationProcessor).

Overrides:
doGenerate in class BasicDeploymentModule
Throws:
EnunciateException
java.io.IOException

doFreemarkerGenerate

public abstract void doFreemarkerGenerate()
                                   throws EnunciateException,
                                          java.io.IOException,
                                          freemarker.template.TemplateException
Generate using Freemarker. Same as doGenerate() but can throw a TemplateException.

Throws:
EnunciateException
java.io.IOException
freemarker.template.TemplateException

processTemplate

public void processTemplate(java.net.URL templateURL,
                            java.lang.Object model)
                     throws java.io.IOException,
                            freemarker.template.TemplateException
Processes the specified template with the given model.

Parameters:
templateURL - The template URL.
model - The root model.
Throws:
java.io.IOException
freemarker.template.TemplateException

processTemplate

public void processTemplate(java.net.URL templateURL,
                            java.lang.Object model,
                            java.io.PrintStream out)
                     throws java.io.IOException,
                            freemarker.template.TemplateException
Processes the specified template with the given model.

Parameters:
templateURL - The template URL.
model - The root model.
out - The output stream to process to.
Throws:
java.io.IOException
freemarker.template.TemplateException

processTemplate

public void processTemplate(freemarker.template.Template template,
                            java.lang.Object model)
                     throws freemarker.template.TemplateException,
                            java.io.IOException
Processes the specified template with the given model.

Parameters:
template - The template.
model - The root model.
Throws:
freemarker.template.TemplateException
java.io.IOException

processTemplate

public void processTemplate(freemarker.template.Template template,
                            java.lang.Object model,
                            java.io.PrintStream out)
                     throws freemarker.template.TemplateException,
                            java.io.IOException
Processes the specified template to the specified output stream.

Parameters:
template - The template to process.
model - The model.
out - The output stream.
Throws:
freemarker.template.TemplateException
java.io.IOException

getModel

public EnunciateFreemarkerModel getModel()
Gets the model for processing.

Returns:
The model for processing.

getModelInternal

protected EnunciateFreemarkerModel getModelInternal()

getObjectWrapper

protected freemarker.template.ObjectWrapper getObjectWrapper()
The object wrapper to use for the model.

Returns:
The object wrapper to use for the model.

getConfiguration

protected freemarker.template.Configuration getConfiguration()
Get the freemarker configuration.

Returns:
the freemarker configuration.

getTemplateExceptionHandler

protected freemarker.template.TemplateExceptionHandler getTemplateExceptionHandler()
Get the template exception handler. The default one prints the stack trace to System.err rather than the writer because often Freemarker is printing to temp files.

Returns:
The template exception handler.

getTemplateLoader

protected freemarker.cache.URLTemplateLoader getTemplateLoader()
Get the template loader for the freemarker configuration.

Returns:
the template loader for the freemarker configuration.

close

public void close()
           throws EnunciateException
Description copied from class: BasicDeploymentModule
Default implementation is a no-op.

Specified by:
close in interface DeploymentModule
Overrides:
close in class BasicDeploymentModule
Throws:
EnunciateException

initModel

public void initModel(EnunciateFreemarkerModel model)
Description copied from interface: EnunciateModelAware
Initialize the model.

Specified by:
initModel in interface EnunciateModelAware
Parameters:
model - The model to initialize.