[jboss-svn-commits] JBL Code SVN: r12239 - in labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_date_manipulation: src/org/jboss/soa/esb/samples/quickstart/transformxml2xmldatemanipulation/test and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed May 30 11:19:21 EDT 2007
Author: tfennelly
Date: 2007-05-30 11:19:21 -0400 (Wed, 30 May 2007)
New Revision: 12239
Modified:
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_date_manipulation/smooks-res.xml
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_date_manipulation/src/org/jboss/soa/esb/samples/quickstart/transformxml2xmldatemanipulation/test/OrderDate.java
Log:
Updated in line with Smooks 0.8 to 0.9 upgrade
Modified: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_date_manipulation/smooks-res.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_date_manipulation/smooks-res.xml 2007-05-30 14:49:38 UTC (rev 12238)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_date_manipulation/smooks-res.xml 2007-05-30 15:19:21 UTC (rev 12239)
@@ -1,55 +1,47 @@
-<?xml version="1.0"?>
-<!DOCTYPE smooks-resource-list PUBLIC "-//MILYN//DTD SMOOKS 1.0//EN" "http://www.milyn.org/dtd/smooksres-list-1.0.dtd">
-<smooks-resource-list>
+<?xml version='1.0' encoding='UTF-8'?>
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
<!--
Create an instance of the OrderDate bean and bind it to the beanId "orderDate". This ID is
used later in the XSLT to refer to this bean.
-->
- <smooks-resource selector="Order" useragent="from-type:text/xml:messageAtA AND from:A AND to-type:text/xml:messageAtB AND to:B" path="org.milyn.javabean.ProcessingPhaseBeanPopulator" >
- <param name="RESERVED:RESOURCE_NAME_PARAM"><![CDATA[JavaBean Create - Processing Phase]]></param>
- <param name="beanId"><![CDATA[orderDate]]></param>
- <param name="beanClass"><![CDATA[org.jboss.soa.esb.samples.quickstart.transformxml2xmldatemanipulation.test.OrderDate]]></param>
- <param name="addToList"><![CDATA[false]]></param>
-
- </smooks-resource>
+ <resource-config selector="Order" target-profile="from-type:text/xml:messageAtA AND from:A AND to-type:text/xml:messageAtB AND to:B">
+ <resource>org.milyn.javabean.ProcessingPhaseBeanPopulator</resource>
+ <param name="RESERVED:RESOURCE_NAME_PARAM"><![CDATA[JavaBean Create - Processing Phase]]></param>
+ <param name="beanId">orderDate</param>
+ <param name="beanClass">org.jboss.soa.esb.samples.quickstart.transformxml2xmldatemanipulation.test.OrderDate</param>
+ <param name="bindings">
+ <binding property="orderDate" selector="Order @orderDate" type="LongDate"/>
+ </param>
+ </resource-config>
- <!--
- Populate the "orderDate" bean with the orderDate attribute value from the Order element.
- -->
- <smooks-resource selector="Order" useragent="from-type:text/xml:messageAtA AND from:A AND to-type:text/xml:messageAtB AND to:B" path="org.milyn.javabean.ProcessingPhaseBeanPopulator" >
- <param name="RESERVED:RESOURCE_NAME_PARAM"><![CDATA[JavaBean Populate - Processing Phase]]></param>
- <param name="beanId"><![CDATA[orderDate]]></param>
- <param name="attributeName"><![CDATA[orderDate]]></param>
- </smooks-resource>
-
- <!--
+ <resource-config selector="decoder:LongDate">
+ <resource>org.milyn.javabean.decoders.CalendarDecoder</resource>
+ <param name="format">EEE MMM dd HH:mm:ss z yyyy</param>
+ </resource-config>
+
+ <!--
Generate the new "OrderDate" element from the date data in the orderDate bean and insert the result before
the OrderLines element.
-->
- <smooks-resource selector="OrderLines" useragent="from-type:text/xml:messageAtA AND from:A AND to-type:text/xml:messageAtB AND to:B" path="See 'resdata' parameter value" >
- <param name="RESERVED:RESOURCE_NAME_PARAM"><![CDATA[XSLT (Templatelet)]]></param>
- <param name="encoding"><![CDATA[UTF-8]]></param>
-
- <param name="visitBefore"><![CDATA[false]]></param>
- <param name="is-xslt-templatelet"><![CDATA[true]]></param>
- <param name="restype"><![CDATA[xsl]]></param>
- <param name="action"><![CDATA[insertbefore]]></param>
- <param name="resdata"><![CDATA[<OrderDate>
+ <resource-config selector="OrderLines" target-profile="from-type:text/xml:messageAtA AND from:A AND to-type:text/xml:messageAtB AND to:B">
+ <resource type="xsl"><![CDATA[<OrderDate>
<day><smooks-bean:select ognl="orderDate.day"/></day>
<time><smooks-bean:select ognl="orderDate.time"/></time>
<zone><smooks-bean:select ognl="orderDate.zone"/></zone>
<month><smooks-bean:select ognl="orderDate.month"/></month>
<year><smooks-bean:select ognl="orderDate.year"/></year>
-</OrderDate>]]></param>
- </smooks-resource>
+</OrderDate>]]></resource>
+ <param name="RESERVED:RESOURCE_NAME_PARAM"><![CDATA[XSLT (Templatelet)]]></param>
+ <param name="action"><![CDATA[insertbefore]]></param>
+ </resource-config>
<!--
Remove the orderDate attribute from the Order element - it's now in the message as an OrderDate element.
-->
- <smooks-resource selector="Order" useragent="from-type:text/xml:messageAtA AND from:A AND to-type:text/xml:messageAtB AND to:B" path="org.milyn.cdres.trans.RemoveAttributeTU" >
- <param name="RESERVED:RESOURCE_NAME_PARAM"><![CDATA[Remove Attribute]]></param>
+ <resource-config selector="Order" target-profile="from-type:text/xml:messageAtA AND from:A AND to-type:text/xml:messageAtB AND to:B">
+ <resource>org.milyn.cdres.trans.RemoveAttributeTU</resource>
<param name="attributeName"><![CDATA[orderDate]]></param>
- </smooks-resource>
+ </resource-config>
</smooks-resource-list>
\ No newline at end of file
Modified: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_date_manipulation/src/org/jboss/soa/esb/samples/quickstart/transformxml2xmldatemanipulation/test/OrderDate.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_date_manipulation/src/org/jboss/soa/esb/samples/quickstart/transformxml2xmldatemanipulation/test/OrderDate.java 2007-05-30 14:49:38 UTC (rev 12238)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_date_manipulation/src/org/jboss/soa/esb/samples/quickstart/transformxml2xmldatemanipulation/test/OrderDate.java 2007-05-30 15:19:21 UTC (rev 12239)
@@ -24,6 +24,7 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.Calendar;
/**
* Sample bean for orderDate manipulation Using Java. This type of thing is a
@@ -33,14 +34,9 @@
*/
public class OrderDate {
- private Date orderDate;
+ private Calendar orderDate;
/**
- * Formatter for decoding the date from the message.
- */
- private static SimpleDateFormat dateDecodeFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
-
- /**
* Formatters for encoding the date in the transformation.
*/
private static SimpleDateFormat dayFormat = new SimpleDateFormat("dd");
@@ -49,31 +45,25 @@
private static SimpleDateFormat yearFormat = new SimpleDateFormat("yy");
private static SimpleDateFormat timezoneFormat = new SimpleDateFormat("Z");
- public void setOrderDate(String orderDate) {
- try {
- // "Wed Nov 15 13:45:28 EST 2006"
- // "EEE MMM dd HH:mm:ss z yyyy"
- this.orderDate = dateDecodeFormat.parse(orderDate);
- } catch (ParseException e) {
- e.printStackTrace();
- }
+ public void setOrderDate(Calendar orderDate) {
+ this.orderDate = orderDate;
}
- public Date getOrderDate() {
+ public Calendar getOrderDate() {
return orderDate;
}
public String getDay() {
- return dayFormat.format(orderDate);
+ return dayFormat.format(orderDate.getTime());
}
public String getTime() {
- return timeFormat.format(orderDate);
+ return timeFormat.format(orderDate.getTime());
}
public String getMonth() {
- return monthFormat.format(orderDate);
+ return monthFormat.format(orderDate.getTime());
}
public String getYear() {
- return yearFormat.format(orderDate);
+ return yearFormat.format(orderDate.getTime());
}
public String getZone() {
- return timezoneFormat.format(orderDate);
+ return timezoneFormat.format(orderDate.getTime());
}
}
More information about the jboss-svn-commits
mailing list