@Resource(type="ftl") public class FreeMarkerContentHandlerFactory extends Object implements ContentHandlerFactory
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).
<resource-config selector="target-element"> <resource>FreeMarker Resource - Inline orExample - URI based FreeMarker spec: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") aBeanContext
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 theOutputStreamResource
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>
<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>
PARAM_RESTYPE
Constructor and Description |
---|
FreeMarkerContentHandlerFactory() |
Modifier and Type | Method and Description |
---|---|
ContentHandler |
create(SmooksResourceConfiguration resourceConfig)
Create a FreeMarker based ContentHandler.
|
public ContentHandler create(SmooksResourceConfiguration resourceConfig) throws SmooksConfigurationException, InstantiationException
create
in interface ContentHandlerFactory
resourceConfig
- The SmooksResourceConfiguration for the FreeMarker.ContentHandler
instance.SmooksConfigurationException
- Successfully created ContentHandler, but an error occured during configuration.InstantiationException
- Unable to create ContentHandler instance.Copyright © 2020. All rights reserved.