<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Robin&#039;s Tech Tips &#187; java</title>
	<atom:link href="http://robin.mytechtip.com/category/programming/java-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://robin.mytechtip.com</link>
	<description>Just another My Tech Tip weblog</description>
	<lastBuildDate>Wed, 06 Jul 2011 02:35:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Spring Web Service (2.0) using xmlbeans as XML marshaling</title>
		<link>http://robin.mytechtip.com/2011/07/06/spring-web-service-2-0-using-xmlbeans-as-xml-marshaling/</link>
		<comments>http://robin.mytechtip.com/2011/07/06/spring-web-service-2-0-using-xmlbeans-as-xml-marshaling/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 02:28:57 +0000</pubDate>
		<dc:creator>robin</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[web-services]]></category>

		<guid isPermaLink="false">http://robin.mytechtip.com/?p=212</guid>
		<description><![CDATA[When I googled “spring webservice xmlbean”, I found this link that provides an example to use xmlbeans as xml marshalling when implementing a spring web service.
The example is based on Spring web service version older than 2 (spring ws 1.5.6 with spring 2.5.6), while now (at the time of writing this post) Spring is now [...]]]></description>
			<content:encoded><![CDATA[<p>When I googled “spring webservice xmlbean”, I found <a href="http://cchweblog.wordpress.com/2009/04/27/developing-spring-web-services-with-xml-marschalling-xmlbeans-example/" onclick="javascript:pageTracker._trackPageview('/outbound/article/cchweblog.wordpress.com');">this link that provides an example to use xmlbeans as xml marshalling when implementing a spring web service</a>.</p>
<p>The example is based on Spring web service version older than 2 (spring ws 1.5.6 with spring 2.5.6), while now (at the time of writing this post) Spring is now on version 3 and Spring-WS on version 2. When I tried the example, I can not make it work straight away on the new Spring/Spring-WS version due to some changed java classes and/or configurations.</p>
<p>The latest <a href="http://static.springsource.org/spring-ws/site/reference/html/tutorial.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/static.springsource.org');">Spring-WS Tutorial</a> does provide an example on how to develop web services using the latest spring-ws version (version 2). However, the simple example does not cover XML marshaling (e.g. xmlbeans).</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3371750151985752";
google_ad_slot = "0950801022";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>So the purpose of this post is to provide an example that use spring-ws version 2 to implement web service with xmlbeans as XML marshaling. This example is based on <a href="http://cchweblog.wordpress.com/2009/04/27/developing-spring-web-services-with-xml-marschalling-xmlbeans-example/" onclick="javascript:pageTracker._trackPageview('/outbound/article/cchweblog.wordpress.com');">Developing Spring Web Services with XML Marschalling – XMLBeans example</a></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:schema</span> <span style="color: #000066;">xmlns:xs</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">attributeFormDefault</span>=<span style="color: #ff0000;">&quot;unqualified&quot;</span> <span style="color: #000066;">elementFormDefault</span>=<span style="color: #ff0000;">&quot;qualified&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">targetNamespace</span>=<span style="color: #ff0000;">&quot;http://robin.mytechtip.com/springws2example/temperature/schemas&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;GetTemperaturesRequest&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:complexType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:sequence<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;city&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:string&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:element</span> <span style="color: #000066;">maxOccurs</span>=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;date&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:date&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:sequence<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:complexType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:element<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;GetTemperaturesResponse&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:complexType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:sequence<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:element</span> <span style="color: #000066;">maxOccurs</span>=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;TemperatureInfo&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:complexType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:sequence<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
							<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;min&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:float&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
							<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;max&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:float&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
							<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;average&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:float&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:sequence<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;city&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:string&quot;</span> <span style="color: #000066;">use</span>=<span style="color: #ff0000;">&quot;optional&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;date&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:date&quot;</span> <span style="color: #000066;">use</span>=<span style="color: #ff0000;">&quot;optional&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:complexType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:element<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:sequence<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:complexType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:element<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:schema<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><span style="font-size: 11pt;font-family: Georgia;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;font-variant: normal;text-decoration: none;vertical-align: baseline">Using xmlbeans, we can create the java classes for this xml schema. The following command generates the jar file  temperature.jar that we need when we create the service end point.</span></p>
<blockquote><p><code>scomp -out temperature.jar temperature.xsd</code>
</p></blockquote>
<p><span style="font-size: 11pt;font-family: Arial;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;font-variant: normal;text-decoration: none;vertical-align: baseline">Then we create the plain web service interface </span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.mytechtip.robin.springws2example</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Date</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> TemperatureService <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>TemperatureInfo<span style="color: #339933;">&gt;</span> getTemperatures<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> city, List<span style="color: #339933;">&lt;</span>Date<span style="color: #339933;">&gt;</span> date<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><span style="font-size: 11pt;font-family: Arial;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;font-variant: normal;text-decoration: none;vertical-align: baseline">and a sample implemetation.</span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.mytechtip.robin.springws2example</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Date</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Random</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TemperatureServiceImpl <span style="color: #000000; font-weight: bold;">implements</span> TemperatureService <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Random</span> rand <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Random</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>TemperatureInfo<span style="color: #339933;">&gt;</span> getTemperatures<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> city, List<span style="color: #339933;">&lt;</span>Date<span style="color: #339933;">&gt;</span> dates<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		List<span style="color: #339933;">&lt;</span>TemperatureInfo<span style="color: #339933;">&gt;</span> temperatures <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>TemperatureInfo<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// Just return some random data</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Date</span> date <span style="color: #339933;">:</span> dates<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			temperatures.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> TemperatureInfo<span style="color: #009900;">&#40;</span>city, date, rand.<span style="color: #006633;">nextInt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span>,
					rand.<span style="color: #006633;">nextInt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">15</span>, <span style="color: #009900;">&#40;</span>rand.<span style="color: #006633;">nextInt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2.0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> temperatures<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><span style="font-size: 11pt;font-family: Arial;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;font-variant: normal;text-decoration: none;vertical-align: baseline">This service requires a  data model “TemperatureInfo”, which is a plain java object:</span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.mytechtip.robin.springws2example</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.Serializable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Date</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TemperatureInfo <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">Serializable</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span> serialVersionUID <span style="color: #339933;">=</span> 1L<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> city<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Date</span> date<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">double</span> min<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">double</span> max<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">double</span> average<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> TemperatureInfo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> TemperatureInfo<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> city, <span style="color: #003399;">Date</span> date, <span style="color: #000066; font-weight: bold;">double</span> min, <span style="color: #000066; font-weight: bold;">double</span> max, <span style="color: #000066; font-weight: bold;">double</span> average<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">city</span> <span style="color: #339933;">=</span> city<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">date</span> <span style="color: #339933;">=</span> date<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">min</span> <span style="color: #339933;">=</span> min<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">max</span> <span style="color: #339933;">=</span> max<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">average</span> <span style="color: #339933;">=</span> average<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Some getter and setter methods</span>
    <span style="color: #666666; font-style: italic;">// ...</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><span style="font-size: 11pt;font-family: Arial;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;font-variant: normal;text-decoration: none;vertical-align: baseline">Based on the above, we create the end point &#8211; “</span><span style="font-size: 11pt;font-family: Georgia;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;font-variant: normal;text-decoration: none;vertical-align: baseline">TemperatureMarshallingEndpoint”</span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.mytechtip.robin.springws2example</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Calendar</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Date</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.beans.factory.annotation.Autowired</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.ws.server.endpoint.annotation.Endpoint</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.ws.server.endpoint.annotation.PayloadRoot</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.mytechtip.robin.springws2Example.temperature.schemas.GetTemperaturesRequestDocument</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.mytechtip.robin.springws2Example.temperature.schemas.GetTemperaturesRequestDocument.GetTemperaturesRequest</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.mytechtip.robin.springws2Example.temperature.schemas.GetTemperaturesResponseDocument</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.mytechtip.robin.springws2Example.temperature.schemas.GetTemperaturesResponseDocument.GetTemperaturesResponse</span><span style="color: #339933;">;</span>
&nbsp;
@Endpoint
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TemperatureMarshallingEndpoint <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> namespaceUri <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://robin.mytechtip.com/springws2example/temperature/schemas&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> TemperatureService temperatureService<span style="color: #339933;">;</span>
&nbsp;
	@Autowired
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setTemperatureService<span style="color: #009900;">&#40;</span>TemperatureService tempService<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">temperatureService</span> <span style="color: #339933;">=</span> tempService<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@PayloadRoot<span style="color: #009900;">&#40;</span>localPart <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;GetTemperaturesRequest&quot;</span>, namespace <span style="color: #339933;">=</span> namespaceUri<span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> GetTemperaturesResponseDocument getTemperatures<span style="color: #009900;">&#40;</span>
			GetTemperaturesRequestDocument request<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		GetTemperaturesRequestDocument requestDoc <span style="color: #339933;">=</span> request<span style="color: #339933;">;</span>
		GetTemperaturesRequest in <span style="color: #339933;">=</span> requestDoc.<span style="color: #006633;">getGetTemperaturesRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		List<span style="color: #339933;">&lt;</span>Date<span style="color: #339933;">&gt;</span> dates <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Date<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Calendar</span> calendar <span style="color: #339933;">:</span> in.<span style="color: #006633;">getDateArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			dates.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>calendar.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		List<span style="color: #339933;">&lt;</span>TemperatureInfo<span style="color: #339933;">&gt;</span> infos <span style="color: #339933;">=</span> temperatureService.<span style="color: #006633;">getTemperatures</span><span style="color: #009900;">&#40;</span>
				in.<span style="color: #006633;">getCity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, dates<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		GetTemperaturesResponseDocument responseDoc <span style="color: #339933;">=</span> GetTemperaturesResponseDocument.<span style="color: #006633;">Factory</span>
				.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		GetTemperaturesResponse response <span style="color: #339933;">=</span> responseDoc
				.<span style="color: #006633;">addNewGetTemperaturesResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>TemperatureInfo info <span style="color: #339933;">:</span> infos<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			GetTemperaturesResponse.<span style="color: #006633;">TemperatureInfo</span> out <span style="color: #339933;">=</span> response
					.<span style="color: #006633;">addNewTemperatureInfo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			out.<span style="color: #006633;">setCity</span><span style="color: #009900;">&#40;</span>info.<span style="color: #006633;">getCity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			out.<span style="color: #006633;">setAverage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span> info.<span style="color: #006633;">getAverage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #003399;">Calendar</span> calendar <span style="color: #339933;">=</span> <span style="color: #003399;">Calendar</span>.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			calendar.<span style="color: #006633;">setTime</span><span style="color: #009900;">&#40;</span>info.<span style="color: #006633;">getDate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			out.<span style="color: #006633;">setDate</span><span style="color: #009900;">&#40;</span>calendar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			out.<span style="color: #006633;">setMax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span> info.<span style="color: #006633;">getMax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			out.<span style="color: #006633;">setMin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span> info.<span style="color: #006633;">getMin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> responseDoc<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><span style="font-size: 11pt;font-family: Georgia;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;font-variant: normal;text-decoration: none;vertical-align: baseline">We need to configure the web application and the spring framework to make the web service work.  So the web.xml looks like this.</span></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE web-app</span>
<span style="color: #00bbdd;">    PUBLIC &quot;-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN&quot;</span>
<span style="color: #00bbdd;">    &quot;http://java.sun.com/dtd/web-app_2_3.dtd&quot;&gt;</span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;web-app<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>springws2example<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			org.springframework.ws.transport.http.MessageDispatcherServlet
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>transformWsdlLocations<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/init-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;load-on-startup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/load-on-startup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>springws2example<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/services/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/web-app<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><span style="font-size: 11pt;font-family: Georgia;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;font-variant: normal;text-decoration: none;vertical-align: baseline">and we have the corresponding spring context configuration (“springws2example-servlet.xml” under WEB-INFO) for the servlet “springws2example”  defined in “web.xml”. NOTE: we need to make sure the schema “temperature.xsd” is under  folder “WEB-INF” so it can automatically generate the “WSDL” file, which can be accessed from “http://&lt;host&gt;:&lt;port&gt;/&lt;context-root&gt;/services/temperature.wsdl”.</span></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span style="color: #000066;">xmlns:context</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/context&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:sws</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/web-services&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd</span>
<span style="color: #009900;">  http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd</span>
<span style="color: #009900;">  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context:component-scan</span> <span style="color: #000066;">base-package</span>=<span style="color: #ff0000;">&quot;com.mytechtip.robin.springws2example&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sws:annotation-driven</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.mytechtip.robin.springws2example.TemperatureServiceImpl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span></span>
<span style="color: #009900;">		<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;marshaller&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;marshaller&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;unmarshaller&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;marshaller&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;marshaller&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.oxm.xmlbeans.XmlBeansMarshaller&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sws:dynamic-wsdl</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;temperature&quot;</span> <span style="color: #000066;">portTypeName</span>=<span style="color: #ff0000;">&quot;TempeatureService&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">locationUri</span>=<span style="color: #ff0000;">&quot;/services/temperature&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sws:xsd</span> <span style="color: #000066;">location</span>=<span style="color: #ff0000;">&quot;/WEB-INF/temperature.xsd&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sws:dynamic-wsdl<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><span style="font-size: 11pt;font-family: Arial;color: #000000;background-color: transparent;font-weight: normal;font-style: normal;font-variant: normal;text-decoration: none;vertical-align: baseline">Since I don’t use maven, I need to manually put the following list of required jars into WEB-INFO/lib</span></p>
<blockquote><p>
<code>org.springframework.aop-3.0.5.RELEASE.jar<br />
org.springframework.asm-3.0.5.RELEASE.jar<br />
org.springframework.beans-3.0.5.RELEASE.jar<br />
org.springframework.context.support-3.0.5.RELEASE.jar<br />
org.springframework.context-3.0.5.RELEASE.jar<br />
org.springframework.core-3.0.5.RELEASE.jar<br />
org.springframework.expression-3.0.5.RELEASE.jar<br />
org.springframework.oxm-3.0.5.RELEASE.jar<br />
org.springframework.web.servlet-3.0.5.RELEASE.jar<br />
org.springframework.web-3.0.5.RELEASE.jar<br />
spring-ws-2.0.2.RELEASE-all.jar<br />
temperature.jar<br />
wsdl4j-1.6.1.jar<br />
xbean.jar</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://robin.mytechtip.com/2011/07/06/spring-web-service-2-0-using-xmlbeans-as-xml-marshaling/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Pentaho Community Edition (Data Ingegration)</title>
		<link>http://robin.mytechtip.com/2011/07/04/pentaho-community-edition-data-ingegration/</link>
		<comments>http://robin.mytechtip.com/2011/07/04/pentaho-community-edition-data-ingegration/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 06:34:54 +0000</pubDate>
		<dc:creator>robin</dc:creator>
				<category><![CDATA[BI]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://robin.mytechtip.com/?p=198</guid>
		<description><![CDATA[Pentaho provides two different editions: Community Edition and Enterprise Edition. Community Edition is free and is what i want to discuss.
Pentaho seems to provide more comprehensive coverage of BI than Eclipse BIRT and Jaspersoft. It has the following components:

 Data Integration &#8211; Kettle
 Analysis Service (OLAP) &#8211; Mondrian
 Reporting
 Data Mining &#8211; Weka
 Dashboard
 Large [...]]]></description>
			<content:encoded><![CDATA[<p>Pentaho provides two different editions: Community Edition and Enterprise Edition. Community Edition is free and is what i want to discuss.</p>
<p>Pentaho seems to provide more comprehensive coverage of BI than Eclipse BIRT and Jaspersoft. It has the following components:</p>
<ul>
<li> Data Integration &#8211; Kettle</li>
<li> Analysis Service (OLAP) &#8211; Mondrian</li>
<li> Reporting</li>
<li> Data Mining &#8211; Weka</li>
<li> Dashboard</li>
<li> Large Volume Data Handling (through Hadoop)</li>
</ul>
<p>Since there is already <a href="http://www.innoventsolutions.com/open-source-reporting-comparison.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.innoventsolutions.com');">a comparison of reporting functionality between Pentaho, Eclipse BIRT and JasperReports</a>, I am not going to get deep into its reporting functionality.</p>
<p>The component that I&#8217;ve tried is the data integration. It helps me do the some data integration tasks without writing my own custom code. Here I just give a brief introduction to this component.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3371750151985752";
google_ad_slot = "0950801022";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p><strong>Data Integration &#8211; Kettle</strong><br />
Data Integration is the first thing i tried when I picked up Pentaho. It has a GUI tool (called Spoon) that is built with Eclipse RCP. With the GUI tool, it&#8217;s very easy to define a data integration process. </p>
<p>There are two main elements in the pentaho data integration process: <strong>Transformation </strong>and <strong>Job</strong>. Transformation, as the name suggestions, is a process that does the data manipulation including data exportation, cleansing, format changing, importation and etc. Job may contain one or more transformation and adds more sanity checks (such as if a file exists) and utilities (e.g., emailing the result). </p>
<p>Both Transformation and Job are made up of steps. Pentaho already includes many types of steps that performs the most common tasks. There steps serve as bricks that you can use to build up the whole data integration process. In the GUI, you can easily use drag and drop to define the steps and hops to form the process. You can even preview the transformed data in some steps to make sure they are doing the right thing.</p>
<p>From the Spoon GUI tool welcome page, you can find a &#8220;Get Started&#8221; document that helps you build the first working example. In addition, the pentaho community web site provides <a href="http://wiki.pentaho.com/display/EAI/Latest+Pentaho+Data+Integration+%28aka+Kettle%29+Documentation" onclick="javascript:pageTracker._trackPageview('/outbound/article/wiki.pentaho.com');">useful documentation on how to use this data integration tool</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://robin.mytechtip.com/2011/07/04/pentaho-community-edition-data-ingegration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse BIRT and JasperReports</title>
		<link>http://robin.mytechtip.com/2011/04/20/eclipse-birt-and-jasperreports/</link>
		<comments>http://robin.mytechtip.com/2011/04/20/eclipse-birt-and-jasperreports/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 05:09:12 +0000</pubDate>
		<dc:creator>robin</dc:creator>
				<category><![CDATA[BI]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://robin.mytechtip.com/?p=186</guid>
		<description><![CDATA[Neither Eclipse BIRT or Jasper seems to support the whole functionality of BI. Their main focus is &#8220;reporting&#8220;, which is a core part of BI. Both of them are written in Java.
Eclipse BIRT has two components: A report designer and a report engine. the report designer interacts with user to generate an XML report design [...]]]></description>
			<content:encoded><![CDATA[<p>Neither Eclipse BIRT or Jasper seems to support the whole functionality of BI. Their main focus is &#8220;<strong>reporting</strong>&#8220;, which is a core part of BI. Both of them are written in Java.</p>
<p><strong>Eclipse BIRT</strong> has two components: A report designer and a report engine. the report designer interacts with user to generate an XML report design using its report design engine; while report engine reads the data and the XML report design to generate reports in different types of format (HTML, PDF, Excel, Word, and etc). The following chart from the eclipse BIRT website illustrates well.<br />
<img src="http://www.eclipse.org/birt/phoenix/intro/images/birtarch.PNG" alt="Eclipse BIRT Arch" width="532" height="222" /></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3371750151985752";
google_ad_slot = "0950801022";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>Let&#8217;s come to <strong>Jasper</strong>. I use Jasper because there are two different things associated with Jasper: JasperReports and Jaspersoft. JasperReports is the open source java reporting library while Jaspersoft is a collection of software including JasperReports. Apparently, Jaspersoft is heading the BI direction straightforward as it includes more enterprise BI functions such as ETL, analysis, dashboard and etc.  It does not seem Jaspersoft is open source, so we here only talk about JasperReports.</p>
<p>JasperReports claims to be &#8220;the world&#8217;s most popular open source reporting engine&#8221;.  From it&#8217;s website, it says:</p>
<blockquote><p>It is entirely written in Java and it is able to use data coming from any kind of data source and produce pixel-perfect documents that can be viewed, printed or exported in a variety of document formats including HTML, PDF, Excel, OpenOffice and Word.</p></blockquote>
<p>Similar to Eclipse BIRT, JasperReports has a JasperReports Engine that reads data from a wide range of data sources (DB, XML, CSV and etc) and generates reports in different formats. This process is controlled via some configuration files or run time parameters, so it can be customized to an extend.  The following is the chart from the JasperReports website that shows the process.<br />
<img src="http://jasperforge.org/uploads/publish/jasperreportswebsite/trunk/images/highlights_jasperreports_2.gif" alt="JasperReports Architecture" /></p>
<p>It seems the bare JasperReports does not have a component that allow users to design reports （there&#8217;s an additional one called iReport for report design), which Eclipse BIRT has. Apparently, an additional report designer make the software more user friendly. However, in another sense, the lightweight of JasperReports makes it easier to be embedded/integrated in a bigger software system.</p>
<p>Stack Overflow has a question asking about the difference of the two tools: <a href="http://stackoverflow.com/questions/2513534/birt-vs-jasper-reports" onclick="javascript:pageTracker._trackPageview('/outbound/article/stackoverflow.com');">BIRT vs JasperReports</a> and someone gives a link that <a href="http://www.innoventsolutions.com/open-source-reporting-comparison.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.innoventsolutions.com');">compares BIRT, JasperReports and even Pentaho in terms of their reporting features</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://robin.mytechtip.com/2011/04/20/eclipse-birt-and-jasperreports/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lucene IndexWriter optimize() behavior change since version 3.0.3</title>
		<link>http://robin.mytechtip.com/2011/02/17/lucene-indexwriter-optimize-change-3-0-3/</link>
		<comments>http://robin.mytechtip.com/2011/02/17/lucene-indexwriter-optimize-change-3-0-3/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 22:58:40 +0000</pubDate>
		<dc:creator>robin</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[full-text]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[Lucene]]></category>
		<category><![CDATA[optimize]]></category>

		<guid isPermaLink="false">http://robin.mytechtip.com/?p=161</guid>
		<description><![CDATA[Lucene is a powerful full-text index and search development tool written in JAVA. Over more than ten years, Lucene has evolved to version 3 (stable version).
Recently, I upgraded Lucene library (the core jar file) from version 3.0.2 to version 3.0.3 (which was released in December 2010) in my project. The purpose of the upgrading is [...]]]></description>
			<content:encoded><![CDATA[<p>Lucene is a powerful full-text index and search development tool written in JAVA. Over more than ten years, Lucene has evolved to version 3 (stable version).</p>
<p>Recently, I upgraded Lucene library (the core jar file) from version 3.0.2 to version 3.0.3 (which was released in December 2010) in my project. The purpose of the upgrading is just for keeping up and sticking with a more bug-free release.</p>
<p>However, after upgrading, I noticed that the optimized index folder contains more index files than previously using version 3.0.2. That means the index merge during <code>IndexWriter.optimize()</code> stops at some point. I am not sure if the un-merged index file may cause any performance degradation during index search, but i am not satisfied with the fact that many files stay in the index folder (although it&#8217;s not too many).</p>
<p>After reading the <a href="http://lucene.apache.org/java/3_0_3/changes/Changes.html#3.0.3.changes_in_runtime_behavior" onclick="javascript:pageTracker._trackPageview('/outbound/article/lucene.apache.org');">change document for Lucene 3.0.3 release</a>, I realized that some changes had been made to avoid high disk usage during indexing. The original change log item from Lucene 3.0.3 is stated as follows:</p>
<blockquote><p><a href="http://issues.apache.org/jira/browse/LUCENE-2773" onclick="javascript:pageTracker._trackPageview('/outbound/article/issues.apache.org');">LUCENE-2773</a>: LogMergePolicy accepts a double noCFSRatio (default = 0.1), which means any time a merged segment is greater than 10% of the index size, it will be left in non-compound format even if compound format is on.  This change was made to reduce peak transient disk usage during optimize which increased due to <a href="http://issues.apache.org/jira/browse/LUCENE-2762" onclick="javascript:pageTracker._trackPageview('/outbound/article/issues.apache.org');">LUCENE-2762</a>.</p></blockquote>
<p>Since my index is not very very big and I don&#8217;t care about the &#8216;peak transient disk usage&#8221;,  I still want the index to be created and optimized in a cleaner way.  This means the merge should be still continued to form a whole compound format.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-3371750151985752";
google_ad_slot = "0950801022";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<br />
Obviously I now need to change the default Lucene indexing and optimizing behavior by adding extra code in my project. The following is my tweak:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #666666; font-style: italic;">// an IndexWriter instance created through method getWriter</span>
    IndexWriter writer <span style="color: #339933;">=</span> getWriter<span style="color: #009900;">&#40;</span>dir<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// The tweak starts here</span>
    MergePolicy mp <span style="color: #339933;">=</span> writer.<span style="color: #006633;">getMergePolicy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>mp <span style="color: #000000; font-weight: bold;">instanceof</span> LogByteSizeMergePolicy<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        LogByteSizeMergePolicy lbsmp <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>LogByteSizeMergePolicy<span style="color: #009900;">&#41;</span> mp<span style="color: #339933;">;</span>
        lbsmp.<span style="color: #006633;">setNoCFSRatio</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1.0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Compiled, deployed, run. Hooray! The cleaner index folder is back!</p>
]]></content:encoded>
			<wfw:commentRss>http://robin.mytechtip.com/2011/02/17/lucene-indexwriter-optimize-change-3-0-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OpenJPA Auto Detach Configuration and Memory Issues</title>
		<link>http://robin.mytechtip.com/2010/12/06/openjpa-auto-detach-memory-issues/</link>
		<comments>http://robin.mytechtip.com/2010/12/06/openjpa-auto-detach-memory-issues/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 06:10:09 +0000</pubDate>
		<dc:creator>robin</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[EntityManager]]></category>
		<category><![CDATA[memory leaking]]></category>
		<category><![CDATA[openjpa]]></category>

		<guid isPermaLink="false">http://robin.mytechtip.com/?p=149</guid>
		<description><![CDATA[When I was doing some work with OpenJPA, I found there is a possible memory leaking issue when OpenJPA is used for data access without the proper configuration of the parameter of auto detach (openjpa.AutoDetach).
The scenario that the memory issue may happen:

 One EntityManagerFactory and One EntityManager are used throughout the whole session;
The session contains [...]]]></description>
			<content:encoded><![CDATA[<p>When I was doing some work with OpenJPA, I found there is a possible memory leaking issue when OpenJPA is used for data access without the proper configuration of the parameter of auto detach (<a href="http://openjpa.apache.org/builds/2.0.1/apache-openjpa-2.0.1/docs/manual/ref_guide_conf_openjpa.html#openjpa.AutoDetach" onclick="javascript:pageTracker._trackPageview('/outbound/article/openjpa.apache.org');">openjpa.AutoDetach</a>).</p>
<p>The scenario that the memory issue may happen:</p>
<ul>
<li> One <code>EntityManagerFactory </code>and One <code>EntityManager </code>are used throughout the whole session;</li>
<li>The session contains a lot of queries, they are all read-only queries;</li>
<li> Most queries are to retrieve database records based on primary keys;</li>
<li>The records retrieved are approximately evenly distributed across primary keys;</li>
<li> The database being queried has a large amount of data.</li>
</ul>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3371750151985752";
google_ad_slot = "0950801022";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<br />
It seems that OpenJPA keeps references to data retrieved from the queries as cache. This prevents JVM garbage collecting them. Eventually, out of memory error happens.</p>
<p>This time, it seems that <a href="http://robin.mytechtip.com/2010/03/24/remember-to-clear-entity-manager-if-entities-no-longer-used/" >the call to <code>clear </code>method on <code>EntityManager </code></a>does not even work. Finally, we added the following properties and it seemed to solve the issue:</p>
<blockquote><p><code>openjpa.AutoDetach=nontx-read</code></p></blockquote>
<p>In fact, it is not a good practice to use <code>EntityManager </code>as shown in the scenario. Maybe the initial consideration is to re-use the single <code>EntityManager </code>as much as possible to help improve the performance of the session that is created in a batch process.</p>
<p>In general, the <code>EntityManager </code>object should not live in the whole long session. Instead it should be created on demand and closed and disregarded when finishing its unit of work. However, i haven&#8217;t got time to test how worse the performance can degrade if it is implemented this way.</p>
]]></content:encoded>
			<wfw:commentRss>http://robin.mytechtip.com/2010/12/06/openjpa-auto-detach-memory-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GWT CellTable Example (Using AsyncDataProvider)</title>
		<link>http://robin.mytechtip.com/2010/11/17/gwt-celltable-example-using-asyncdataprovider/</link>
		<comments>http://robin.mytechtip.com/2010/11/17/gwt-celltable-example-using-asyncdataprovider/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 05:25:52 +0000</pubDate>
		<dc:creator>robin</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://robin.mytechtip.com/?p=134</guid>
		<description><![CDATA[GWT version 2.1 has finally been released with the anticipated business level data presentation widgets and other interesting features. CellTable is one of the new widgets that supports pagination. Therefore, there no need to use PagingScrollTable in the gwt incubator or implementations in other third-party libraries.
From the Google official document on how to use data [...]]]></description>
			<content:encoded><![CDATA[<p>GWT version 2.1 has finally been released with the anticipated business level data presentation widgets and other interesting features. <code>CellTable</code> is one of the new widgets that supports pagination. Therefore, there no need to <a href="http://robin.mytechtip.com/2010/11/15/how-to-use-pagingscrolltable-in-the-gwt-incubator/" >use <code>PagingScrollTable</code> in the gwt incubator</a> or implementations in other third-party libraries.</p>
<p>From the <a href="http://code.google.com/webtoolkit/doc/latest/DevGuideUiCellWidgets.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/code.google.com');">Google official document on how to use data presentation widgets</a>, you can get some examples of using these cell widgets including <code>CellTable</code>. It also includes a simple example of using <code>CellTable</code> with <code>SimplePager</code> to implement pagination. That example uses <code>ListDataProvider</code> which requires all the data that needs to be paged to be set at the client (browser) side. However, in realty, the common practice is to load only one page of data from the server (mostly pulled from a database) to the browser in order to save the bandwidth and improve the response time.</p>
<p>Of course the document indicates there are ways to implement the asynchronized page data loading from remote server.  It mentions that (at the time of writing of this post) (<strong>Update: the new Google document does not have the following text anymore</strong>):</p>
<blockquote><p><del datetime="2011-01-25T04:37:14+00:00">&#8220;GWT also provides the abstract class <code>AsyncListViewAdapter</code>, which you can  override to connect to an asynchronous data source, such as a database  running on a server.  Just implement the onRangeChanged() method and  request the data in the new Range for the specified cell widget.  When  the data is returned, call updateRowCount() and/or updateRowData() to  push the data to the widgets.&#8221;</del>
</p></blockquote>
<p><del datetime="2011-01-25T04:37:14+00:00">However,  it seems the official GWT 2.1 release does not have the class <code>AsyncListViewAdapter</code>. Instead, <code>AsyncDataProvider</code> is found. (A document bug?)</del></p>
<p>To illustrate how to use <code>AsyncDataProvider</code>, I modified a simple example from GWT below. </p>
<p><strong>Please note the example do not actually calls the server to get the data. It should be quite easy to modify the example to do so as illustrated in the next code snippet.</strong><br />
<script type="text/javascript"><!--
google_ad_client = "pub-3371750151985752";
google_ad_slot = "0950801022";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Arrays</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Date</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.cell.client.DateCell</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.core.client.EntryPoint</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.cellview.client.CellTable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.cellview.client.Column</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.cellview.client.SimplePager</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.cellview.client.TextColumn</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.client.ui.RootPanel</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.user.client.ui.VerticalPanel</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.view.client.AsyncDataProvider</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gwt.view.client.HasData</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CellTableExample <span style="color: #000000; font-weight: bold;">implements</span> EntryPoint <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #008000; font-style: italic; font-weight: bold;">/**
   * A simple data type that represents a contact.
   */</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> Contact <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> address<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Date</span> birthday<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> name<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> Contact<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name, <span style="color: #003399;">Date</span> birthday, <span style="color: #003399;">String</span> address<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">name</span> <span style="color: #339933;">=</span> name<span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">birthday</span> <span style="color: #339933;">=</span> birthday<span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">address</span> <span style="color: #339933;">=</span> address<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #008000; font-style: italic; font-weight: bold;">/**
   * The list of data to display.
   */</span>
  @SuppressWarnings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;deprecation&quot;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> List<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;</span> CONTACTS <span style="color: #339933;">=</span> <span style="color: #003399;">Arrays</span>.<span style="color: #006633;">asList</span><span style="color: #009900;">&#40;</span>
      <span style="color: #000000; font-weight: bold;">new</span> Contact<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;John&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">80</span>, <span style="color: #cc66cc;">4</span>, <span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;123 Abc Avenue&quot;</span><span style="color: #009900;">&#41;</span>, 
      <span style="color: #000000; font-weight: bold;">new</span> Contact<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Joe&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">85</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">22</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;22 Lance Ln&quot;</span><span style="color: #009900;">&#41;</span>, 
      <span style="color: #000000; font-weight: bold;">new</span> Contact<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Tom&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">85</span>, <span style="color: #cc66cc;">3</span>, <span style="color: #cc66cc;">22</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;33 Lance Ln&quot;</span><span style="color: #009900;">&#41;</span>, 
      <span style="color: #000000; font-weight: bold;">new</span> Contact<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Jack&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">85</span>, <span style="color: #cc66cc;">4</span>, <span style="color: #cc66cc;">22</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;44 Lance Ln&quot;</span><span style="color: #009900;">&#41;</span>, 
      <span style="color: #000000; font-weight: bold;">new</span> Contact<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Tim&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">85</span>, <span style="color: #cc66cc;">5</span>, <span style="color: #cc66cc;">22</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;55 Lance Ln&quot;</span><span style="color: #009900;">&#41;</span>, 
      <span style="color: #000000; font-weight: bold;">new</span> Contact<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Mike&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">85</span>, <span style="color: #cc66cc;">6</span>, <span style="color: #cc66cc;">22</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;66 Lance Ln&quot;</span><span style="color: #009900;">&#41;</span>, 
      <span style="color: #000000; font-weight: bold;">new</span> Contact<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;George&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">46</span>, <span style="color: #cc66cc;">6</span>, <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span>,<span style="color: #0000ff;">&quot;77 Lance Ln&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onModuleLoad<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Create a CellTable.</span>
    <span style="color: #000000; font-weight: bold;">final</span> CellTable<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;</span> table <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CellTable<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// Display 3 rows in one page</span>
    table.<span style="color: #006633;">setPageSize</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Add a text column to show the name.</span>
    TextColumn<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;</span> nameColumn <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TextColumn<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      @Override
      <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getValue<span style="color: #009900;">&#40;</span>Contact object<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> object.<span style="color: #006633;">name</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    table.<span style="color: #006633;">addColumn</span><span style="color: #009900;">&#40;</span>nameColumn, <span style="color: #0000ff;">&quot;Name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Add a date column to show the birthday.</span>
    DateCell dateCell <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DateCell<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Column<span style="color: #339933;">&lt;</span>Contact, Date<span style="color: #339933;">&gt;</span> dateColumn <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Column<span style="color: #339933;">&lt;</span>Contact, Date<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span>dateCell<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      @Override
      <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Date</span> getValue<span style="color: #009900;">&#40;</span>Contact object<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> object.<span style="color: #006633;">birthday</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    table.<span style="color: #006633;">addColumn</span><span style="color: #009900;">&#40;</span>dateColumn, <span style="color: #0000ff;">&quot;Birthday&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Add a text column to show the address.</span>
    TextColumn<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;</span> addressColumn <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TextColumn<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      @Override
      <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getValue<span style="color: #009900;">&#40;</span>Contact object<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> object.<span style="color: #006633;">address</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    table.<span style="color: #006633;">addColumn</span><span style="color: #009900;">&#40;</span>addressColumn, <span style="color: #0000ff;">&quot;Address&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Associate an async data provider to the table</span>
	<span style="color: #666666; font-style: italic;">// XXX: Use AsyncCallback in the method onRangeChanged</span>
	<span style="color: #666666; font-style: italic;">// to actaully get the data from the server side</span>
    AsyncDataProvider<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;</span> provider <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AsyncDataProvider<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      @Override
      <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> onRangeChanged<span style="color: #009900;">&#40;</span>HasData<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;</span> display<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">int</span> start <span style="color: #339933;">=</span> display.<span style="color: #006633;">getVisibleRange</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getStart</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> end <span style="color: #339933;">=</span> start <span style="color: #339933;">+</span> display.<span style="color: #006633;">getVisibleRange</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getLength</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        end <span style="color: #339933;">=</span> end <span style="color: #339933;">&gt;=</span> CONTACTS.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> CONTACTS.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> end<span style="color: #339933;">;</span>
        List<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;</span> sub <span style="color: #339933;">=</span> CONTACTS.<span style="color: #006633;">subList</span><span style="color: #009900;">&#40;</span>start, end<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        updateRowData<span style="color: #009900;">&#40;</span>start, sub<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    provider.<span style="color: #006633;">addDataDisplay</span><span style="color: #009900;">&#40;</span>table<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    provider.<span style="color: #006633;">updateRowCount</span><span style="color: #009900;">&#40;</span>CONTACTS.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    SimplePager pager <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SimplePager<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    pager.<span style="color: #006633;">setDisplay</span><span style="color: #009900;">&#40;</span>table<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    VerticalPanel vp <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> VerticalPanel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    vp.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>table<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    vp.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>pager<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Add it to the root panel.</span>
    RootPanel.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>vp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>To make remote calls to retrieve table data from the server, The code snippet should look like the following.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Associate an async data provider to the table</span>
    AsyncDataProvider<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;</span> provider <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AsyncDataProvider<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      @Override
      <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> onRangeChanged<span style="color: #009900;">&#40;</span>HasData<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;</span> display<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> start <span style="color: #339933;">=</span> display.<span style="color: #006633;">getVisibleRange</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getStart</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> length <span style="color: #339933;">=</span> display.<span style="color: #006633;">getVisibleRange</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getLength</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        AsyncCallback<span style="color: #339933;">&lt;</span>List<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;&gt;</span> callback <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AsyncCallback<span style="color: #339933;">&lt;</span>List<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          @Override
          <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onFailure<span style="color: #009900;">&#40;</span><span style="color: #003399;">Throwable</span> caught<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">Window</span>.<span style="color: #006633;">alert</span><span style="color: #009900;">&#40;</span>caught.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
          @Override
          <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onSuccess<span style="color: #009900;">&#40;</span>List<span style="color: #339933;">&lt;</span>Contact<span style="color: #339933;">&gt;</span> result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            updateRowData<span style="color: #009900;">&#40;</span>start, result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">// The remote service that should be implemented</span>
        remoteService.<span style="color: #006633;">fetchPage</span><span style="color: #009900;">&#40;</span>start, length, callback<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://robin.mytechtip.com/2010/11/17/gwt-celltable-example-using-asyncdataprovider/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>How to use PagingScrollTable in the gwt incubator</title>
		<link>http://robin.mytechtip.com/2010/11/15/how-to-use-pagingscrolltable-in-the-gwt-incubator/</link>
		<comments>http://robin.mytechtip.com/2010/11/15/how-to-use-pagingscrolltable-in-the-gwt-incubator/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 06:01:49 +0000</pubDate>
		<dc:creator>robin</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://robin.mytechtip.com/?p=64</guid>
		<description><![CDATA[The core GWT library (prior to version 2.1) does not provide an official widget that allows for a table with pagination support. Instead, there is a widget in gwt incubator called PagingScrollTable that has the paging functionality.



However, the &#8220;official wiki document&#8221; does not provide enough detailed information to use this widget. Luckily someone has made [...]]]></description>
			<content:encoded><![CDATA[<p>The core GWT library (prior to version 2.1) does not provide an official widget that allows for a table with pagination support. Instead, there is a widget in gwt incubator called PagingScrollTable that has the paging functionality.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3371750151985752";
google_ad_slot = "0950801022";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>However, the &#8220;official wiki document&#8221; does not provide enough detailed information to use this widget. Luckily someone has made an illustrative example with informative documentation on <a href="http://zenoconsulting.wikidot.com/blog:17" onclick="javascript:pageTracker._trackPageview('/outbound/article/zenoconsulting.wikidot.com');">how to implement a table with pagination support using PagingScrollTable in gwt incubator</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://robin.mytechtip.com/2010/11/15/how-to-use-pagingscrolltable-in-the-gwt-incubator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Configure Spring beans.xml File: The Use of PropertyPlaceholderConfigurer</title>
		<link>http://robin.mytechtip.com/2010/06/09/spring-beans-xml-file-the-use-of-propertyplaceholderconfigurer/</link>
		<comments>http://robin.mytechtip.com/2010/06/09/spring-beans-xml-file-the-use-of-propertyplaceholderconfigurer/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 05:28:47 +0000</pubDate>
		<dc:creator>robin</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[beans.xml]]></category>
		<category><![CDATA[properties]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://robin.mytechtip.com/?p=117</guid>
		<description><![CDATA[


The file &#8220;beans.xml&#8221; used for you application is already a kind of configuration file. However, this file is designed for the developer who can quickly customize the application with less coding changes. It is not recommended for an end user to change the file.
For example, you can, of course, define the database connection properties in [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-3371750151985752";
google_ad_slot = "0950801022";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>The file &#8220;beans.xml&#8221; used for you application is already a kind of configuration file. However, this file is designed for the developer who can quickly customize the application with less coding changes. It is not recommended for an end user to change the file.</p>
<p>For example, you can, of course, define the database connection properties in the beans.xml file straight away. This way, every time a user wants the application to connect to a database at a different location, the beans.xml file needs to be modified. For a complicated application, the file can grow very complicated as well. Therefore, making changes to the beans.xml file directly may not seem obvious to the end user.</p>
<p>Fortunately, Spring have already come up with a solution for this problem. You can define the properties in the &#8220;beans.xml&#8221; file with place holders and use the Spring provided bean <code><strong>PropertyPlaceholderConfigurer</strong></code> to replace the place holders with the value from a properties file. Here is <a href="http://static.springsource.org/spring/docs/2.5.x/reference/beans.html#beans-factory-extension-factory-postprocessors" onclick="javascript:pageTracker._trackPageview('/outbound/article/static.springsource.org');">an example of the use of PropertyPlaceholderConfigurer</a>.</p>
<p>In the example from the above link, it specifies one location for the properties file with a classpath: &#8220;classpath:com/foo/jdbc.properties&#8221;. In addition to that, you can also specify a file on your file system. When using a file on file system, remember to add &#8220;file:/&#8221; to an absolute path; otherwise, Spring will treat it as a relative path even the value starts with &#8220;/&#8221;.</p>
<p><code>PropertyPlaceholderConfigurer</code> also allows you to define some default values using the property &#8220;<strong>properties</strong>&#8220;. The following is an example of using the default values if the file defined by &#8220;<strong>locations</strong>&#8221; property does not exist. Please note setting &#8220;<strong>ignoreResourceNotFound</strong>&#8221; to <strong>true </strong>is necessary. If not set, the application will throw exception if the defined property does not exist even we&#8217;ve defined the default values.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ignoreResourceNotFound&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;locations&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>file:///etc/app/jdbc.properties<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;properties&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;props<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;jdbc.driverClassName&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>com.mysql.jdbc.Driver<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prop<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;jdbc.url&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>jdbc:mysql://localhost:3306/mytechtip<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prop<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;jdbc.username&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>jdbc_username<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prop<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;jdbc.password&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>xxx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prop<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/props<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;dataSource&quot;</span> <span style="color: #000066;">destroy-method</span>=<span style="color: #ff0000;">&quot;close&quot;</span> </span>
<span style="color: #009900;">    <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.apache.commons.dbcp.BasicDataSource&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;driverClassName&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${jdbc.driverClassName}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;url&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${jdbc.url}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;username&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${jdbc.username}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;password&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${jdbc.password}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://robin.mytechtip.com/2010/06/09/spring-beans-xml-file-the-use-of-propertyplaceholderconfigurer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Configure Spring beans.xml File: Collection properties and EntityManagerFactory Examples</title>
		<link>http://robin.mytechtip.com/2010/06/07/configure-spring-beans-xml-collection-properties-and-entitymanagerfactory-examples/</link>
		<comments>http://robin.mytechtip.com/2010/06/07/configure-spring-beans-xml-collection-properties-and-entitymanagerfactory-examples/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 05:43:51 +0000</pubDate>
		<dc:creator>robin</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[beans.xml]]></category>
		<category><![CDATA[EntityManager]]></category>
		<category><![CDATA[openjpa]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://robin.mytechtip.com/?p=106</guid>
		<description><![CDATA[


Java beans in Spring can also have their collection properties populated in the beans.xml file. The collection properties here mean things like List, Map and Array.
For example, if you want to create a JPA EntityManagerFactory with a set of connection properties, these properties can be configured in beans.xml like this:

&#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62;
&#60;beans xmlns=&#34;http://www.springframework.org/schema/beans&#34;
  xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34; [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-3371750151985752";
google_ad_slot = "0950801022";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>Java beans in Spring can also have their collection properties populated in the beans.xml file. The collection properties here mean things like List, Map and Array.</p>
<p>For example, if you want to create a JPA EntityManagerFactory with a set of connection properties, these properties can be configured in beans.xml like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">  <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> </span>
<span style="color: #009900;">  <span style="color: #000066;">xmlns:p</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/p&quot;</span></span>
<span style="color: #009900;">  <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;entityManagerFactoryCreator&quot;</span> </span>
<span style="color: #009900;">    <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.mytechtip.example.EntityManagerFactoryCreator&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;persistenceUnitName&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;HRMN_Repository&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jpaProperties&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;props<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;openjpa.ConnectionURL&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>the_url<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prop<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;openjpa.ConnectionDriverName&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>the_driver_class_name<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prop<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;openjpa.ConnectionUserName&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>the_user_name<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prop<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;openjpa.ConnectionPassword&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>the_password<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prop<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/props<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Here, jpaProperties in the actual java class &#8220;<code>EntityManagerFactoryCreator</code>&#8221; is an instance of <code>Properties</code>. And you can just use this properties to create EntityManagerFactory.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #666666; font-style: italic;">// ...</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Properties</span> jpaProperties<span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//...</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setJpaProperties<span style="color: #009900;">&#40;</span><span style="color: #003399;">Properties</span> prop<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">jpaProperties</span> <span style="color: #339933;">=</span> prop<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #666666; font-style: italic;">// ...</span>
    <span style="color: #000000; font-weight: bold;">public</span> EntityManagerFactory create<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> Persistence.<span style="color: #006633;">createEntityManagerFactory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;myPersistenceUnit&quot;</span>, prop<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Actually, Spring already have something similar for you to access EntityManagerFactory with ease. The beans used for the task are: </p>
<ul>
<li><code>org.springframework.orm.jpa.LocalEntityManagerFactoryBean</code></li>
<li><code>org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean</code></li>
</ul>
<p>More information / examples can be found <a href="http://static.springsource.org/spring/docs/2.5.x/reference/orm.html#orm-jpa-setup" onclick="javascript:pageTracker._trackPageview('/outbound/article/static.springsource.org');">here about the support of JPA entity manager factory creatation in Spring</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://robin.mytechtip.com/2010/06/07/configure-spring-beans-xml-collection-properties-and-entitymanagerfactory-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Configure Spring beans.xml File: Basic Usage</title>
		<link>http://robin.mytechtip.com/2010/05/18/how-to-configure-spring-beans-xml-file-basic-usage/</link>
		<comments>http://robin.mytechtip.com/2010/05/18/how-to-configure-spring-beans-xml-file-basic-usage/#comments</comments>
		<pubDate>Tue, 18 May 2010 03:55:42 +0000</pubDate>
		<dc:creator>robin</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[beans.xml]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://robin.mytechtip.com/?p=76</guid>
		<description><![CDATA[how to configure spring beans.xml file with more flexibility
Spring is a very flexible java framework. In spring, beans are the main building bricks of an application while the bean configuration file (mostly beans.xml) acts as cement that glues the beans together.



The file beans.xml also allows beans to be initialized with particular values. For example, you [...]]]></description>
			<content:encoded><![CDATA[<p>how to configure spring beans.xml file with more flexibility</p>
<p>Spring is a very flexible java framework. In spring, beans are the main building bricks of an application while the bean configuration file (mostly beans.xml) acts as cement that glues the beans together.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3371750151985752";
google_ad_slot = "0950801022";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>The file beans.xml also allows beans to be initialized with particular values. For example, you can set the JDBC driver, user name, password for a java bean that is in charge of database connection in the beans.xml file as the following example.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:p</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/p&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;dbManager&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.mytechtip.example.DbManager&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jdbcDriver&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;com.mysql.jdbc.Driver&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jdbcUrl&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;jdbc:mysql://localhost/app&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jdbcUser&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;app&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jdbcPassword&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;app&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>So in the java class &#8220;com.example.app.DbManager&#8221;, you can make JDBC connections with the fields/properties value set as in the beans.xml file. The DbManager class may look as simple as the following:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.mytechtip.example</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.Connection</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.DriverManager</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DbManager <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> jdbcDriver<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> jdbcUrl<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> jdbcUser<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> jdbcPassword<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getJdbcDriver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> jdbcDriver<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setJdbcDriver<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> jdbcDriver<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">jdbcDriver</span> <span style="color: #339933;">=</span> jdbcDriver<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// more getters and setters ...</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Connection</span> getConnection<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
             <span style="color: #000000; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span> <span style="color: #009900;">&#40;</span>getJdbcDriver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
             <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #003399;">DriverManager</span>.<span style="color: #006633;">getConnection</span><span style="color: #009900;">&#40;</span>
                   getJdbcUrl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, getJdbcUser<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, getJdbcPassword<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>There is one note: </strong>These properties are set after the constructor of the bean is called. So if you try to make a JDBC connection in the constructor with the fields, you will mostly get exceptions.</p>
<p>Anyway, this is a very simple example of the bean configuration. We will show more examples to learn the flexibility of the bean configuration in Spring.</pre>
]]></content:encoded>
			<wfw:commentRss>http://robin.mytechtip.com/2010/05/18/how-to-configure-spring-beans-xml-file-basic-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

