public class BeanPopulator extends Object implements ConfigurationExpander
Order
bean with Header
and OrderItem
beans (OrderItems added to a list).
<order> <header> <date>Wed Nov 15 13:45:28 EST 2006</date> <customer number="123123">Joe</customer> </header> <order-items> <order-item> <product>111</product> <quantity>2</quantity> <price>8.90</price> </order-item> <order-item> <product>222</product> <quantity>7</quantity> <price>5.20</price> </order-item> </order-items> </order>
public class Order { private Header header; private List<OrderItem> orderItems; } public class Header { private Date date; private Long customerNumber; private String customerName; } public class OrderItem { private long productId; private Integer quantity; private double price; }
<?xml version="1.0"?> <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd"> <-- Create the Order bean instance when we encounter the "order" element and call it "order"... --> <resource-config selector="order"> <resource>org.milyn.javabean.BeanPopulator</resource> <param name="beanId">order</param> <param name="beanClass">org.milyn.javabean.Order</param> <param name="bindings"> <binding property="header" selector="${header}" /> <-- Wire the header bean to the header property. See header configuration below... --> <binding property="orderItems" selector="${orderItems}" /> <-- Wire the orderItems ArrayList to the orderItems property. See orderItems configuration below... --> </param> </resource-config> <-- Create a List for the OrderItem instances when we encounter the "order" element. Call it "orderItems" and set it on the "order" bean... --> <resource-config selector="order"> <resource>org.milyn.javabean.BeanPopulator</resource> <param name="beanId">orderItems</param> <param name="beanClass">java.util.ArrayList
</param> <param name="bindings"> <binding selector="${orderItem}" /> <-- Wire the orderItem to this ArrayList. See order-item configuration below... --> </param> </resource-config> <-- Create the Header bean instance when we encounter the "header" element. Call it "header" --> <resource-config selector="header"> <resource>org.milyn.javabean.BeanPopulator</resource> <param name="beanId">header</param> <param name="beanClass">org.milyn.javabean.Header</param> <param name="bindings"> <-- Header bindings... --> <binding property="date" type="OrderDateLong" selector="header/date" /> <-- See OrderDateLong decoder definition below... --> <binding property="customerNumber" type="Long
" selector="header/customer/@number" /> <binding property="customerName" selector="header/customer" /> <-- Type defaults to String --> </param> </resource-config> <-- Create OrderItem instances when we encounter the "order-item" element. Set them on the "orderItems" bean (List)... --> <resource-config selector="order-item"> <resource>org.milyn.javabean.BeanPopulator</resource> <param name="beanClass">org.milyn.javabean.OrderItem</param> <param name="bindings"> <-- OrderItem bindings... --> <binding property="productId" type="Long
" selector="order-item/product" /> <binding property="quantity" type="Integer
" selector="order-item/quantity" /> <binding property="price" type="Double
" selector="order-item/price" /> </param> </resource-config> <-- Explicitly defining a decoder for the date field on the order header so as to define the format... --> <resource-config selector="decoder:OrderDateLong"> <resource>org.milyn.javabean.decoders.DateDecoder
</resource> <param name="format">EEE MMM dd HH:mm:ss z yyyy</param> </resource-config> </smooks-resource-list>
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_FACTORY_DEFINITION_PARSER_CLASS
Deprecated.
|
static String |
GLOBAL_DEFAULT_EXTEND_LIFECYCLE
Deprecated.
|
static String |
GLOBAL_DEFAULT_FACTORY_DEFINITION_PARSER_CLASS
Deprecated.
|
Constructor and Description |
---|
BeanPopulator()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
List<SmooksResourceConfiguration> |
expandConfigurations()
Deprecated.
Get the additional configurations to be added to the delivery config by
this ContentHandler.
|
void |
initialize()
Deprecated.
Set the resource configuration on the bean populator.
|
public static String GLOBAL_DEFAULT_EXTEND_LIFECYCLE
public static String GLOBAL_DEFAULT_FACTORY_DEFINITION_PARSER_CLASS
public static String DEFAULT_FACTORY_DEFINITION_PARSER_CLASS
@Initialize public void initialize() throws SmooksConfigurationException
SmooksConfigurationException
- Incorrectly configured resource.public List<SmooksResourceConfiguration> expandConfigurations() throws SmooksConfigurationException
ConfigurationExpander
expandConfigurations
in interface ConfigurationExpander
SmooksConfigurationException
Copyright © 2014. All rights reserved.