<?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>Dimuthu&#039;s Blog</title>
	<atom:link href="http://www.dimuthu.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dimuthu.org</link>
	<description>Waiting for your comments</description>
	<lastBuildDate>Wed, 21 Dec 2011 05:39:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>WSO2 Web Services Framework for PHP 2.1.0 Released</title>
		<link>http://www.dimuthu.org/blog/2010/07/07/wso2-web-services-framework-for-php-2-1-0-released/</link>
		<comments>http://www.dimuthu.org/blog/2010/07/07/wso2-web-services-framework-for-php-2-1-0-released/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 12:42:52 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wsf/php]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=1099</guid>
		<description><![CDATA[WSO2 just released a newer version of the popular web services framework for php (WSF/PHP). It has lot of bug fixes + performance improvement.  And it now support PHP 5.3. So you can use wsf/php with the latest php version. &#8230; <a href="http://www.dimuthu.org/blog/2010/07/07/wso2-web-services-framework-for-php-2-1-0-released/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>WSO2 just released a newer version of the popular web services framework for php (WSF/PHP). It has lot of bug fixes + performance improvement.  And it now support PHP 5.3. So you can use wsf/php with the latest php version.</p>
<p>You can download the new release from <a href="http://wso2.org/downloads/wsf/php">http://wso2.org/downloads/wsf/php</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2010/07/07/wso2-web-services-framework-for-php-2-1-0-released/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WSO2 Stratos: WSO2 Brings The Whole SOA Stack to The Cloud</title>
		<link>http://www.dimuthu.org/blog/2010/06/03/wso2-stratos-wso2-bring-the-whole-soa-stack-to-the-cloud/</link>
		<comments>http://www.dimuthu.org/blog/2010/06/03/wso2-stratos-wso2-bring-the-whole-soa-stack-to-the-cloud/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 10:59:44 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[app server]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[gadget server]]></category>
		<category><![CDATA[Governance Registry]]></category>
		<category><![CDATA[identity]]></category>
		<category><![CDATA[mashup server]]></category>
		<category><![CDATA[stratos]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[SOA]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=1093</guid>
		<description><![CDATA[WSO2 announced that the SOA stack that they provided as downloadable packages are now available in the cloud as hosted instances with the code name WSO2 Stratos. You can try them out for free from https://cloud.wso2.com. You can register your &#8230; <a href="http://www.dimuthu.org/blog/2010/06/03/wso2-stratos-wso2-bring-the-whole-soa-stack-to-the-cloud/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>WSO2 announced that the SOA stack that they provided as downloadable packages are now available in the cloud as hosted instances with the code name WSO2 Stratos. You can try them out for free from <a href="https://cloud.wso2.com">https://cloud.wso2.com</a>. You can register your organization for an account in the WSO2 Stratos by clicking the &#8216;Register&#8217; button in the home page. You can find a detail guide on &#8216;How to register for WSO2 Stratos&#8217; from Charitha&#8217;s blog, <a href="http://charithaka.blogspot.com/2010/06/wso2-stratos-introducing-wso2.html">http://charithaka.blogspot.com/2010/06/wso2-stratos-introducing-wso2.html</a>.</p>
<p>At the registration, you will be asked to provide a username and password for the admin account. Use this credential to login as admin for the Stratos services and surf through the products. Here is a brief introduction on all the products currently available.</p>
<ul>
<li><a href="https://governance.cloud.wso2.com">Stratos Governance</a>: Store and govern your services, wsdls, schemas, policies and other SOA artifacts</li>
<li><a href="https://identity.cloud.wso2.com">Stratos Identity</a>: Manage user bases, authentication mechanisms, permissions and all the identity aspects of your enterprise.</li>
<li><a href="https://appserver.cloud.wso2.com">Stratos Application Server</a>: Host your web apps, web services and manage their QoS aspects like security, reliability.</li>
<li><a href="https://gadget.cloud.wso2.com">Stratos Gadgets Server</a>: Write and host gadgets complaint with Google gadget standards.</li>
<li><a href="https://mashup.cloud.wso2.com">Stratos Mashup Server</a>: Write mashup using scripting languages like javascript.</li>
<li><a href="https://bam.cloud.wso2.com">Stratos Business Activity Monitor</a>: Monitor activities of your services.</li>
<li>Stratos Enterprise Service Bus: Coming soon with message routing, intermediate message transformations, task scheduling and many more features.</li>
</ul>
<p>With this release WSO2 bring complete SOA stack to the cloud, Now your enterprise can enjoy the power of SOA without the hassle of maintaining your own SOA infrastructure.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2010/06/03/wso2-stratos-wso2-bring-the-whole-soa-stack-to-the-cloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Web Services: Webinar From WSO2 And Zend</title>
		<link>http://www.dimuthu.org/blog/2010/05/19/php-web-services-webinar-from-wso2-and-zend/</link>
		<comments>http://www.dimuthu.org/blog/2010/05/19/php-web-services-webinar-from-wso2-and-zend/#comments</comments>
		<pubDate>Wed, 19 May 2010 13:30:25 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wsf/php]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[webinar]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=1088</guid>
		<description><![CDATA[WSO2 and Zend jointly present a webinar titling &#8220;PHP Web Services: Why You Should Care&#8221; on 26th of May, 2010. The webinar will mainly focus on the following aspects, • Understand Web services development best practices • Discuss Web service &#8230; <a href="http://www.dimuthu.org/blog/2010/05/19/php-web-services-webinar-from-wso2-and-zend/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>WSO2 and Zend jointly present a webinar titling &#8220;<a href="http://wso2.org/library/webinars/2010/05/webinar-php-web-services-you-should-care">PHP Web Services: Why You Should Care</a>&#8221; on 26th of May, 2010. The webinar will mainly focus on the following aspects,<br />
• Understand Web services development best practices<br />
• Discuss Web service myths and pitfalls<br />
• Learn about prominent PHP Web services extensions<br />
• Watch a demo of building Web Services with both the Zend Framework and WSO2 Web Services Framework for PHP.</p>
<p>You can find more information about the webinar and the link to registration here, <a href="http://wso2.org/library/webinars/2010/05/webinar-php-web-services-you-should-care">http://wso2.org/library/webinars/2010/05/webinar-php-web-services-you-should-care</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2010/05/19/php-web-services-webinar-from-wso2-and-zend/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Metering Java Reader and Writer Objects</title>
		<link>http://www.dimuthu.org/blog/2010/05/05/metering-java-reader-and-writer-objects/</link>
		<comments>http://www.dimuthu.org/blog/2010/05/05/metering-java-reader-and-writer-objects/#comments</comments>
		<pubDate>Wed, 05 May 2010 03:38:25 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[measure]]></category>
		<category><![CDATA[reader]]></category>
		<category><![CDATA[writer]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=1080</guid>
		<description><![CDATA[Last few days I was working on measuring the bandwidth consumed by different java objects passed to our remote interfaces. It was simple task to do it with &#8216;String&#8217; objects, byte arrays as we can directly get the sizes of &#8230; <a href="http://www.dimuthu.org/blog/2010/05/05/metering-java-reader-and-writer-objects/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Last few days I was working on measuring the bandwidth consumed by different java objects passed to our remote interfaces. It was simple task to do it with &#8216;String&#8217; objects, byte arrays as we can directly get the sizes of them using String.length and byte[].size() methods.</p>
<p>But there were objects of type <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/Reader.html">Reader</a> and <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/Writer.html">Writer</a>, which is supposed to transfer big chunk of data. There also we could load all the data to memory and measure the sizes.</p>
<pre><span style="color: #808080; font-style: italic;">// measuring reader size - memory inefficient method</span>

<span style="color: #808080; font-style: italic;">// read all data to buffer and measure the length</span>
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AStringReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">StringReader</span></a> stringReader = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AStringReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">StringReader</span></a><span style="color: #66cc66;">(</span>reader<span style="color: #66cc66;">)</span>;
<span style="color: #993333;">int</span> size = stringReader.<span style="color: #006600;">toString</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>.<span style="color: #006600;">length</span>;

doRealWork<span style="color: #66cc66;">(</span>stringReader<span style="color: #66cc66;">)</span>;</pre>
<p>But that will consume lot of memory (even possible to exceed available heap size). So it is wrong to use the above method to measure the size of reader or writer.</p>
<p>Anyway there is an easy solution for the problem. We can use the design of Reader API itself to measure it size. The Reader interface has a method that read the data by small chunks. We just need to intercept that call and measure the size of each small chunk and add them all. For that we need to implement the Reader interface in to a custom class (say &#8216;MonitoredReader&#8217;). Here is how it is implemented.</p>
<pre><span style="color: #a1a100;">import java.io.IOException;</span>
<span style="color: #a1a100;">import java.io.Reader;</span>

<span style="color: #808080; font-style: italic;">/**
 * The class to intercept the read method and calculate
 * the number of reads
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MonitoredReader <span style="color: #000000; font-weight: bold;">extends</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Reader</span></a> <span style="color: #66cc66;">{</span>

    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Reader</span></a> reader;
    <span style="color: #993333;">int</span> totalReadSize;

    <span style="color: #808080; font-style: italic;">/**
     * constructor that wraps the original reader object
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> MonitoredReader<span style="color: #66cc66;">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Reader</span></a> reader<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">reader</span> = reader;
        totalReadSize = <span style="color: #cc66cc;">0</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #808080; font-style: italic;">/**
     * The method to call by the user to read the data. We will just calculate the amount
     * of data read here.
     *
     * @param cBuf destination buffer
     * @param off  offset at which to start storing characters
     * @param len  maximum number of characters to read
     *
     * @return the number of characters read, or -1 if the end of the stream has been reached
     * @throws IOException if an I/O error occurs
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">int</span> read<span style="color: #66cc66;">(</span><span style="color: #993333;">char</span> cbuf<span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span>, <span style="color: #993333;">int</span> off, <span style="color: #993333;">int</span> len<span style="color: #66cc66;">)</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AIOException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">IOException</span></a> <span style="color: #66cc66;">{</span>

        <span style="color: #993333;">int</span> read = reader.<span style="color: #006600;">read</span><span style="color: #66cc66;">(</span>cbuf, off, len<span style="color: #66cc66;">)</span>;
        totalReadSize += read;
        <span style="color: #000000; font-weight: bold;">return</span> read;
    <span style="color: #66cc66;">}</span>

    <span style="color: #808080; font-style: italic;">/**
     * Method to call after finishing reading the data. We will just pass the call to the
     * original reader
     */</span>

    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> close<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AIOException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">IOException</span></a> <span style="color: #66cc66;">{</span>
        reader.<span style="color: #006600;">close</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #808080; font-style: italic;">/**
     * Custom method that will return the total size of read data
     *
     * @return the size of the data read
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">int</span> getTotalReadSize<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
        <span style="color: #000000; font-weight: bold;">return</span> totalReadSize;
    <span style="color: #66cc66;">}</span>
<span style="color: #66cc66;">}</span></pre>
<p>So our code to measure the size will simple reduce to the following piece of code.</p>
<pre><span style="color: #808080; font-style: italic;">// measuring reader size - memory efficient method</span>

<span style="color: #808080; font-style: italic;">// just wrap the original reader with our custom reader</span>
MonitoredReader monitoredReader = <span style="color: #000000; font-weight: bold;">new</span> MonitoredReader<span style="color: #66cc66;">(</span>reader<span style="color: #66cc66;">)</span>;

<span style="color: #808080; font-style: italic;">// pass our custom reader to the real work</span>
doRealWork<span style="color: #66cc66;">(</span>monitoredReader<span style="color: #66cc66;">)</span>;

<span style="color: #808080; font-style: italic;">// get the size read in the real work</span>
<span style="color: #993333;">int</span> size = monitoredReader.<span style="color: #006600;">getTotalReadSize</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</pre>
<p>Similarly we can use this method to get the data size of the writer. (amount of data written to the writer).</p>
<pre><span style="color: #a1a100;">import java.io.IOException;</span>
<span style="color: #a1a100;">import java.io.Writer;</span>

<span style="color: #808080; font-style: italic;">/**
 * The class to intercept the write method and calculate
 * the number of writes
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MonitoredWriter <span style="color: #000000; font-weight: bold;">extends</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AWriter+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Writer</span></a> <span style="color: #66cc66;">{</span>

    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AWriter+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Writer</span></a> writer;
    <span style="color: #993333;">int</span> totalWrittenSize;

    <span style="color: #808080; font-style: italic;">/**
     * constructor that wraps the original writer object
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> MonitoredWriter<span style="color: #66cc66;">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AWriter+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Writer</span></a> writer<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">writer</span> = writer;
        totalWrittenSize = <span style="color: #cc66cc;">0</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #808080; font-style: italic;">/**
     * The method to call by the user to write the data. We will just calculate the amount
     * of data written here.
     *
     * @param  cBuf  Array of characters
     * @param  off   Offset from which to start writing characters
     * @param  len   Number of characters to write
     *
     * @throws java.io.IOException  If an I/O error occurs
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> write<span style="color: #66cc66;">(</span><span style="color: #993333;">char</span> cbuf<span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span>, <span style="color: #993333;">int</span> off, <span style="color: #993333;">int</span> len<span style="color: #66cc66;">)</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AIOException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">IOException</span></a> <span style="color: #66cc66;">{</span>
        totalWrittenSize += <span style="color: #66cc66;">(</span>len - off<span style="color: #66cc66;">)</span>;
        writer.<span style="color: #006600;">write</span><span style="color: #66cc66;">(</span>cbuf, off, len<span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #808080; font-style: italic;">/**
     * Method to call after finishing writing the data. We will just pass the call to the
     * original writer
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> close<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AIOException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">IOException</span></a> <span style="color: #66cc66;">{</span>
        writer.<span style="color: #006600;">close</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #808080; font-style: italic;">/**
     * flush already written data. Here also we just pass the call to the original writer
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> flush<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AIOException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">IOException</span></a> <span style="color: #66cc66;">{</span>
        writer.<span style="color: #006600;">flush</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #808080; font-style: italic;">/**
     * Custom method that will return the total size of written data
     *
     * @return the size of the data written
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">int</span> getTotalWrittenSize<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
        <span style="color: #000000; font-weight: bold;">return</span> totalWrittenSize;
    <span style="color: #66cc66;">}</span>
<span style="color: #66cc66;">}</span></pre>
<p>Here is how it is used in measuring the writer size.</p>
<pre><span style="color: #808080; font-style: italic;">// measuring writer size - memory efficient method</span>

<span style="color: #808080; font-style: italic;">// just wrap the original writer with our custom writer</span>
MonitoredWriter monitoredWriter = <span style="color: #000000; font-weight: bold;">new</span> MonitoredWriter<span style="color: #66cc66;">(</span>writer<span style="color: #66cc66;">)</span>;

<span style="color: #808080; font-style: italic;">// pass our custom wrter to the real work</span>

doRealWork<span style="color: #66cc66;">(</span>monitoredWriter<span style="color: #66cc66;">)</span>;

<span style="color: #808080; font-style: italic;">// get the size written in the real work</span>
<span style="color: #993333;">int</span> size = monitoredWriter.<span style="color: #006600;">getTotalWrittenSize</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</pre>
<p>Anyway like every good methods, there are drawbacks of using these methods to measure the data size on Reader and Writer objects.</p>
<p>If we take measuring the bandwidth consumed by a reader in a remote interface, this gives a slightly low value because this particular code only provide the size of the data read by the end user application and not by the network hardware layers. But actually these low layers read more data and keep it in a buffer which is not measured here. But if we assume that most of the time the end user application read all the data from the reader (and very rarely read portion of data and give up), this give nearly accurate value.</p>
<p>The other drawback could be the performance degradation  by wrapping the reader/writer with our custom implementation. But mostly reader and writers are used in IO bound operations (like to read through network or files), so going through an another layer does really little effect to the overall performance. And after all the &#8216;Observer effect theory&#8217; says we can&#8217;t measure anything without causing any effect to the actual cause&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2010/05/05/metering-java-reader-and-writer-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WSO2 Governance Registry, WSO2 Identity Server, WSO2 ESB, WSO2 Web Service Application Server Released</title>
		<link>http://www.dimuthu.org/blog/2010/05/03/wso2-governance-registry-wso2-identity-server-wso2-esb-wso2-web-service-application-server-released/</link>
		<comments>http://www.dimuthu.org/blog/2010/05/03/wso2-governance-registry-wso2-identity-server-wso2-esb-wso2-web-service-application-server-released/#comments</comments>
		<pubDate>Mon, 03 May 2010 04:02:59 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[carbon]]></category>
		<category><![CDATA[esb]]></category>
		<category><![CDATA[Governance Registry]]></category>
		<category><![CDATA[identity]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[wsas]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[governance registry]]></category>
		<category><![CDATA[web service application server]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=1074</guid>
		<description><![CDATA[WSO2 has released new versions of their SOA platform products including WSO2 Governance Registry, WSO2 Identity Server, WSO2 ESB, WSO2 Web Service Application Server. This is a major version upgrade of these products introducing many features. ESB: Priority based mediation &#8230; <a href="http://www.dimuthu.org/blog/2010/05/03/wso2-governance-registry-wso2-identity-server-wso2-esb-wso2-web-service-application-server-released/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>WSO2 has released new versions of their SOA platform products including <a href="http://wso2.org/projects/governance-registry">WSO2 Governance Registry</a>, <a href="http://wso2.org/projects/identity">WSO2 Identity Server</a>, <a href="http://wso2.org/projects/esb/java">WSO2 ESB</a>, <a href="http://wso2.org/projects/wsas/java">WSO2 Web Service Application Server</a>. This is a major version upgrade of these products introducing many features.</p>
<p><a href="http://wso2.org/projects/esb/java">ESB</a>:</p>
<ul>
<li>Priority based mediation through priority executors</li>
<li>WS-Discovery support and dynamic endpoint discovery</li>
<li>Message Relay for efficient pass through of messages</li>
<li>Component manager to install and uninstall features (provisioning support)</li>
<li>Common Internet File System (CIFS) support through the VFS transport</li>
<li>File locking functionality in the VFS transport to support concurrent polling</li>
<li>Smooks mediator for efficient message transformation</li>
<li>Enrich mediator for smart message manipulation</li>
<li>OAuth mediator for 2-legged OAuth support</li>
<li>Default endpoint UI</li>
<li>Hot deploy and hot update configuration elements (sequences, endpoints, proxy services etc)</li>
<li>Transport level statistics collection and monitoring</li>
<li>POX security support</li>
<li>Dependency detection and alerting for mediation configuration elements</li>
<li>Mediation statistics API and custom mediation statistics consumers</li>
<li>Multiple certificate/identity support in the NHTTP transport sender</li>
<li>Improved logging capabilities for the NHTTP transport</li>
<li>Templates based proxy service development in the UI</li>
<li>Dashboard to monitor server environment and runtime</li>
<li>Easy creation and management capabilities for dynamic sequences and endpoints</li>
<li>Pagination to service management, endpoint management and sequence management UIs</li>
<li>Obtaining resources like WSDL&#8217;s through web proxy servers</li>
</ul>
<p><a href="http://wso2.org/projects/governance-registry">Governance Registry</a></p>
<ul>
<li>Gadgets for impact analysis on services and registry resources</li>
<li>WSDL custom view</li>
<li>Dynamic Handler configuration</li>
<li>Handler simulator</li>
<li>Tree-based Resource view</li>
<li>API to govern SOA artifacts</li>
<li>Complete Web Services API for Registry</li>
<li>Improved options for Service discovery</li>
<li>WS-Discovery support</li>
<li>Scripting support for lifecycle management</li>
<li>Improved P2 based provisioning and feature management support</li>
<li>Support for adding remote mounts</li>
<li>Platform, and Group/Cluster based deployment model</li>
<li>Support for multiple server instances</li>
<li>E-mail verification for subscriptions</li>
<li>Support for deleting tags and comments</li>
<li>Support for PostgreSQL and DB2 DBMS</li>
<li>Paged activity and resource search</li>
<li>Hierarchical permission model with granular and extensible permissions</li>
<li>Ability to upload metadata (in addition to importing)</li>
<li>Governance Archive for uploading WSDLs and Schemas with imports</li>
<li>Ability to update resource content by uploading</li>
<li>Rich text editor for editing text resources</li>
<li>XML editor for editing handler, lifecycle and service UI configurations</li>
</ul>
<p><a href="http://wso2.org/projects/wsas/java">Web Service Application Server</a> (WSO2 WSAS):</p>
<ul>
<li>Component Manager &#8211; The UI tool to install/uninstall Carbon featrues.</li>
<li> Various bug fixes &amp; enhancements including architectural improvements         to Apache Axis2, Apache Rampart, Apache Sandesha2         , WSO2 Carbon &amp; other projects.</li>
<li>Equinox P2 based provisioning support &#8211;         extend your WSAS instance by installin new P2 features. See         <a href="https://wso2.org/wiki/display/carbon/p2-based-provisioning-support"> P2 based provisioning in WSO2 Carbon </a></li>
<li>Hierarchical service support for Axis2 services, JAX-WS services, Spring         services &amp; Jar services</li>
<li>Report generation for deployed services</li>
</ul>
<p><a href="http://wso2.org/projects/identity">Identity Server</a>:</p>
<ul>
<li>SAML 2.0 based Single Sign-on support</li>
<li>OAuth Support</li>
<li>Support for bulk-user import</li>
<li>Various bug fixes and enhancements including architectural improvements to Apache Axis2, Apache Rampart, Apache Sandesha2 , WSO2 Carbon and other projects.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2010/05/03/wso2-governance-registry-wso2-identity-server-wso2-esb-wso2-web-service-application-server-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Webinar: WSO2 Business Activity Monitor for Agile Enterprises</title>
		<link>http://www.dimuthu.org/blog/2010/02/03/webinar-wso2-business-activity-monitor-for-agile-enterprises/</link>
		<comments>http://www.dimuthu.org/blog/2010/02/03/webinar-wso2-business-activity-monitor-for-agile-enterprises/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 02:03:45 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[BAM]]></category>
		<category><![CDATA[Governance]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[agile enterprsie]]></category>
		<category><![CDATA[buisness activity monitor]]></category>
		<category><![CDATA[report]]></category>
		<category><![CDATA[webinar]]></category>
		<category><![CDATA[wso2]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=1070</guid>
		<description><![CDATA[Samisa Abeysinghe, the directory of engineering at WSO2 will present a webinar on Building an Agile Enterprise With Business Activity Monitoring today (3rd February 2010). There he will provide an overview of WSO2 Business Activity Monitor (WSO2 BAM), the latest &#8230; <a href="http://www.dimuthu.org/blog/2010/02/03/webinar-wso2-business-activity-monitor-for-agile-enterprises/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://samisa-abeysinghe.blogspot.com">Samisa Abeysinghe</a>, the directory of engineering at WSO2 will present a <a href="http://wso2.org/library/webinars/02-03-2010-webinar-building-agile-enterprise-business-activity-monitoring/?otbdate=22110">webinar on Building an Agile Enterprise With Business Activity Monitoring</a> today (3rd February 2010).</p>
<p>There he will provide an overview of <a href="http://wso2.org/projects/bam">WSO2 Business Activity Monitor (WSO2 BAM)</a>, the latest product from the WSO2 Carbon platform, including its built-in dashboard to view analytics , reports of past and present activities of the enterprise SOA infrastructure and how these information can be used in tactical and strategic decision making.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2010/02/03/webinar-wso2-business-activity-monitor-for-agile-enterprises/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Access WSO2 Governance as a Service From Remote Registry</title>
		<link>http://www.dimuthu.org/blog/2010/01/11/access-wso2-governance-as-a-service-from-remote-registry/</link>
		<comments>http://www.dimuthu.org/blog/2010/01/11/access-wso2-governance-as-a-service-from-remote-registry/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 16:36:45 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[GaaS]]></category>
		<category><![CDATA[Governance]]></category>
		<category><![CDATA[Governance Registry]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[governance as a service]]></category>
		<category><![CDATA[governance registry]]></category>
		<category><![CDATA[remote registry]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=1065</guid>
		<description><![CDATA[WSO2 Governance as a Service is a hosted instance of WSO2 Governance Registry with multi-tenant support. WSO2 Governance as a Service provide you almost all the functionalities provided with the Governance Registry targeting the enterprise SOA governance, same time it &#8230; <a href="http://www.dimuthu.org/blog/2010/01/11/access-wso2-governance-as-a-service-from-remote-registry/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://governance.cloud.wso2.com">WSO2 Governance as a Service</a> is a hosted instance of <a href="http://wso2.org/projects/governance-registry">WSO2 Governance Registry</a> with multi-tenant support. WSO2 Governance as a Service provide you almost all the functionalities provided with the Governance Registry targeting the enterprise SOA governance, same time it provides all the advantages  inherent with the Software as a Service model.</p>
<p>Here I&#8217;m talking about how to use a popular feature available in Governance Registry, inside WSO2 Governance as a Service. i.e. <a href="http://wso2.org/project/registry/3.0.2/docs/developer_guide/remote_registry_client.html">Remote Registry Client</a>. With Remote Registry Client, you can access the resources in registry programatically. It uses atom/pub protocol to communicate with the registry server.</p>
<p>Here is an example of using Remote Registry Client. I assumed I have an account with domain name &#8216;example.com&#8217; with a user name &#8216;example_user&#8217; (&#8216;example_password&#8217;). You have to change this to valid values before running this code, You can create an account in Governance as a Service freely for a limited use.</p>
<pre><span style="color: #a1a100;">import java.net.URL;</span>
<span style="color: #a1a100;">import org.wso2.carbon.registry.core.Registry;</span>
<span style="color: #a1a100;">import org.wso2.carbon.registry.core.Resource;</span>
<span style="color: #a1a100;">import org.wso2.carbon.registry.app.RemoteRegistry;</span>

<span style="color: #000000; font-weight: bold;">class</span> RegistryDemo <span style="color: #66cc66;">{</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span> args<span style="color: #66cc66;">)</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> <span style="color: #66cc66;">{</span>

        <span style="color: #808080; font-style: italic;">// calls the registry with the authentication information</span>
        callRemoteRegistry<span style="color: #66cc66;">(</span><span style="color: #ff0000;">"http://governance.cloud.wso2.com/registry"</span>,
                   <span style="color: #ff0000;">"example_username@example.com"</span>, <span style="color: #ff0000;">"example_password"</span><span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #993333;">void</span> callRemoteRegistry<span style="color: #66cc66;">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> url, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> username,
                       <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> password<span style="color: #66cc66;">)</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> <span style="color: #66cc66;">{</span>

        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ARegistry+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Registry</span></a> myRegistry = <span style="color: #000000; font-weight: bold;">new</span> RemoteRegistry<span style="color: #66cc66;">(</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AURL+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">URL</span></a><span style="color: #66cc66;">(</span>url<span style="color: #66cc66;">)</span>, username, password<span style="color: #66cc66;">)</span>;
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!myRegistry.<span style="color: #006600;">resourceExists</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"/demoResource"</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

            Resource r = myRegistry.<span style="color: #006600;">newResource</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
            r.<span style="color: #006600;">setContent</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"demo content"</span><span style="color: #66cc66;">)</span>;
            myRegistry.<span style="color: #006600;">put</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"/demoResource"</span>, r<span style="color: #66cc66;">)</span>;
        <span style="color: #66cc66;">}</span>

        Resource r = myRegistry.<span style="color: #006600;">get</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"/demoResource"</span><span style="color: #66cc66;">)</span>;
        <span style="color: #993333;">byte</span><span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span> contentBytes = <span style="color: #66cc66;">(</span><span style="color: #993333;">byte</span><span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">)</span>r.<span style="color: #006600;">getContent</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> content = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">(</span>contentBytes<span style="color: #66cc66;">)</span>;
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"Content: "</span> + content<span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>
<span style="color: #66cc66;">}</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2010/01/11/access-wso2-governance-as-a-service-from-remote-registry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make vs Ant</title>
		<link>http://www.dimuthu.org/blog/2010/01/10/make-vs-ant/</link>
		<comments>http://www.dimuthu.org/blog/2010/01/10/make-vs-ant/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 13:06:39 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[make]]></category>
		<category><![CDATA[makefile]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=1063</guid>
		<description><![CDATA[Ant was developed mainly to run java programs, so it is good at building and running java programs. But you can use the good all Make program to build and even run java programs. Say I have an ant file &#8230; <a href="http://www.dimuthu.org/blog/2010/01/10/make-vs-ant/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Ant was developed mainly to run java programs, so it is good at building and running java programs. But you can use the good all Make program to build and even run java programs.</p>
<p>Say I have an ant file that will</p>
<ol>
<li>Clean the build &#8211; ant clean</li>
<li>Compile &#8211; ant compile</li>
<li>Make a Jar &#8211; ant jar</li>
<li>Run &#8211; ant run or simply ant</li>
</ol>
<p>For this, I will only compile one java file name src/test/HelloWorld.java</p>
<pre><span style="font-weight: bold; color: black;">&lt;project</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"HelloWorld"</span> <span style="color: #000066;">basedir</span>=<span style="color: #ff0000;">"."</span> <span style="color: #000066;">default</span>=<span style="color: #ff0000;">"main"</span><span style="font-weight: bold; color: black;">&gt;</span>

    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"src.dir"</span>     <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"src"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>

    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"build.dir"</span>   <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"build"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"classes.dir"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"${build.dir}/classes"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>

    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"jar.dir"</span>     <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"${build.dir}/jar"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"main-class"</span>  <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"test.HelloWorld"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>

    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"clean"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;delete</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">"${build.dir}"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/target<span style="font-weight: bold; color: black;">&gt;</span></span></span>

    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"compile"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mkdir</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">"${classes.dir}"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;javac</span> <span style="color: #000066;">srcdir</span>=<span style="color: #ff0000;">"${src.dir}"</span> <span style="color: #000066;">destdir</span>=<span style="color: #ff0000;">"${classes.dir}"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>

    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/target<span style="font-weight: bold; color: black;">&gt;</span></span></span>

    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"jar"</span> <span style="color: #000066;">depends</span>=<span style="color: #ff0000;">"compile"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mkdir</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">"${jar.dir}"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>

        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;jar</span> <span style="color: #000066;">destfile</span>=<span style="color: #ff0000;">"${jar.dir}/${ant.project.name}.jar"</span> <span style="color: #000066;">basedir</span>=<span style="color: #ff0000;">"${classes.dir}"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;manifest<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"Main-Class"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"${main-class}"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>

            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/manifest<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/jar<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/target<span style="font-weight: bold; color: black;">&gt;</span></span></span>

    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"run"</span> <span style="color: #000066;">depends</span>=<span style="color: #ff0000;">"jar"</span><span style="font-weight: bold; color: black;">&gt;</span></span>

        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;java</span> <span style="color: #000066;">jar</span>=<span style="color: #ff0000;">"${jar.dir}/${ant.project.name}.jar"</span> <span style="color: #000066;">fork</span>=<span style="color: #ff0000;">"true"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/target<span style="font-weight: bold; color: black;">&gt;</span></span></span>

    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"clean-build"</span> <span style="color: #000066;">depends</span>=<span style="color: #ff0000;">"clean,jar"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>

    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"main"</span> <span style="color: #000066;">depends</span>=<span style="color: #ff0000;">"clean,run"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>

<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/project<span style="font-weight: bold; color: black;">&gt;</span>
</span></span></pre>
<p>If you want to learn what each line of this means, just follow the excellent ant tutorial at <a href="http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html">http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html</a>.</p>
<p>Here is the Makefile that will do the above tasks,</p>
<pre><span style="color: #007800;">SRC_DIR=</span>src
<span style="color: #007800;">BUILD_DIR=</span>build
<span style="color: #007800;">CLASSES_DIR=</span>$<span style="color: #7a0874; font-weight: bold;">(</span>BUILD_DIR<span style="color: #7a0874; font-weight: bold;">)</span>/classes
<span style="color: #007800;">JAR_DIR=</span>$<span style="color: #7a0874; font-weight: bold;">(</span>BUILD_DIR<span style="color: #7a0874; font-weight: bold;">)</span>/jar

<span style="color: #007800;">PROJECT=</span>HelloWorld
<span style="color: #007800;">MAIN_CLASS=</span>test.HelloWorld
<span style="color: #007800;">PACKAGE=</span>test
 
run: clean jar
        java -jar $<span style="color: #7a0874; font-weight: bold;">(</span>JAR_DIR<span style="color: #7a0874; font-weight: bold;">)</span>/$<span style="color: #7a0874; font-weight: bold;">(</span>PROJECT<span style="color: #7a0874; font-weight: bold;">)</span>.jar
 

jar: $<span style="color: #7a0874; font-weight: bold;">(</span>JAR_DIR<span style="color: #7a0874; font-weight: bold;">)</span>/$<span style="color: #7a0874; font-weight: bold;">(</span>PROJECT<span style="color: #7a0874; font-weight: bold;">)</span>.jar
 
$<span style="color: #7a0874; font-weight: bold;">(</span>JAR_DIR<span style="color: #7a0874; font-weight: bold;">)</span>/$<span style="color: #7a0874; font-weight: bold;">(</span>PROJECT<span style="color: #7a0874; font-weight: bold;">)</span>.jar: $<span style="color: #7a0874; font-weight: bold;">(</span>CLASSES_DIR<span style="color: #7a0874; font-weight: bold;">)</span>/$<span style="color: #7a0874; font-weight: bold;">(</span>PACKAGE<span style="color: #7a0874; font-weight: bold;">)</span>/*.class
        <span style="color: #7a0874; font-weight: bold;">echo</span> Main-Class: $<span style="color: #7a0874; font-weight: bold;">(</span>MAIN_CLASS<span style="color: #7a0874; font-weight: bold;">)</span>&gt; mf
        <span style="color: #7a0874; font-weight: bold;">test</span> -d $<span style="color: #7a0874; font-weight: bold;">(</span>JAR_DIR<span style="color: #7a0874; font-weight: bold;">)</span> | <span style="color: #c20cb9; font-weight: bold;">mkdir</span> -p $<span style="color: #7a0874; font-weight: bold;">(</span>JAR_DIR<span style="color: #7a0874; font-weight: bold;">)</span>

        jar cfm $@ mf -C $<span style="color: #7a0874; font-weight: bold;">(</span>CLASSES_DIR<span style="color: #7a0874; font-weight: bold;">)</span> .
 
compile: $<span style="color: #7a0874; font-weight: bold;">(</span>CLASSES_DIR<span style="color: #7a0874; font-weight: bold;">)</span>/$<span style="color: #7a0874; font-weight: bold;">(</span>PACKAGE<span style="color: #7a0874; font-weight: bold;">)</span>/*.class

 
$<span style="color: #7a0874; font-weight: bold;">(</span>CLASSES_DIR<span style="color: #7a0874; font-weight: bold;">)</span>/$<span style="color: #7a0874; font-weight: bold;">(</span>PACKAGE<span style="color: #7a0874; font-weight: bold;">)</span>/%.class: <span style="color: #007800;">$<span style="color: #7a0874; font-weight: bold;">{</span>SRC_DIR<span style="color: #7a0874; font-weight: bold;">}</span></span>/$<span style="color: #7a0874; font-weight: bold;">(</span>PACKAGE<span style="color: #7a0874; font-weight: bold;">)</span>/*.java
        <span style="color: #7a0874; font-weight: bold;">test</span> -d $<span style="color: #7a0874; font-weight: bold;">(</span>CLASSES_DIR<span style="color: #7a0874; font-weight: bold;">)</span> | <span style="color: #c20cb9; font-weight: bold;">mkdir</span> -p $<span style="color: #7a0874; font-weight: bold;">(</span>CLASSES_DIR<span style="color: #7a0874; font-weight: bold;">)</span>

        javac -sourcepath src -d <span style="color: #007800;">$<span style="color: #7a0874; font-weight: bold;">{</span>CLASSES_DIR<span style="color: #7a0874; font-weight: bold;">}</span></span> $&lt;
 
clean:
        <span style="color: #c20cb9; font-weight: bold;">rm</span> -rf build mf
</pre>
<p>You may notice I had to provide the package name to the compile command, as it doesn&#8217;t have a proper wildcards to represent the jar. Similar to ant all these make tasks will execute only if it is required. i.e. for an example if all the .class files are up to date with .java it will not try to recompile it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2010/01/10/make-vs-ant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WSF/PHP Code First Approach: Returning an Array of String</title>
		<link>http://www.dimuthu.org/blog/2010/01/08/wsfphp-code-first-approach-returning-an-array-of-string/</link>
		<comments>http://www.dimuthu.org/blog/2010/01/08/wsfphp-code-first-approach-returning-an-array-of-string/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 02:05:12 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[WSDL]]></category>
		<category><![CDATA[wsf/php]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xml schema]]></category>
		<category><![CDATA[code first]]></category>
		<category><![CDATA[wsdl generation]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=1060</guid>
		<description><![CDATA[Here is a problem that many people have asked me how to do it. &#8220;Returning an array of string&#8221; with the code first approach. The API or WSDL generation annotation guide, http://wso2.org/project/wsf/php/2.0.0/docs/wsdl_generation_api.html contain all the things required in details. Here &#8230; <a href="http://www.dimuthu.org/blog/2010/01/08/wsfphp-code-first-approach-returning-an-array-of-string/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Here is a problem that many people have asked me how to do it. &#8220;Returning an array of string&#8221; with the code first approach. The API or WSDL generation annotation guide, <a href="http://wso2.org/project/wsf/php/2.0.0/docs/wsdl_generation_api.html">http://wso2.org/project/wsf/php/2.0.0/docs/wsdl_generation_api.html</a> contain all the things required in details. Here is an example of a service that return an array of string.</p>
<pre><span style="color: #000000; font-weight: bold;">&lt;?php</span>

<span style="color: #808080; font-style: italic;">/** splitMe function
 * @param string $string_to_split string to split
 * (maps to the xs:string XML schema type )
 * @return array of string $result split to array
 *(maps to the xs:double XML schema type )
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> splitMe<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$string_to_split</span><span style="color: #66cc66;">)</span>
<span style="color: #66cc66;">{</span>
    <span style="color: #b1b100;">return</span> <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"result"</span> =&gt; <a href="http://www.php.net/split"><span style="color: #000066;">split</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">":"</span>, <span style="color: #0000ff;">$string_to_split</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

<span style="color: #66cc66;">}</span>

<span style="color: #0000ff;">$operations</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"splitMe"</span>=&gt;<span style="color: #ff0000;">"splitMe"</span><span style="color: #66cc66;">)</span>;
<span style="color: #0000ff;">$opParams</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"splitMe"</span>=&gt;<span style="color: #ff0000;">"MIXED"</span><span style="color: #66cc66;">)</span>;

<span style="color: #0000ff;">$svr</span> = <span style="color: #000000; font-weight: bold;">new</span> WSService<span style="color: #66cc66;">(</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"operations"</span>=&gt;<span style="color: #0000ff;">$operations</span>,
                           <span style="color: #ff0000;">"bindingStyle"</span>=&gt;<span style="color: #ff0000;">"doclit"</span>,
                           <span style="color: #ff0000;">"opParams"</span>=&gt;<span style="color: #0000ff;">$opParams</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

<span style="color: #0000ff;">$svr</span>-&gt;<span style="color: #006600;">reply</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
</pre>
<p>Note that the annotation corresponding to the return value.</p>
<pre> * @return array of spring $result split to array
</pre>
<p>This will generate an schema with an element of maxOccurs=&#8217;unbounded&#8217;. Note that you can get the wsdl from the &#8216;serviceurl?wsdl&#8217;.</p>
<pre><span style="font-weight: bold; color: black;">&lt;xsd:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"splitMeResponse"</span><span style="font-weight: bold; color: black;">&gt;</span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;xsd:complexType<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;xsd:sequence<span style="font-weight: bold; color: black;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;xsd:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"result"</span> <span style="color: #000066;">maxOccurs</span>=<span style="color: #ff0000;">"unbounded"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"xsd:string"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/xsd:sequence<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/xsd:complexType<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/xsd:element<span style="font-weight: bold; color: black;">&gt;</span>
</span></span></pre>
<p>Now just generate a client for this service using wsdl2php and try invoke it. You will get an array of string as the response.</p>
<pre>    <span style="color: #0000ff;">$input</span> = <span style="color: #000000; font-weight: bold;">new</span> splitMe<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
    <span style="color: #0000ff;">$input</span>-&gt;<span style="color: #006600;">string_to_split</span> = <span style="color: #ff0000;">"a:b:c:d"</span>;

 
    <span style="color: #808080; font-style: italic;">// call the operation</span>
    <span style="color: #0000ff;">$response</span> = <span style="color: #0000ff;">$proxy</span>-&gt;<span style="color: #006600;">splitMe</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$input</span><span style="color: #66cc66;">)</span>;
    <a href="http://www.php.net/print_r"><span style="color: #000066;">print_r</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$response</span><span style="color: #66cc66;">)</span>;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2010/01/08/wsfphp-code-first-approach-returning-an-array-of-string/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Writing Business Rules in WSO2 Carbon Platform</title>
		<link>http://www.dimuthu.org/blog/2010/01/07/writing-business-rules-in-wso2-carbon-platform/</link>
		<comments>http://www.dimuthu.org/blog/2010/01/07/writing-business-rules-in-wso2-carbon-platform/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 03:52:49 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[carbon]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Tutorial/Guide]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[business rules]]></category>
		<category><![CDATA[esb]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=1055</guid>
		<description><![CDATA[If you want to write rules in a Java program you have lot of choices. You can use a third party library like Drools or use the JAVA built-in JSR-94 reference implementation. In WSO2 Carbon, there is a component that &#8230; <a href="http://www.dimuthu.org/blog/2010/01/07/writing-business-rules-in-wso2-carbon-platform/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If you want to write rules in a Java program you have lot of choices. You can use a <a href="http://java-source.net/open-source/rule-engines">third party library</a> like Drools or use the JAVA built-in JSR-94 reference implementation. In <a href="http://wso2.org">WSO2</a> Carbon, there is a component that abstract the behaviour of different rule engine and give you a unified API. Currently it has plugged into Drools and JAVA built-in JSR-94 implementation.</p>
<p>The rule component in WSO2 Carbon platform mainly used by <a href="http://wso2.org/projects/esb/java">WSO2 ESB</a> product to mediate messages according to the given business rules. But the component is written to facilitate any requirement of using business rules in WSO2 Carbon platform. I had such a requirement in past few days and manage to use the rule component easily with the help of the component author, indika@wso2.com. So I thought it is worth sharing my experience in here.</p>
<p>Here You will be preparing the following stuff.</p>
<p>1. Rule configuration -</p>
<p>We can use this to provide the information about the rule implementation we are going to use, the rules (You can write rules inline or provide a reference to an external file) and the input and output adapter information.</p>
<pre><span style="font-weight: bold; color: black;">&lt;configuration</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">"http://www.wso2.org/products/rule/drools"</span><span style="font-weight: bold; color: black;">&gt;</span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;executionSet</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">"simpleItemRuleXML"</span><span style="font-weight: bold; color: black;">&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;source</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">"file:src/test/resources/rules/simple-rules.drl"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>

<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- &lt;source&gt;</span>
</span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;x<span style="font-weight: bold; color: black;">&gt;</span></span></span><span style="color: #339933;">&lt;![CDATA[</span>
<span style="color: #339933;"> rule InvokeABC</span>
<span style="color: #339933;"> // rules inbuilt to the rule conf</span>
<span style="color: #339933;"> end</span>

<span style="color: #339933;"> ]]&gt;</span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/x<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/source<span style="font-weight: bold; color: black;">&gt;</span></span></span> --&gt;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;creation<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"source"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"drl"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>

<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/creation<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/executionSet<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;session</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"stateless"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;input</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"facts"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"itemData"</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">"dataContext"</span><span style="font-weight: bold; color: black;">&gt;</span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/input<span style="font-weight: bold; color: black;">&gt;</span></span></span>

<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;output</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"results"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"itemData"</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">"dataContext"</span><span style="font-weight: bold; color: black;">&gt;</span></span><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/output<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/configuration<span style="font-weight: bold; color: black;">&gt;</span></span></span>

<span style="color: #009900;"><span style="font-weight: bold; color: black;"><span style="font-weight: bold; color: black;">
</span></span></span></pre>
<p>2. The Rules  -</p>
<p>You can write rules inline in the above configuration or put it in a file and refer it from a key which can be refered from the ResourceHelper (described below).</p>
<pre><span style="color: #a1a100;">import java.util.Calendar;</span>

rule YearEndDiscount
when
$item : org.<span style="color: #006600;">test</span>.<span style="color: #006600;">pojo</span>.<span style="color: #006600;">SimpleItem</span><span style="color: #66cc66;">(</span>price &gt; <span style="color: #cc66cc;">100</span> <span style="color: #66cc66;">)</span>

then

<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a> calendar = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a>.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>calendar.<span style="color: #006600;">get</span><span style="color: #66cc66;">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a>.<span style="color: #006600;">MONTH</span><span style="color: #66cc66;">)</span> == <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a>.<span style="color: #006600;">JANUARY</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

$item.<span style="color: #006600;">setPrice</span><span style="color: #66cc66;">(</span>$item.<span style="color: #006600;">getPrice</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> * <span style="color: #cc66cc;">80</span>/<span style="color: #cc66cc;">100</span><span style="color: #66cc66;">)</span>;
<span style="color: #66cc66;">}</span>

end
</pre>
<p>3. Data Context -</p>
<p>The context object that can be used to feed and retrieve data from and to rule engine. Here is the data context for my application.</p>
<pre><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SimpleDataContext <span style="color: #66cc66;">{</span>

    <span style="color: #000000; font-weight: bold;">public</span> List&lt;NameValuePair&gt; getInput<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #808080; font-style: italic;">// in reality the data will be retrieve from a database or some datasource </span>
        List&lt;NameValuePair&gt; itemPairList = <span style="color: #000000; font-weight: bold;">new</span> ArrayList&lt;NameValuePair&gt;<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
        SimpleItem item1 = <span style="color: #000000; font-weight: bold;">new</span> SimpleItem<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
        item1.<span style="color: #006600;">setName</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"item1"</span><span style="color: #66cc66;">)</span>;
        item1.<span style="color: #006600;">setPrice</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">)</span>;
        itemPairList.<span style="color: #006600;">add</span><span style="color: #66cc66;">(</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ANameValuePair+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">NameValuePair</span></a><span style="color: #66cc66;">(</span>item1.<span style="color: #006600;">getName</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>, item1<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

        SimpleItem item2 = <span style="color: #000000; font-weight: bold;">new</span> SimpleItem<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
        item2.<span style="color: #006600;">setName</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"item2"</span><span style="color: #66cc66;">)</span>;
        item2.<span style="color: #006600;">setPrice</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">120</span><span style="color: #66cc66;">)</span>;
        itemPairList.<span style="color: #006600;">add</span><span style="color: #66cc66;">(</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ANameValuePair+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">NameValuePair</span></a><span style="color: #66cc66;">(</span>item2.<span style="color: #006600;">getName</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>, item2<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

        SimpleItem item3 = <span style="color: #000000; font-weight: bold;">new</span> SimpleItem<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
        item3.<span style="color: #006600;">setName</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"item3"</span><span style="color: #66cc66;">)</span>;
        item3.<span style="color: #006600;">setPrice</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">130</span><span style="color: #66cc66;">)</span>;
        itemPairList.<span style="color: #006600;">add</span><span style="color: #66cc66;">(</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ANameValuePair+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">NameValuePair</span></a><span style="color: #66cc66;">(</span>item3.<span style="color: #006600;">getName</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>, item3<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

        <span style="color: #000000; font-weight: bold;">return</span> itemPairList;
    <span style="color: #66cc66;">}</span>

    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setResult<span style="color: #66cc66;">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> result<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!<span style="color: #66cc66;">(</span>result <span style="color: #000000; font-weight: bold;">instanceof</span> SimpleItem<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
            <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"it is not a SimpleItem"</span><span style="color: #66cc66;">)</span>;
        <span style="color: #66cc66;">}</span>

        SimpleItem item = <span style="color: #66cc66;">(</span>SimpleItem<span style="color: #66cc66;">)</span>result;
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"Item: "</span> + item.<span style="color: #006600;">getName</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> + <span style="color: #ff0000;">", Price: "</span> + item.<span style="color: #006600;">getPrice</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>

<span style="color: #66cc66;">}</span>
</pre>
<p>And the Item I&#8217;m going to manipulate using rule is a simple bean like this,</p>
<pre><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SimpleItem <span style="color: #66cc66;">{</span>
    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> name;
    <span style="color: #993333;">int</span> price;
    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getName<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #000000; font-weight: bold;">return</span> name;
    <span style="color: #66cc66;">}</span>

    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setName<span style="color: #66cc66;">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> name<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">name</span> = name;
    <span style="color: #66cc66;">}</span>

    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">int</span> getPrice<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #000000; font-weight: bold;">return</span> price;
    <span style="color: #66cc66;">}</span>

    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setPrice<span style="color: #66cc66;">(</span><span style="color: #993333;">int</span> price<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">price</span> = price;
    <span style="color: #66cc66;">}</span>
<span style="color: #66cc66;">}</span>
</pre>
<p>4. Data Adapter</p>
<p>You have to adapt the input and output with the rule engine. Mostly here you only have to wrap the data context. The advantage of having the data adapter is, a data adapter always associated with a input/output type. So in the rule configuration I can provide the type for the input and output. If you see my rule configuration above, you see the input/output type is marked as &#8220;ItemData&#8221;.  Here is my custom data adapter that is associated with the &#8220;itemData&#8221; type.</p>
<pre><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SimpleDataAdapter <span style="color: #000000; font-weight: bold;">implements</span>
        ResourceAdapter, InputAdaptable, OutputAdaptable <span style="color: #66cc66;">{</span>

    <span style="color: #808080; font-style: italic;">// the type associated with the adapter</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">static</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> TYPE = <span style="color: #ff0000;">"itemData"</span>;
    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getType<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #000000; font-weight: bold;">return</span> TYPE;
    <span style="color: #66cc66;">}</span>

    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> adaptInput<span style="color: #66cc66;">(</span>ResourceDescription resourceDescription, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> tobeadapted<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!<span style="color: #66cc66;">(</span>tobeadapted <span style="color: #000000; font-weight: bold;">instanceof</span> SimpleDataContext<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">null</span>;
        <span style="color: #66cc66;">}</span>

        SimpleDataContext dataContext = <span style="color: #66cc66;">(</span>SimpleDataContext<span style="color: #66cc66;">)</span>tobeadapted;
        <span style="color: #000000; font-weight: bold;">return</span> dataContext.<span style="color: #006600;">getInput</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">boolean</span> adaptOutput<span style="color: #66cc66;">(</span>ResourceDescription description,
                               <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> value,
                               <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> context,
                               ResourceHelper resourceHelper<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!<span style="color: #66cc66;">(</span>context <span style="color: #000000; font-weight: bold;">instanceof</span> SimpleDataContext<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">false</span>;
        <span style="color: #66cc66;">}</span>

        <span style="color: #66cc66;">(</span><span style="color: #66cc66;">(</span>SimpleDataContext<span style="color: #66cc66;">)</span>context<span style="color: #66cc66;">)</span>.<span style="color: #006600;">setResult</span><span style="color: #66cc66;">(</span>value<span style="color: #66cc66;">)</span>;
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">true</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">boolean</span> canAdapt<span style="color: #66cc66;">(</span>ResourceDescription description, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> ouptput<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> key = description.<span style="color: #006600;">getKey</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
        <span style="color: #000000; font-weight: bold;">return</span> key != <span style="color: #000000; font-weight: bold;">null</span> &amp;&amp; !<span style="color: #ff0000;">""</span>.<span style="color: #006600;">equals</span><span style="color: #66cc66;">(</span>key<span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>

<span style="color: #66cc66;">}</span>
</pre>
<p>5. Resource Helper</p>
<p>Resource Helper will map the keys refered from the configuration to JAVA objects. This is mostly used in mediation rule configurations which can extract the message data using a key or an xpath. In this example, we don&#8217;t have much keys refering from the configuration only the rule file and the data context.</p>
<pre><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SimpleResourceHelper <span style="color: #000000; font-weight: bold;">extends</span> ResourceHelper <span style="color: #66cc66;">{</span>

    <span style="color: #000000; font-weight: bold;">public</span> ReturnValue findByKey<span style="color: #66cc66;">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> key, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> source, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> defaultValue<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!<span style="color: #66cc66;">(</span>source <span style="color: #000000; font-weight: bold;">instanceof</span> SimpleDataContext<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ReturnValue<span style="color: #66cc66;">(</span>defaultValue<span style="color: #66cc66;">)</span>;
        <span style="color: #66cc66;">}</span>

        SimpleDataContext dataContext = <span style="color: #66cc66;">(</span>SimpleDataContext<span style="color: #66cc66;">)</span>source;
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>key.<span style="color: #006600;">startsWith</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"file:"</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

            <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> filename = key.<span style="color: #006600;">substring</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"file:"</span>.<span style="color: #006600;">length</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
            <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">{</span>

                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ABufferedInputStream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">BufferedInputStream</span></a> in = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ABufferedInputStream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">BufferedInputStream</span></a><span style="color: #66cc66;">(</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFileInputStream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">FileInputStream</span></a><span style="color: #66cc66;">(</span>filename<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ReturnValue<span style="color: #66cc66;">(</span>in<span style="color: #66cc66;">)</span>;
            <span style="color: #66cc66;">}</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">(</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> e<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ReturnValue<span style="color: #66cc66;">(</span>defaultValue<span style="color: #66cc66;">)</span>;
            <span style="color: #66cc66;">}</span>
        <span style="color: #66cc66;">}</span>
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>key.<span style="color: #006600;">startsWith</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"dataContext"</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ReturnValue<span style="color: #66cc66;">(</span>dataContext<span style="color: #66cc66;">)</span>;
        <span style="color: #66cc66;">}</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ReturnValue<span style="color: #66cc66;">(</span>defaultValue<span style="color: #66cc66;">)</span>;
    <span style="color: #66cc66;">}</span>

    <span style="color: #808080; font-style: italic;">// there are few more methods to be implemented, which can just leave not implemented for this example</span>
    <span style="color: #66cc66;">}</span>
<span style="color: #66cc66;">}</span>
</pre>
<p>That is all the accessories. Now you will be able to write the rule engine execution code.</p>
<pre><span style="color: #aaaadd; font-weight: bold;">File</span> ruleConfigFile = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">File</span></a><span style="color: #66cc66;">(</span>ruleConfigFilename<span style="color: #66cc66;">)</span>;
XMLStreamReader parser = XMLInputFactory.<span style="color: #006600;">newInstance</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>.<span style="color: #006600;">createXMLStreamReader</span><span style="color: #66cc66;">(</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFileInputStream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">FileInputStream</span></a><span style="color: #66cc66;">(</span>ruleConfigFile<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

<span style="color: #808080; font-style: italic;">//create the builder</span>
StAXOMBuilder builder = <span style="color: #000000; font-weight: bold;">new</span> StAXOMBuilder<span style="color: #66cc66;">(</span>parser<span style="color: #66cc66;">)</span>;
<span style="color: #808080; font-style: italic;">//get the root element (in this case the envelope)</span>

OMElement ruleConfig =  builder.<span style="color: #006600;">getDocumentElement</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
EngineConfiguration configuration =
        <span style="color: #000000; font-weight: bold;">new</span> EngineConfigurationFactory<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>.<span style="color: #006600;">create</span><span style="color: #66cc66;">(</span>ruleConfig, <span style="color: #000000; font-weight: bold;">new</span> AXIOMXPathFactory<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

EngineController
        engineController = <span style="color: #000000; font-weight: bold;">new</span> EngineController<span style="color: #66cc66;">(</span>configuration, <span style="color: #000000; font-weight: bold;">new</span> SimpleResourceHelper<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;
        <span style="color: #000000; font-weight: bold;">final</span> ResourceAdapterFactory factory = ResourceAdapterFactory.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;

ResourceAdapter adapter = <span style="color: #000000; font-weight: bold;">new</span> SimpleDataAdapter<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> adapterType = adapter.<span style="color: #006600;">getType</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!factory.<span style="color: #006600;">containsResourceAdapter</span><span style="color: #66cc66;">(</span>adapterType<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>

    factory.<span style="color: #006600;">addResourceAdapter</span><span style="color: #66cc66;">(</span>adapter<span style="color: #66cc66;">)</span>;
<span style="color: #66cc66;">}</span>

SimpleDataContext simpleContext = <span style="color: #000000; font-weight: bold;">new</span> SimpleDataContext<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;

<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!engineController.<span style="color: #006600;">isInitialized</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
    engineController.<span style="color: #006600;">init</span><span style="color: #66cc66;">(</span>simpleContext<span style="color: #66cc66;">)</span>;

<span style="color: #66cc66;">}</span>

<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>engineController.<span style="color: #006600;">isInitialized</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
    engineController.<span style="color: #006600;">execute</span><span style="color: #66cc66;">(</span>simpleContext, simpleContext<span style="color: #66cc66;">)</span>;

<span style="color: #66cc66;">}</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2010/01/07/writing-business-rules-in-wso2-carbon-platform/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
