<?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>indiWiz.com &#187; groovy</title>
	<atom:link href="http://indiwiz.com/tag/groovy/feed/" rel="self" type="application/rss+xml" />
	<link>http://indiwiz.com</link>
	<description>Subhash&#039;s Tech Log</description>
	<lastBuildDate>Sun, 29 Apr 2012 15:11:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Quick WebService Client in Groovy</title>
		<link>http://indiwiz.com/2008/11/18/quick-webservice-client-in-groovy/</link>
		<comments>http://indiwiz.com/2008/11/18/quick-webservice-client-in-groovy/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 09:50:57 +0000</pubDate>
		<dc:creator>Subhash Chandran</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[webservice]]></category>

		<guid isPermaLink="false">http://indiwiz.wordpress.com/?p=17</guid>
		<description><![CDATA[Writing WebService client in Groovy is simple. sayHello() is the operation name. More details here. See the Installation part, you need to put the Groovy SOAP Jar in ${user.home}/.groovy/lib.]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><p>Writing WebService client in Groovy is simple.</p>
<pre class="brush: python; title: ; notranslate">
import groovy.net.soap.SoapClient

def proxy = new SoapClient(&quot;http://localhost:7777/path/to/endpoint?WSDL&quot;)
def result = proxy.sayHello(&quot;Subhash&quot;)

println result
</pre>
<p><tt>sayHello()</tt> is the operation name.</p>
<p>More details <a href="http://docs.codehaus.org/display/GROOVY/Groovy+SOAP">here</a>. See the Installation part, you need to put the Groovy SOAP Jar in <tt>${user.home}/.groovy/lib</tt>.</p>
<div class="shr-publisher-17"></div><!-- Start Shareaholic LikeButtonSetBottom --><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://indiwiz.com/2008/11/18/quick-webservice-client-in-groovy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beautiful Closures</title>
		<link>http://indiwiz.com/2008/11/18/beautiful-closures/</link>
		<comments>http://indiwiz.com/2008/11/18/beautiful-closures/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 08:27:54 +0000</pubDate>
		<dc:creator>Subhash Chandran</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[closure]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://indiwiz.wordpress.com/?p=6</guid>
		<description><![CDATA[One of the irritating things when writing code in Java is when managing files or database resources. We have to write so much redundant code: So much redundancy is ground for human errors. Issues like these are beautifully solved using programming concept called Closures. For example, in the newly released 2.6 version of Python, the [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><p>One of the irritating things when writing code in Java is when managing files or database resources. We have to write so much redundant code:</p>
<pre class="brush: java; title: ; notranslate">
File f = new File(&quot;/etc/passwd&quot;);
BufferedReader br = null;
try{
  br = new BufferedReader(new FileReader(f));
  String str;
  while((str=br.readLine())!=null){
    System.out.println(str);
  }
}
catch(IOException ex){
  ...
}
finally{
  if(br != null){
    try{
      br.close();
    }
    catch(IOException ex){
      ...
    }
  }
}
</pre>
<p>So much redundancy is ground for human errors. Issues like these are beautifully solved using programming concept called Closures. For example, in the newly released 2.6 version of Python, the same would be written as:</p>
<pre class="brush: python; title: ; notranslate">
with open('/etc/passwd', 'r') as f:
    for line in f:
        print line
</pre>
<p>In the above code, even when an exception is raised during file read, the file is gracefully closed when the control exits with block. A similar example in Groovy:</p>
<pre class="brush: java; title: ; notranslate">
File f = new File(&quot;/etc/passwd&quot;)
f.eachLine{
  line -&gt;
  println line
}
</pre>
<p>Martin Fowler has written a short introduction to <a href="http://martinfowler.com/bliki/Closure.html">Closures</a>.</p>
<div class="shr-publisher-6"></div><!-- Start Shareaholic LikeButtonSetBottom --><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://indiwiz.com/2008/11/18/beautiful-closures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

