org.milyn.templating.freemarker
Class FreeMarkerContentHandlerFactory
java.lang.Object
org.milyn.templating.freemarker.FreeMarkerContentHandlerFactory
- All Implemented Interfaces:
- ContentHandler, ContentHandlerFactory
@Resource(type="ftl")
public class FreeMarkerContentHandlerFactory
- extends Object
- implements ContentHandlerFactory
FreeMarker templating Visitor Creator class.
This templating solution relies on the Smooks JavaBean Cartridge
to perform the JavaBean population that's required by FreeMarker (for the data model).
Targeting "ftl" Templates
The following is the basic configuration specification for FreeMarker resources:
<resource-config selector="target-element">
<resource>FreeMarker Resource - Inline or URI</resource>
<!-- (Optional) The action to be applied on the template content. Should the content
generated by the template:
1. replace ("replace") the target element, or
2. be added to ("addto") the target element, or
3. be inserted before ("insertbefore") the target element, or
4. be inserted after ("insertafter") the target element.
5. be bound to ("bindto") a BeanContext variable named by the "bindId" param.
Default "replace".-->
<param name="action">replace/addto/insertbefore/insertafter</param>
<!-- (Optional) Should the template be applied before (true) or
after (false) Smooks visits the child elements of the target element.
Default "false".-->
<param name="applyTemplateBefore">true/false</param>
<!-- (Optional) The name of the OutputStreamResource
to which the result should be written. If set, the "action" param is ignored. -->
<param name="outputStreamResource">xyzResource</param>
<!-- (Optional) Template encoding.
Default "UTF-8".-->
<param name="encoding">encoding</param>
<!-- (Optional) bindId when "action" is "bindto".
<param name="bindId">xxxx</param>
</resource-config>
Example - URI based FreeMarker spec:
<resource-config selector="target-element">
<!-- 1. See URIResourceLocator -->
<resource>/com/acme/order-transform.ftl</resource>
</resource-config>
Example - Inlined FreeMarker spec:
<resource-config selector="target-element">
<!-- 1. Note how we have to specify the resource type when it's inlined. -->
<!-- 2. Note how the inlined FreeMarker template is wrapped as an XML Comment. CDATA Section wrapping also works. -->
<resource type="ftl">
<!--
Inline FreeMarker Template....
-->
</resource>
</resource-config>
- Author:
- tfennelly
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FreeMarkerContentHandlerFactory
public FreeMarkerContentHandlerFactory()
create
public ContentHandler create(SmooksResourceConfiguration resourceConfig)
throws SmooksConfigurationException,
InstantiationException
- Create a FreeMarker based ContentHandler.
- Specified by:
create in interface ContentHandlerFactory
- Parameters:
resourceConfig - The SmooksResourceConfiguration for the FreeMarker.
- Returns:
- The FreeMarker
ContentHandler instance.
- Throws:
SmooksConfigurationException
InstantiationException
Copyright © 2014. All Rights Reserved.