public class DomModelCreator extends Object implements DOMVisitBefore, SAXVisitBefore, SAXVisitAfter, Producer
<order id='332'> <header> <customer number="123">Joe</customer> </header> <order-items> <order-item id='1'> <product>1</product> <quantity>2</quantity> <price>8.80</price> </order-item> <order-item id='2'> <product>2</product> <quantity>2</quantity> <price>8.80</price> </order-item> <order-item id='3'> <product>3</product> <quantity>2</quantity> <price>8.80</price> </order-item> </order-items> </order>The
DomModelCreator
can be configured to create model for the "order" and "order-item"
message fragments:
<resource-config selector="order,order-item"> <resource>org.milyn.delivery.DomModelCreator</resource> </resource-config>In this case, the "order" model will never contain "order-item" model data (order-item elements are nested inside the order element). The in memory model for the "order" will simply be:
<order id='332'> <header> <customer number="123">Joe</customer> </header> <order-items /> </order>Added to this is the fact that there will only ever be 0 or 1 "order-item" model in memory at any given time, with each new "order-item" model overwriting the previous "order-item" model. All this ensures that the memory footprint is kept to a minimum.
Constructor and Description |
---|
DomModelCreator() |
Modifier and Type | Method and Description |
---|---|
Set<String> |
getProducts()
Get the set of products produced by this producer instance.
|
Document |
popCreator(ExecutionContext executionContext) |
void |
visitAfter(SAXElement element,
ExecutionContext executionContext)
Visit the supplied element after visiting its child elements.
|
void |
visitBefore(Element element,
ExecutionContext executionContext)
Visit the supplied element before visiting its child elements.
|
void |
visitBefore(SAXElement element,
ExecutionContext executionContext)
Visit the supplied element before visiting its child elements.
|
public DomModelCreator() throws ParserConfigurationException
ParserConfigurationException
public Set<String> getProducts()
Producer
getProducts
in interface Producer
public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException
DOMVisitBefore
visitBefore
in interface DOMVisitBefore
element
- The DOM element being visited.executionContext
- Request relative instance.SmooksException
- Element processing failure.public void visitBefore(SAXElement element, ExecutionContext executionContext) throws SmooksException, IOException
SAXVisitBefore
visitBefore
in interface SAXVisitBefore
element
- The SAX element being visited.executionContext
- Execution context.SmooksException
- Event processing failure.IOException
- Error writing event to output writer.public void visitAfter(SAXElement element, ExecutionContext executionContext) throws SmooksException, IOException
SAXVisitAfter
visitAfter
in interface SAXVisitAfter
element
- The SAX element being visited.executionContext
- Execution context.SmooksException
- Event processing failure.IOException
- Error writing event to output writer.public Document popCreator(ExecutionContext executionContext)
Copyright © 2020. All rights reserved.