<?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>noor - نور</title>
	<atom:link href="http://noor.ojuba.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://noor.ojuba.org</link>
	<description>Kefah Issa weblog - مدونة كفاح عيسى</description>
	<lastBuildDate>Thu, 17 Dec 2009 07:52:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A ride with hessian</title>
		<link>http://noor.ojuba.org/2008/11/a-ride-with-hessian/</link>
		<comments>http://noor.ojuba.org/2008/11/a-ride-with-hessian/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 20:54:02 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://noor.ojuba.org/?p=31</guid>
		<description><![CDATA[Today, I came across what I call a deep-sea pearl. I came to know Hessian, the binary web service protocol.
Some time ago I blogged about the same idea Predictable Binary Representation (PBR)
 , naively thinking that no one has done this before.
With the help of few friends, and some googling there turned out to be [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I came across what I call a deep-sea pearl. I came to know Hessian, the binary web service protocol.</p>
<p>Some time ago I blogged about the same idea <a href="http://noor.ojuba.org/2008/9/predictable-binary-representation-pbr">Predictable Binary Representation (PBR)</a><br />
 </a>, naively thinking that no one has done this before.</p>
<p>With the help of few friends, and some googling there turned out to be a zillion solutions that attempt to address that very problem; the etch has been really scratched by many, and the need for a compact, and predictable binary protocol is a must, no matter how fast the internet is or will become.<br/></p>
<p><span id="more-31"></span></p>
<p>Parsing JSON, despite the fact that its among the most elegant human-readable text-protocols, would consume CPU cycles, and would be susceptible to errors more likely than not.</p>
<p>With a Binary protocol, you could &#8230;</p>
<ul>
<li>Know the total size of a message (aka packet) before hand</li>
<li>Have its checksum that you can verify</li>
<li>For every single data entry, you would exactly know what size in bytes to expect next and what the type of data is, as opposed to checking for special marking characters to tell when an end of that item is reached.</li>
<li>No need to escape any special characters, should they occur plainly within the data. The problems JSON and XML have because of this deficiency are huge. Why all that hassle?! A question that puzzled me for years. </li>
<li>Far more compact in size, even without compression. There are no xml tags repeating for every node. In hessian, a dictionary of entry-names is only defined once at the header, then corresponding id&#8217;s are used across the message.
</ul>
<p>From the technical perspective, when we talk about web services, we are talking about software-to-software communication. As such Human-readable protocols are mere overhead to say the least. We should focus more on optimizing software-to-software protocol than making it look good to the human eyes.</p>
<p>Forget about XML, JSON or anything similar; and consider the beauty, performance, and optimization of binary protocols.</p>
<p>Despite the competition from Thrift (by facebook), Protocol Buffers (by google), and ASN.1 (older standard), along many others, <a href="http://hessian.caucho.com/">Hessian (by Caucho)</a> stands out from the crowd &#8230;</p>
<p>Let me tell you why I quickly fell in love with Hessian,<br/></p>
<ul>
<li>Dead-simple to use, both server-side and client-side.</li>
<li>Can be equally used on Java, C/C++, .Net, Ruby, PHP, Flash and so forth.</li>
<li>Saves tons of bandwidth, cpu cycles and increases reliability</li>
<li>Runs via the firewall-friendly http-protocol</li>
</ul>
<p>It was intriguing when reading the features and specifications. Being the hands-on person I am, I only believe what I can do &#8230;</p>
<p>So, lets roll up our sleeves and get in a quick practical session with Hessian &#8230;.</p>
<p><b>Hessian  and Java </b></p>
<p>Preparations </p>
<p>Create few folders to host our samples</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> hessian<span style="color: #000000; font-weight: bold;">/</span>lib
<span style="color: #7a0874; font-weight: bold;">cd</span> hessian</pre></div></div>

<p>I downloaded the latest <a href="http://hessian.caucho.com/download/hessian-3.2.0.jar">hessian library jar file</a> to my local lib folder.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #ff0000;">'http://hessian.caucho.com/download/hessian-3.2.0.jar'</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> hessian-3.2.0.jar lib</pre></div></div>

<p>Using jetty 6.1.x or 7.x would do equally well,</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #ff0000;">'http://dist.codehaus.org/jetty/jetty-6.1.12/jetty-6.1.12.zip'</span></pre></div></div>

<p>Unpack</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> <span style="color: #c20cb9; font-weight: bold;">unzip</span> jetty-6.1.12.zip</pre></div></div>

<p>we only need three jars, as we are going to use the compact embeddable jetty jars.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mv</span> jetty-6.1.12<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>jetty-<span style="color: #000000; font-weight: bold;">*</span> jetty-6.1.12<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>servlet-api-<span style="color: #000000;">2.5</span>-6.1.12.jar lib<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> jetty-6.1.12</pre></div></div>

<p>Make sure to define CLASSPATH environment variable that would properly point to all the jars in our lib folder. for that I use the following setenv.sh script that can be sourced every time needed.</p>
<p><em>setenv.sh</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">CLASSPATH</span>=<span style="color: #ff0000;">&quot;.&quot;</span>
<span style="color: #000000; font-weight: bold;">for</span> myjar <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #007800;">$PWD</span><span style="color: #000000; font-weight: bold;">/</span>lib <span style="color: #660033;">-iname</span> <span style="color: #ff0000;">'*.jar'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #007800;">CLASSPATH</span>=<span style="color: #007800;">$CLASSPATH</span>:<span style="color: #007800;">$myjar</span>; <span style="color: #000000; font-weight: bold;">done</span>;
<span style="color: #7a0874; font-weight: bold;">export</span> CLASSPATH</pre></div></div>

<p>Then you can source it like this</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">source</span> setenv.sh</pre></div></div>

<p>Define (create) our API interface using POJO<br/></p>
<p><em>BasicAPI.java</em></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> BasicAPI <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> hello <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Create the service API implementation and expose via an embeddable servlet container<br/><br />
<em>BasicService.java</em></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.servlet.Context</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.Server</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.caucho.hessian.server.HessianServlet</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BasicService <span style="color: #000000; font-weight: bold;">extends</span> HessianServlet <span style="color: #000000; font-weight: bold;">implements</span> BasicAPI <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> _greeting <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Hello, world&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setGreeting<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> greeting<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		_greeting <span style="color: #339933;">=</span> greeting<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> hello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> _greeting<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
		Server server <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Server<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">8080</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
		<span style="color: #003399;">Context</span> context <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Context</span><span style="color: #009900;">&#40;</span>server, <span style="color: #0000ff;">&quot;/&quot;</span>, <span style="color: #003399;">Context</span>.<span style="color: #006633;">SESSIONS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		context.<span style="color: #006633;">addServlet</span><span style="color: #009900;">&#40;</span>BasicService.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #0000ff;">&quot;/basic&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		server.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Compile the Java Server API and Interface and start our service<br/></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">javac BasicService.<span style="color: #006633;">java</span> 
java BasicService</pre></div></div>

<p>Create the Client app<br/><br />
<em>Client.java</em></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.caucho.hessian.client.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Client <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">String</span> url <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://localhost:8080/basic&quot;</span><span style="color: #339933;">;</span>
		HessianProxyFactory factory <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HessianProxyFactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		BasicAPI basic <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>BasicAPI<span style="color: #009900;">&#41;</span> factory.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span>BasicAPI.<span style="color: #000000; font-weight: bold;">class</span>, url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;basic.hello() said : &quot;</span> <span style="color: #339933;">+</span> basic.<span style="color: #006633;">hello</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Compile and run the client<br/></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">javac Client.java
java Client</pre></div></div>

<p>C&#8217;est tout! (Thats all). Your java-based client-server hessian binary protocol web service system is up and running. Wow!</p>
<p><b>Hessian in Ruby</b><br/></p>
<p>After download and unpacking <a href="http://hessian.rubyforge.org/">hessian library for ruby</a> it only takes three lines of code to connect to our java web service</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">&quot;lib/hessian.rb&quot;</span>
client = <span style="color:#6666ff; font-weight:bold;">Hessian::HessianClient</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'http://localhost:8080/basic'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#CC0066; font-weight:bold;">print</span> client.<span style="color:#9900CC;">hello</span></pre></div></div>

<p>It seems that you can also easily create hessian-based services via ruby, but i didn&#8217;t dig into it.</p>
<p><b> Hessian in PHP </b><br />
Download, unpack and make accessible via apache <a href="http://hessianphp.sourceforge.net/">the php library of hessian</a>. There is a minor glitch in Hessian PHP in which the DateTime class conflicts with Php 5.2 pre-defined DateTime class. Simply re-touch the library code and rename that class.</p>
<p><em>php_hessian_client.php</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'HessianClient.php'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$proxy</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">&amp;new</span> HessianClient<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://localhost:8080/basic'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$proxy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hello</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>You can also write a simple hessian web service api provider &#8230;<br />
<em>php_hessian_service.php</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000000; font-weight: bold;">class</span> Math<span style="color: #009900;">&#123;</span>    
  <span style="color: #000000; font-weight: bold;">function</span> add<span style="color: #009900;">&#40;</span><span style="color: #000088;">$n1</span><span style="color: #339933;">,</span><span style="color: #000088;">$n2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>        
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$n1</span><span style="color: #339933;">+</span><span style="color: #000088;">$n2</span><span style="color: #339933;">;</span>    
  <span style="color: #009900;">&#125;</span>    
  <span style="color: #000000; font-weight: bold;">function</span> sub<span style="color: #009900;">&#40;</span><span style="color: #000088;">$n1</span><span style="color: #339933;">,</span><span style="color: #000088;">$n2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>        
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$n1</span><span style="color: #339933;">-</span><span style="color: #000088;">$n2</span><span style="color: #339933;">;</span>    
  <span style="color: #009900;">&#125;</span>    
  <span style="color: #000000; font-weight: bold;">function</span> mul<span style="color: #009900;">&#40;</span><span style="color: #000088;">$n1</span><span style="color: #339933;">,</span><span style="color: #000088;">$n2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>        
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$n1</span><span style="color: #339933;">*</span><span style="color: #000088;">$n2</span><span style="color: #339933;">;</span>    
  <span style="color: #009900;">&#125;</span>    
  <span style="color: #000000; font-weight: bold;">function</span> div<span style="color: #009900;">&#40;</span><span style="color: #000088;">$n1</span><span style="color: #339933;">,</span><span style="color: #000088;">$n2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>        
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$n1</span><span style="color: #339933;">/</span><span style="color: #000088;">$n2</span><span style="color: #339933;">;</span>    
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'HessianService.php'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wrapper</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">&amp;new</span> HessianService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wrapper</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">registerObject</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Math<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wrapper</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">service</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><b> More! </b><br />
Wait, there is more! </p>
<ul>
<li> <b>Lanuages Support </b>Hessian is supported on Grails via <a href="http://grails.org/Remoting+Plugin">the remoting plugin</a>, I didn&#8217;t try the rest of the languages supported by hessian yet, but it looks that they would be fine.</li>
<li><b>Authentication and Http Proxy</b><br />
You can also make use of Http Authentication to add a security layer on top of your api&#8217;s, and proxy-by-pass in case there is a proxy in the way. </li>
<li><b>Additional Services built on top of Hessian </b><br />
There are also two interesting technologies by Caucho built on top of hessian, viz <a href="http://caucho.com/resin/doc/bam.xtp">BAM</a> and <a href="http://caucho.com/resin/doc/resin-comet.xtp"> comet </a>. </li>
<li><b>Performance benchmarks</b><br />
This is an <a href="http://daniel.gredler.net/2008/01/07/java-remoting-protocol-benchmarks/">interesting benchmark</a>, demonstrating how hessian perform against classical text and binary protocols.</li>
</ul>
<p><b> Gotcha&#8217;s </b><br />
I can see a couple of minor gotcha&#8217;s in Hessian library that can be addressed &#8230;</p>
<p>A. The language-support projects seem not to be updated for a long time, some more than a year. Those projects only support hessian protocol version 1.0.x and don&#8217;t support the latest hessian 2 protocol.</p>
<p>B. The thing I really missed is a JavaScript library that connects me to a hessian service directly. That alone will immediately offer a great value to AJAX applications.  I don&#8217;t see that far from possible, given the fact that there is already an ActionScript implementation for Flash. I hope someone will dedicate the effort to make that a reality.</p>
<p><b>Conclusion</b><br />
The Internet is coming back to its senses <img src='http://noor.ojuba.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , using Binary-based communication protocols might sound 30-year old concept, but it brings a lot on the table that current text-based human-readable protocols don&#8217;t.<br />
I am all forward for making use of such protocols in SaaS / SOA setups. Simply Binary Protocols such as hessian, could provide an alternative communication option for today&#8217;s SOAP/XML-RPC/JSON ones.</p>
]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/11/a-ride-with-hessian/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Predictable Binary Representation  (PBR)</title>
		<link>http://noor.ojuba.org/2008/09/predictable-binary-representation-pbr/</link>
		<comments>http://noor.ojuba.org/2008/09/predictable-binary-representation-pbr/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 10:30:56 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://noor.ojuba.org/?p=20</guid>
		<description><![CDATA[XML is nice, YAML and JSON are cool, proprietary formats for binary encapsulation are not good; those are all facts that many people agree to.
But they all the good solutions remain sub-optimal when it comes to network bandwidth overhead and cpu usage needed to parse the blob every time.
This might have, and should have been [...]]]></description>
			<content:encoded><![CDATA[<p>XML is nice, YAML and JSON are cool, proprietary formats for binary encapsulation are not good; those are all facts that many people agree to.</p>
<p>But they all the good solutions remain sub-optimal when it comes to network bandwidth overhead and cpu usage needed to parse the blob every time.</p>
<p>This might have, and should have been considered long time ago. I didn&#8217;t find any open format to cover it however, hence I&#8217;m suggesting one&#8230;</p>
<p><strong>Features</strong></p>
<p>The following needs are not addressed by those data representation formats, but are by PBR :</p>
<p>1. Supporting Binary content. You need to revert to Base64 or the like to do this. but its not natively supported.<br />
2. Completly Predictable (so no guess work in parsing). I don&#8217;t want to waste cpu cycles and logic to parse the content in an unpredicable manner. I want to be able to exactly tell what the next step a head and how much data I need to manage.<br />
3. No escaping. I really don&#8217;t like escaping. I want to be able to put my content AS IS &#8482;.<br />
4. Reliable : Checksum. Thats a cool addition that will make me confident of my data.</p>
<p><span id="more-20"></span></p>
<p>Here I outline the details of PBR (pronoucde  Pe.be.r) along with reference implementation (TBD) :</p>
<p>The data is represented in a message.</p>
<p>Each message is made of envelope header and body.</p>
<p>The Data elements (Entries) are organized in Entry-Name/Entry-Value pairs.</p>
<p>The body is simple a list of Entries (aka root node).</p>
<p><strong>Supported Data Types</strong></p>
<p>Just like JSON PBR does support the basic and most used data types that cover most of today&#8217;s modern needs</p>
<ol>
<li><strong>Boolean</strong></li>
<li><strong>String </strong>(UTF-8)<strong><br />
</strong></li>
<li><strong>Binary</strong></li>
<li><strong>Integer</strong></li>
<li><strong>Double</strong></li>
<li><strong>Date</strong></li>
<li><strong>Map </strong>(List is just a map with unnamed entries)<strong><br />
</strong></li>
</ol>
<p>- Depth or number of entries is unlimited.<br />
- Content-size limit it 2^31 (2GB).</p>
<p>PBR is not human readable, but using a binary editor or in the future a simple PBR reader would allow to easily read and manually manipulate the data.</p>
<p><strong>Envelope Header </strong></p>
<ul>
<li><strong>PBR Version</strong> (2 Bytes, signed short)</li>
<li><strong>MD5 Checksum</strong> of the body (16 Bytes)</li>
<li><strong>Total Message Size</strong> exclusive of the envelope header  in Bytes(4 Bytes, signed long)</li>
<li><strong>Number of Level-One Entries </strong>(4 Bytes, signed long)</li>
</ul>
<p>Total Envelop Header size is 26 bytes</p>
<p>The Message Body is a list of data entries. The number of those data entries (1st-level) is as defined in the header above.</p>
<p><strong>Data Entry </strong></p>
<ul>
<li><strong>Entry Type</strong> (1 Byte, signed byte) : The type id of the entry, 1..7 as per the types list above.</li>
<li><strong>Entry Name Size</strong> (1 Byte, signed byte) : The Size of the Name of the entry.  can be set to 0.</li>
<li><strong>Entry Name Value</strong> (0..127 Bytes) : The entry name in UTF-8.</li>
<li><strong>Number of Children</strong> (4 Bytes, signed long)</li>
<li><strong>Value Size</strong> : (4 Bytes, signed long) : The size in bytes of the value of this entry.</li>
<li><strong>Value</strong> : ( 1 .. 2^31)</li>
</ul>
<p>Any entry can have children, just like XML node.</p>
<p>However it can only either have children or a value (i.e. Number of Children ==0).</p>
<p>If Number of Children &gt; 0, then the value contains an aggregation of a list of other entries that need to be read.</p>
]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/09/predictable-binary-representation-pbr/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Groovy with SQLite</title>
		<link>http://noor.ojuba.org/2008/07/groovy-with-sqlite/</link>
		<comments>http://noor.ojuba.org/2008/07/groovy-with-sqlite/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 21:45:12 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://noor.ojuba.org/?p=19</guid>
		<description><![CDATA[SQLite is a very interesting database engine. Its performance, simplicity and that fact it runs as a library (not a server) make it the perfect candidate for small project with few users.
Today I experimented with accessing SQLite database from within groovy.

I tried the SQLite JDBC libraries and all went fine. SQLite JDBC jar file, magically [...]]]></description>
			<content:encoded><![CDATA[<p>SQLite is a very interesting database engine. Its performance, simplicity and that fact it runs as a library (not a server) make it the perfect candidate for small project with few users.</p>
<p>Today I experimented with accessing SQLite database from within groovy.</p>
<p><span id="more-19"></span></p>
<p>I tried the <a href="http://www.zentus.com/sqlitejdbc/">SQLite JDBC libraries</a> and all went fine. SQLite JDBC jar file, magically contains both Native and Pure java versions, and it automatically chooses the native one when running on Linux, Mac and Windows.</p>
<p>If you want to try the following snippets on groovy, make sure to copy sqlitejdbc-v052.jar to your ~/.groovy/lib.</p>
<p>Here is a one-liner on creating the GSQL object of a sqlite database. One nice thing to note is that you don&#8217;t have to have the test.db file created. if its not there it will be automatically created for you.</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">sql <span style="color: #66cc66;">=</span> groovy.<span style="color: #006600;">sql</span>.<span style="color: #993399; font-weight: bold;">Sql</span>.<span style="color: #006600;">newInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;jdbc:sqlite:/home/kefah/test.db&quot;</span>,<span style="color: #ff0000;">&quot;org.sqlite.JDBC&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Creating schema, insert and query</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">sql.<span style="color: #993399; font-weight: bold;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;create table students(name, age)&quot;</span><span style="color: #66cc66;">&#41;</span>
sql.<span style="color: #993399; font-weight: bold;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;insert into students(name, age) values( 'Ali Baba', 20)&quot;</span><span style="color: #66cc66;">&#41;</span>
sql.<span style="color: #993399; font-weight: bold;">eachRow</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;select rowid,name,age from students;&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
     <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;${it.rowid}: ${it.name} ${it.age}&quot;</span><span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>&#8230; a more elaborated DDL</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">sql.<span style="color: #993399; font-weight: bold;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'''
create table teachers( login primary key, firstname, lastname);
create unique index teachers_name on teachers(firstname, lastname);
'''</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Datasets are another nifty way to access the data</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">students <span style="color: #66cc66;">=</span> sql.<span style="color: #006600;">dataSet</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'students'</span><span style="color: #66cc66;">&#41;</span> 
students.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span>name:<span style="color: #ff0000;">&quot;Abu Mohammed&quot;</span>, age:<span style="color: #cc66cc;">35</span><span style="color: #66cc66;">&#41;</span>
students.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span><span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot; ${it.name}, ${it.age}&quot;</span><span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Note that sqlite datatypes are automatically induced from the data you insert into the table, or you can specify them at DDL creation time. aka Optional Typing, just like groovy <img src='http://noor.ojuba.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Further more, you can create both inmemory and persistent (on harddisk) sqlite databases.</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">sql <span style="color: #66cc66;">=</span> groovy.<span style="color: #006600;">sql</span>.<span style="color: #993399; font-weight: bold;">Sql</span>.<span style="color: #006600;">newInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;jdbc:sqlite::memory:&quot;</span>, <span style="color: #ff0000;">&quot;org.sqlite.JDBC&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>so all in all its a perfect fit for groovy and (once working for grails too).</p>
<p>[Update] A reader mentions below that he could successfully get sqlite running on grails too. Which is great news.</p>
]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/07/groovy-with-sqlite/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>QT for GNOME</title>
		<link>http://noor.ojuba.org/2008/07/qt-for-gnome/</link>
		<comments>http://noor.ojuba.org/2008/07/qt-for-gnome/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 21:23:34 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[Fedora 9]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://noor.ojuba.org/?p=18</guid>
		<description><![CDATA[I feel very strongly about the historical opportunity for the GNOME community to switch their tool kit over to QT 4.x. GNOME was originally a fork of effort from KDE back in the old days when QT was not GPL-enabled.

Now it is &#8212; and so for many years &#8212; I can see no reason why [...]]]></description>
			<content:encoded><![CDATA[<p>I feel very strongly about the historical opportunity for the GNOME community to switch their tool kit over to QT 4.x. GNOME was originally a fork of effort from KDE back in the old days when QT was not GPL-enabled.</p>
<p><span id="more-18"></span></p>
<p>Now it is &#8212; and so for many years &#8212; I can see no reason why GNOME can&#8217;t do the switch.</p>
<p>This will be a major effort of course, and there will be two types of opponents in the GNOME community :<br />
A. C-Lovers : Those who like C-language (not C++) as GTK and GNOME in general is more C-Lang than C++.<br />
B. Mono-lovers : Those who are after mono, which is not a very successful imitation for Microsot .NET.</p>
<p>Lets put that a side for a minute and lets give it a hard look, GNOME development has been stalled due to many technology limitation. Even with the latest GUADEC and talk about tab-enabling (which i still think is a joke).</p>
<p>So, despite our love and hate, at the end of the day QT is THE most mature toolkit in the FLOSS world. It deserves all the blessings it can get &#8230; and very well deserves to be considered as an excellent candidate for the GNOME project, especially after what happened with KDE4 and their move into directions that are far from the users and community. The failure in KDE4 was a result of the people who assumed its leader ship in the last two years, and its not in any way related to QT.</p>
]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/07/qt-for-gnome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weaving Groovy Threads</title>
		<link>http://noor.ojuba.org/2008/07/weaving-groovy-threads/</link>
		<comments>http://noor.ojuba.org/2008/07/weaving-groovy-threads/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 08:57:36 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://noor.ojuba.org/?p=17</guid>
		<description><![CDATA[Could writing threads be easier than this? I wonder. 


class Storage &#123;
	List stack = &#91;&#93;
&#160;
	synchronized void leftShift &#40;value&#41; &#123;
		stack &#38;lt;&#38;lt; value
		println &#34;Push : $value&#34;
		notifyAll&#40;&#41;
	&#125;
&#160;
	synchronized Object pop&#40;&#41; &#123;
		while&#40;stack.isEmpty&#40;&#41;&#41; &#123;
			try &#123; wait&#40;&#41; &#125; catch &#40;e&#41; &#123;&#125;
		&#125;
&#160;
		def value = stack.pop&#40;&#41;
		println &#34;Pop  : $value&#34;
		return value
	&#125;
&#125;
&#160;
storage = new Storage&#40;&#41;
&#160;
Thread.start &#123;
	10.times &#123;
		storage &#38;lt;&#38;lt; it
		sleep 100
	&#125;
&#125;
&#160;
Thread.start &#123;
	10.times &#123;
		sleep 200
		value = storage.pop&#40;&#41;
	&#125;
&#125;

]]></description>
			<content:encoded><![CDATA[<p>Could writing threads be easier than this? I wonder. <img src='http://noor.ojuba.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<span id="more-17"></span></p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Storage <span style="color: #66cc66;">&#123;</span>
	<span style="color: #aaaadd; font-weight: bold;">List</span> stack <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #993333;">void</span> leftShift <span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		stack <span style="color: #66cc66;">&amp;</span>lt<span style="color: #66cc66;">;&amp;</span>lt<span style="color: #66cc66;">;</span> value
		<span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Push : $value&quot;</span>
		notifyAll<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #aaaadd; font-weight: bold;">Object</span> <span style="color: #663399;">pop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>stack.<span style="color: #006600;">isEmpty</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span> wait<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span>e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">def</span> value <span style="color: #66cc66;">=</span> stack.<span style="color: #663399;">pop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Pop  : $value&quot;</span>
		<span style="color: #000000; font-weight: bold;">return</span> value
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
storage <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Storage<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #aaaadd; font-weight: bold;">Thread</span>.<span style="color: #993399;">start</span> <span style="color: #66cc66;">&#123;</span>
	10.<span style="color: #993399;">times</span> <span style="color: #66cc66;">&#123;</span>
		storage <span style="color: #66cc66;">&amp;</span>lt<span style="color: #66cc66;">;&amp;</span>lt<span style="color: #66cc66;">;</span> it
		sleep <span style="color: #cc66cc;">100</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #aaaadd; font-weight: bold;">Thread</span>.<span style="color: #993399;">start</span> <span style="color: #66cc66;">&#123;</span>
	10.<span style="color: #993399;">times</span> <span style="color: #66cc66;">&#123;</span>
		sleep <span style="color: #cc66cc;">200</span>
		value <span style="color: #66cc66;">=</span> storage.<span style="color: #663399;">pop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/07/weaving-groovy-threads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Groovy Introspection, know what you have</title>
		<link>http://noor.ojuba.org/2008/07/groovy-introspection-know-what-you-have/</link>
		<comments>http://noor.ojuba.org/2008/07/groovy-introspection-know-what-you-have/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 06:31:59 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://noor.ojuba.org/?p=16</guid>
		<description><![CDATA[Lots of fun with Groovy introspection. Java already provides something similar but in Groovy it has completely different taste and use.
I actually use introspection often from within groovysh to investigate on what a class provides, just like auto-complete in modern IDE&#8217;s  


// Whats is your class?
&#160;
a = 5
b = &#34;Hello&#34;
&#160;
println &#34;Class of a : [...]]]></description>
			<content:encoded><![CDATA[<p>Lots of fun with Groovy introspection. Java already provides something similar but in Groovy it has completely different taste and use.</p>
<p>I actually use introspection often from within groovysh to investigate on what a class provides, just like auto-complete in modern IDE&#8217;s <img src='http://noor.ojuba.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-16"></span></p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Whats is your class?</span>
&nbsp;
a <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">5</span>
b <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;Hello&quot;</span>
&nbsp;
<span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Class of a : ${a.class} nClass of b : ${b.class}&quot;</span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;">// Introspection, know all the details about classes :</span>
<span style="color: #808080; font-style: italic;">// List all constructors of a class</span>
<span style="color: #aaaadd; font-weight: bold;">String</span>.<span style="color: #006600;">constructors</span>.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#123;</span><span style="color: #993399;">println</span> it<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// List all interfaces implemented by a class</span>
<span style="color: #aaaadd; font-weight: bold;">String</span>.<span style="color: #006600;">interfaces</span>.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#123;</span><span style="color: #993399;">println</span> it<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// List all methods offered by a class</span>
<span style="color: #aaaadd; font-weight: bold;">String</span>.<span style="color: #006600;">methods</span>.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#123;</span><span style="color: #993399;">println</span> it<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Just list the methods names</span>
<span style="color: #aaaadd; font-weight: bold;">String</span>.<span style="color: #006600;">methods</span>.<span style="color: #006600;">name</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Get the fields of an object (with their values)</span>
d <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">Date</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
d.<span style="color: #006600;">properties</span>.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#123;</span><span style="color: #993399;">println</span> it<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Not much related, but interesting : Dynamic Method calling</span>
<span style="color: #000000; font-weight: bold;">class</span> Greeting<span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">def</span> sayHello<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Hello, Stranger&quot;</span>
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">def</span> sayHello<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span> name<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Hello, ${name}&quot;</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
g <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Greeting<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
s <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;sayHello&quot;</span>
g.<span style="color: #ff0000;">&quot;${s}&quot;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Ali Baba&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/07/groovy-introspection-know-what-you-have/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Databases with Groovy</title>
		<link>http://noor.ojuba.org/2008/07/databases-with-groovy/</link>
		<comments>http://noor.ojuba.org/2008/07/databases-with-groovy/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 23:37:09 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://noor.ojuba.org/?p=15</guid>
		<description><![CDATA[GORM is cool, but groovy Sql is for the simpler cases were you just need to interact with the database.

groovy.sql.Sql is just an amazing Groovy class.  See this link for a mind-opener level of ease when dealing with databases and this is an interesting article from IBM Developer works :   Practically Groovy: [...]]]></description>
			<content:encoded><![CDATA[<p>GORM is cool, but groovy Sql is for the simpler cases were you just need to interact with the database.<br />
<span id="more-15"></span></p>
<p>groovy.sql.Sql is just an amazing Groovy class. <a href="http://groovy.codehaus.org/Database+features"> See this link for a mind-opener level of ease when dealing with databases</a> and this is an interesting article from IBM Developer works :  <a href="http://www.ibm.com/developerworks/java/library/j-pg01115.html"> Practically Groovy: JDBC programming with Groovy</a></p>
<p>Watch : </p>
<p>Define your database sql object (aka database swiss-nife)<br />
With Oracle</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">sql <span style="color: #66cc66;">=</span> groovy.<span style="color: #006600;">sql</span>.<span style="color: #993399; font-weight: bold;">Sql</span>.<span style="color: #006600;">newInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;jdbc:oracle:thin:@myoraclehost:1521:mydbinstance&quot;</span>, 
                        <span style="color: #ff0000;">&quot;myuser&quot;</span>, <span style="color: #ff0000;">&quot;mypassword&quot;</span>, <span style="color: #ff0000;">&quot;oracle.jdbc.driver.OracleDriver&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>With MySql</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">sql <span style="color: #66cc66;">=</span> groovy.<span style="color: #006600;">sql</span>.<span style="color: #993399; font-weight: bold;">Sql</span>.<span style="color: #006600;">newInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;jdbc:mysql://localhost:3306/mydb&quot;</span>, <span style="color: #ff0000;">&quot;user&quot;</span>, <span style="color: #ff0000;">&quot;pswd&quot;</span>, 
          <span style="color: #ff0000;">&quot;com.mysql.jdbc.Driver&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>and voala, you&#8217;ve got a database connection that you use to conduct most needed db operations.</p>
<p>Remember to place your Oracle JDBC driver (in my case ojdbc14.jar) and/or your mysql JDBC driver (mysql-connector-java-5.1.6-bin.jar) into ~/.groovy/lib</p>
<p>Did I mention that you can easily call Oracle Stored procedure?<br />
Three input parameters, two output parameters, and one single line of code <img src='http://noor.ojuba.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">groovy.sql.Sql</span>
sql.<span style="color: #993399; font-weight: bold;">call</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;{ call MY_SP ( 'My in param', ${Sql.inout(Sql.INTEGER(context))}, 'my in param2', 'myin params3', ${Sql.inout(Sql.VARCHAR(result))}) }&quot;</span><span style="color: #66cc66;">&#41;</span>  <span style="color: #66cc66;">&#123;</span>context,result <span style="color: #66cc66;">-&gt;</span> <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;$context and $result&quot;</span> <span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/07/databases-with-groovy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Groovy Simple Templates</title>
		<link>http://noor.ojuba.org/2008/07/groovy-simple-templates/</link>
		<comments>http://noor.ojuba.org/2008/07/groovy-simple-templates/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 23:28:54 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://noor.ojuba.org/?p=14</guid>
		<description><![CDATA[Dynamic text templates are joy to do in groovy.

I came across the need of such functionality many times during my past projects, and now with the new one.
Not only can I place my bound variables and reuse them in the template, but I can also run legal groovy code.

&#160;
text = '''
 Dear &#34;$firstname $lastname&#34;,
 So [...]]]></description>
			<content:encoded><![CDATA[<p>Dynamic text templates are joy to do in groovy.<br />
<span id="more-14"></span></p>
<p>I came across the need of such functionality many times during my past projects, and now with the new one.</p>
<p>Not only can I place my bound variables and reuse them in the template, but I can also run legal groovy code.</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">&nbsp;
text <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'''
 Dear &quot;$firstname $lastname&quot;,
 So nice to meet you in &lt;% print city %&gt;.
 See you in ${month},
 ${signed} 
 ${10.times{println it}}
 '''</span>
params <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>firstname:<span style="color: #ff0000;">&quot;Ali&quot;</span>, lastname:<span style="color: #ff0000;">&quot;Baba&quot;</span>,city:<span style="color: #ff0000;">&quot;Baghdad&quot;</span>, month:<span style="color: #ff0000;">&quot;June&quot;</span>, 
              signed:<span style="color: #ff0000;">&quot;Cool-guy&quot;</span><span style="color: #66cc66;">&#93;</span>
template <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> groovy.<span style="color: #006600;">text</span>.<span style="color: #006600;">SimpleTemplateEngine</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">createTemplate</span><span style="color: #66cc66;">&#40;</span>text<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">make</span><span style="color: #66cc66;">&#40;</span>params<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>For this particular here-document example, note the single-quotes on the text variable, as double-quotes will cause the string to be treated as GString and hence resolve our bound variables earlier than needed. </p>
<p>Another way to do even simpler templates :</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">messageTemplate <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">' &quot;Let today ${new Date()} be a new start&quot; '</span>
message <span style="color: #66cc66;">=</span> evaluate<span style="color: #66cc66;">&#40;</span>messageTemplate<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Bear in mind that the examples above are ment to cover the case where the template string comes from else where (text file, user input) and has to be processed. otherwise the evaluate example would sound useless, because one can just run the line &#8220;Let today ${new Date()} be a new start&#8221; without evaluate.</p>
<p><a href="http://groovy.codehaus.org/Groovy+Templates">Here is a wider coverage for the topic</a></p>
]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/07/groovy-simple-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The wars are over, let the era of peace and prosperty begin!</title>
		<link>http://noor.ojuba.org/2008/07/the-wars-are-over-let-the-era-of-peace-and-prosperty-begin/</link>
		<comments>http://noor.ojuba.org/2008/07/the-wars-are-over-let-the-era-of-peace-and-prosperty-begin/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 08:50:08 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://noor.ojuba.org/?p=13</guid>
		<description><![CDATA[In the computer industry, the pendulum of debate, innovation, and building infrastructure at one end vs building up complete and ready solutions on the other end keeps swinging every 20 years (more or less).
So here it comes, to the rest of the thinkers and planners and to the delight of the builders and engineers; the [...]]]></description>
			<content:encoded><![CDATA[<p>In the computer industry, the pendulum of debate, innovation, and building infrastructure at one end vs building up complete and ready solutions on the other end keeps swinging every 20 years (more or less).</p>
<p>So here it comes, to the rest of the thinkers and planners and to the delight of the builders and engineers; the era of FLOSS</p>
<p><span id="more-13"></span></p>
<p>In this blog, I might sound biased or short-sighted. Its really just an opinion based on my day to day findings. Please don&#8217;t be harsh on me, if you want to comment, take me completely out of the picture and focus on the ideas and let them debate in a professional fashion.</p>
<p><br/></p>
<h2>In the beginning there was the operating system</h2>
<p>In my professional view, GNU/Linux (and  FLOSS) is the clear winner (over MacOs and Windows) &#8230;<br />
<strong>GNU/Linux</strong> is not a prospect, or a great idea any more. its a solid fact on the ground. that is being used millions of people in mission critical systems addressing real life needs, both at home and at work. with an ever increasing adoption rate, the whole <strong>FLOSS era</strong> has certainly passed its childhood as being opted by hopiests and enthusiasts into being used in real life by real people wither individuals or organizations.</p>
<p>In a very ironic and unexpected fashion, Windows Vista is a great failure. It took too long to come up with, and when it came it was a disaster on two important aspects : performance, hence requiring considerably more hardware power to run, and stability. </p>
<p>This very incident is what probably gave GNU/Linux the time to get a head of Windows.<br />
<br/></p>
<h2>On the server-side</h2>
<p>The FLOSS has the lead in adoption and innovation, this wasn&#8217;t the case few years ago.</p>
<p>Java et al has become fully open source; Groovy and Grails is second to none when it comes to agile web-development, Ruby on Rails started the new era of web 2.0 and RAD web development, Php is the people&#8217;s scripting language, Apache is the leading web server, MySQL and PostgreSQL have the full horse power to compete with the big boys and so forth.</p>
<p>The road a head is so clear to the point where there is no need to make any case for FLOSS on the server side. FLOSS offers a wide variety of options covering most of today&#8217;s needs.<br />
No need for me, as a technology consultant, to ever think twice about choosing FLOSS vs Proprietary.</p>
<p>What about <strong>Open Solaris</strong>? That will surely continue to be the big brother covering up for GNU/Linux for even more critical situation. The relation between Open Solaris and GNU/Linux is not a competition, its rather complementary.<br />
<br/></p>
<h2>On the desktop/client-side</h2>
<p>Within GNU/Linux there has been another war, the War of the Desktop Environments (DE) and the war of toolkits &#8230;<br />
On the Desktop Environment side, I believe its time to declare that there has been no winner! <img src='http://noor.ojuba.org/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /><br />
Not KDE nor GNOME.<br />
<strong>KDE</strong> went into a very unpleasant direction with KDE4, its becoming more like the fantasy of its developers as opposed to being practical and usable. With the huge effort and long time (2years plus now) put on those fantasies as opposed to just upgrading its core tool kit from Qt 3.x to Qt 4.x means its not expected that KDE4 steers back to doing just that. KDE 3.x series was the best ever released Desktop  environment on Linux platform.<br />
<strong>GNOME</strong> has caught the infection, actually even before KDE 4 started. With the completely unjustified adoration to Microsoft &#8230; comes the Mono project. Which is &#8211; with all respect to the hard working people who made it happen &#8211; a shame. <strong>Most</strong> of the FLOSS working class who create software <em>have</em> realized that following on the heels of someone else is a never ending story, and will get us no where. FLOSS project leaders need to have independent thinking and a clear vision. Let alone the ugly heaviness of the Mono project and its apps, compared to plain gtk.</p>
<p>For my day to day use, I am relying on <strong>XFCE</strong> is my DE of choice, as it covers all my needs, and does a great job in letting me focus on the apps rather than DE. ( I used to be a die-hard KDE users for the past seven years)</p>
<p>XFCE is so close to becoming a winner and surpassing KDE and GNOME with bounds and leaps, when it comes to simplicity,  and performance.</p>
<p>One important good thing that has been going on for the last few years, is freedesktop.org doing a great job in standardizing the desktop operation regardless of the running environment. All distros have also adopted dbus as their core inter-process communication engine.<br />
Minimizing the importance the importance of KDE or GNOME and maximizing the importance of standardization. This is why XFCE was able to fit so easily.</p>
<p>Back to the basics, XFCE (or the like of a lightweight DE) along with Gtk/Qt only apps seem to be the natural direction. Given the fact that Gtk and Qt app run on the other platforms without much of a hassle. Application developer from the two camps (kde and gnome) need now to steer away from DE and back into being Toolkit centric; or at least offer that option.</p>
<p>Both Qt and Gtk only apps are fast and snappy and don&#8217;t require lots of depdency. Unlike DE Apps, which would require the whole underlying libraries and subsystems of the respective DE.</p>
<p>If I like konqueror why should I live with the kde dinosaur?!</p>
<p>As with the Gtk case, more and more Qt-only apps are showing (e.g. Speedcrunch, Aurora), some KDE apps are also supporting Qt-only mode (kchmviewer).</p>
<p>I tried those types of apps on GNOME or XFCE only environment and they are a breeze to run. No performance overhead, despite the fact they need to load Qt libraries, but this happens only once and doesn&#8217;t eat much memory.</p>
<p>In the debate between Qt and Gtk, and despite all the nice things Gtk offers. Qt is the clear winner.<br />
Qt 4.4 is becoming the jewel of the crown in the FLOSS world, Qt 4.5 is expected to shine even more.</p>
<p>Last but not least, Qt being GPL&#8217;ed on all platforms eliminates the last obstacle of adoption. Remember, this was the very reason why GNOME started off from KDE.</p>
<p>I predict that Qt Apps will have a huge edge, presenting cross-platform open-source alternatives, every overtaking existing big names such as firefox and Openoffice.</p>
<ul>
<li>Web-kit based Web browser</li>
<li>Phonon based player</li>
<li>Office suite that natively supports ODF</li>
<li>Simplified Desktop environment that is xfce-like, that runs on all platforms</li>
<li>&#8230; and so forth</li>
</ul>
<p>The very notion of becoming cross-platform is really important and intriguing; no more do you as an application developer limit your user with their choice of platform. hence giving your app a far wider base of audience.<br />
Look at what OpenOffice and Firefox did. They are almost every where.</p>
<p>Same token applies on embedded systems, wither mobiles, sub-notebooks, modems and routers, media centres and so forth.<br />
<br/></p>
<h2>Conclusion</h2>
<p>The important and strategic point to bear in mind is the peace of mind and durability of the software. All FLOSS software is being built to live far longer than its counter part. No fear of vendor locking or  platform dying out. Being cross platform means both developers and users will feel better.</p>
<p>This year, 2008, FLOSS community has completed laying down the technology foundations for many years to come. The pillars and infrastructure is there, its now the time to reap the advantage and develop even more mature applications.</p>
<p>Investing in learning those technologies is a guaranteed one, and could only mean having the advantage.</p>
<p>That shift of mentality and focus is needed to make the next wave of change.</p>
<p>Does that mean innovation on those areas has reached its limit? no. but it means the pendulum is now shifting to building up applications as the infrastructure and its related thinking process is completed.</p>
<p>The road for the next years is clear for FLOSS to become the leader in the computer software industry. I am very optimistic on where FLOSS stands now and where its heading, having great confident that the best is yet to come.</p>
]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/07/the-wars-are-over-let-the-era-of-peace-and-prosperty-begin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GEdit with Groovy</title>
		<link>http://noor.ojuba.org/2008/06/gedit-with-groovy/</link>
		<comments>http://noor.ojuba.org/2008/06/gedit-with-groovy/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 07:22:26 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[Fedora 9]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovlet]]></category>
		<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://ojuba.org/kefahblog/?p=8</guid>
		<description><![CDATA[Need a cool development setup for Groovy and Grails on Linux?
No I don&#8217;t mean Eclipse nor IntelliJ, and Yes, I&#8217;m smart enough for that I&#8217;m dumping the autocompletion and autoerror detection; at least I know i&#8217;m smarter than the current plugins for those two.  

Searching for a good development setup for my groovy and [...]]]></description>
			<content:encoded><![CDATA[<p>Need a cool development setup for Groovy and Grails on Linux?</p>
<p>No I don&#8217;t mean Eclipse nor IntelliJ, and Yes, I&#8217;m smart enough for that I&#8217;m dumping the autocompletion and autoerror detection; at least I know i&#8217;m smarter than the current plugins for those two. <img src='http://noor.ojuba.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-8"></span></p>
<p>Searching for a good development setup for my groovy and grails projects, i tried IntelliJ and Eclipse along with their groovy and grails plugins. I wasn&#8217;t impressed, more so because they fail to properly understand things and give you errors where there are none.</p>
<p>So, I eneded up using GEdit which is a very nice piece of software. I whished Geany had groovy syntax highlight support, but it doesn&#8217;t, further more, Geany doesn&#8217;t do a good job when dealing with Arabic text inside the code; while GEdit has a fairly good support for arabic.</p>
<p>GEdit doesn&#8217;t come with groovy support out of the box, after a short search I found this article :<br />
http://www.sudovi.com/blog/show/teach_gedit_grails<br />
That worked for me.</p>
<p>Here is how it looks like :</p>
<p><a href="http://ojuba.org/kefahblog/wp-content/uploads/2008/06/grails-app-gedit1.png"><img class="alignnone size-medium wp-image-10" title="Grails development on GEdit" src="http://ojuba.org/kefahblog/wp-content/uploads/2008/06/grails-app-gedit1-300x264.png" alt="Grails and GEdit" width="300" height="264" /></a><br />
I then compiled all the steps needed to enable groovy on gedit in one handy bashscript file for Fedora 9:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">&gt;</span> groovy-gsp-mime.xml <span style="color: #cc0000; font-style: italic;">&lt;&lt; EOF
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;mime-info xmlns=&quot;http://www.freedesktop.org/standards/shared-mime-info&quot;&gt;
&nbsp;
	&lt;mime-type type=&quot;text/x-groovy&quot;&gt;
		&lt;sub-class-of type=&quot;text/x-java&quot;/&gt;
		&lt;comment&gt;Groovy Source File&lt;/comment&gt;
		&lt;glob pattern=&quot;*.groovy&quot;/&gt;
	&lt;/mime-type&gt;
&nbsp;
	&lt;mime-type type=&quot;text/x-gsp&quot;&gt;
		&lt;sub-class-of type=&quot;text/html&quot;/&gt;
		&lt;comment&gt;Grails GSP File&lt;/comment&gt;
		&lt;glob pattern=&quot;*.gsp&quot;/&gt;
	&lt;/mime-type&gt;
&nbsp;
&lt;/mime-info&gt;
EOF</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">&gt;</span> groovy.lang <span style="color: #cc0000; font-style: italic;">&lt;&lt; EOF
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;language id=&quot;groovy&quot; _name=&quot;Groovy&quot; version=&quot;2.0&quot; _section=&quot;Sources&quot;&gt;
  &lt;metadata&gt;
    &lt;property name=&quot;mimetypes&quot;&gt;text/x-groovy&lt;/property&gt;
    &lt;property name=&quot;globs&quot;&gt;*.groovy&lt;/property&gt;
    &lt;property name=&quot;line-comment-start&quot;&gt;//&lt;/property&gt;
    &lt;property name=&quot;block-comment-start&quot;&gt;/*&lt;/property&gt;
    &lt;property name=&quot;block-comment-end&quot;&gt;*/&lt;/property&gt;
  &lt;/metadata&gt;
&nbsp;
  &lt;styles&gt;
    &lt;style id=&quot;comment&quot; _name=&quot;Comment&quot; map-to=&quot;def:comment&quot;/&gt;
    &lt;style id=&quot;error&quot; _name=&quot;Error&quot; map-to=&quot;def:error&quot;/&gt;
    &lt;style id=&quot;string&quot; _name=&quot;String&quot; map-to=&quot;def:string&quot;/&gt;
    &lt;style id=&quot;external&quot; _name=&quot;External&quot; map-to=&quot;def:preprocessor&quot;/&gt;
    &lt;style id=&quot;declaration&quot; _name=&quot;Declaration&quot; map-to=&quot;def:type&quot;/&gt;
    &lt;style id=&quot;storage-class&quot; _name=&quot;Storage Class&quot; map-to=&quot;def:type&quot;/&gt;
    &lt;style id=&quot;scope-declaration&quot; _name=&quot;Scope Declaration&quot; map-to=&quot;def:type&quot;/&gt;
    &lt;style id=&quot;keyword&quot; _name=&quot;Keyword&quot; map-to=&quot;def:keyword&quot;/&gt;
    &lt;style id=&quot;null-value&quot; _name=&quot;Null Value&quot; map-to=&quot;def:special-constant&quot;/&gt;
    &lt;style id=&quot;boolean&quot; _name=&quot;Boolean value&quot; map-to=&quot;def:boolean&quot;/&gt;
    &lt;style id=&quot;number&quot; _name=&quot;Number&quot; map-to=&quot;def:decimal&quot;/&gt;
    &lt;style id=&quot;reserved&quot; _name=&quot;Future Reserved Keywords&quot; map-to=&quot;def:error&quot;/&gt;
    &lt;style id=&quot;type&quot; _name=&quot;Data Type&quot; map-to=&quot;def:type&quot;/&gt;
  &lt;/styles&gt;
&nbsp;
  &lt;definitions&gt;
&nbsp;
    &lt;context id=&quot;string&quot; style-ref=&quot;string&quot; end-at-line-end=&quot;true&quot;&gt;
      &lt;start&gt;&quot;&lt;/start&gt;
      &lt;end&gt;&quot;&lt;/end&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;string-2&quot; style-ref=&quot;string&quot; end-at-line-end=&quot;true&quot;&gt;
      &lt;start&gt;'&lt;/start&gt;
      &lt;end&gt;'&lt;/end&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;line-comment&quot; style-ref=&quot;comment&quot; end-at-line-end=&quot;true&quot;&gt;
      &lt;start&gt;//&lt;/start&gt;
      &lt;include&gt;
        &lt;context ref=&quot;def:in-line-comment&quot;/&gt;
      &lt;/include&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;block-comment&quot; style-ref=&quot;comment&quot;&gt;
      &lt;start&gt;/*&lt;/start&gt;
      &lt;end&gt;*/&lt;/end&gt;
      &lt;include&gt;
        &lt;context ref=&quot;def:in-comment&quot;/&gt;
      &lt;/include&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;close-comment-outside-comment&quot; style-ref=&quot;error&quot;&gt;
      &lt;match&gt;*/(?!*)&lt;/match&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;externals&quot; style-ref=&quot;external&quot;&gt;
      &lt;keyword&gt;import&lt;/keyword&gt;
      &lt;keyword&gt;package&lt;/keyword&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;declarations&quot; style-ref=&quot;declaration&quot;&gt;
      &lt;keyword&gt;class&lt;/keyword&gt;
      &lt;keyword&gt;enum&lt;/keyword&gt;
      &lt;keyword&gt;extends&lt;/keyword&gt;
      &lt;keyword&gt;implements&lt;/keyword&gt;
      &lt;keyword&gt;instanceof&lt;/keyword&gt;
      &lt;keyword&gt;interface&lt;/keyword&gt;
      &lt;keyword&gt;native&lt;/keyword&gt;
      &lt;keyword&gt;throws&lt;/keyword&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;primitive-types&quot; style-ref=&quot;type&quot;&gt;
      &lt;keyword&gt;boolean&lt;/keyword&gt;
      &lt;keyword&gt;byte&lt;/keyword&gt;
      &lt;keyword&gt;char&lt;/keyword&gt;
      &lt;keyword&gt;def&lt;/keyword&gt;
      &lt;keyword&gt;double&lt;/keyword&gt;
      &lt;keyword&gt;float&lt;/keyword&gt;
      &lt;keyword&gt;int&lt;/keyword&gt;
      &lt;keyword&gt;long&lt;/keyword&gt;
      &lt;keyword&gt;short&lt;/keyword&gt;
      &lt;keyword&gt;void&lt;/keyword&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;storage-class&quot; style-ref=&quot;storage-class&quot;&gt;
      &lt;keyword&gt;abstract&lt;/keyword&gt;
      &lt;keyword&gt;final&lt;/keyword&gt;
      &lt;keyword&gt;static&lt;/keyword&gt;
      &lt;keyword&gt;strictfp&lt;/keyword&gt;
      &lt;keyword&gt;synchronized&lt;/keyword&gt;
      &lt;keyword&gt;transient&lt;/keyword&gt;
      &lt;keyword&gt;volatile&lt;/keyword&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;scope-declarations&quot; style-ref=&quot;scope-declaration&quot;&gt;
      &lt;keyword&gt;private&lt;/keyword&gt;
      &lt;keyword&gt;protected&lt;/keyword&gt;
      &lt;keyword&gt;public&lt;/keyword&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;flow&quot; style-ref=&quot;keyword&quot;&gt;
      &lt;keyword&gt;assert&lt;/keyword&gt;
      &lt;keyword&gt;break&lt;/keyword&gt;
      &lt;keyword&gt;case&lt;/keyword&gt;
      &lt;keyword&gt;catch&lt;/keyword&gt;
      &lt;keyword&gt;continue&lt;/keyword&gt;
      &lt;keyword&gt;default&lt;/keyword&gt;
      &lt;keyword&gt;do&lt;/keyword&gt;
      &lt;keyword&gt;each&lt;/keyword&gt;
      &lt;keyword&gt;else&lt;/keyword&gt;
      &lt;keyword&gt;finally&lt;/keyword&gt;
      &lt;keyword&gt;for&lt;/keyword&gt;
      &lt;keyword&gt;if&lt;/keyword&gt;
      &lt;keyword&gt;render&lt;/keyword&gt;
      &lt;keyword&gt;return&lt;/keyword&gt;
      &lt;keyword&gt;throw&lt;/keyword&gt;
      &lt;keyword&gt;switch&lt;/keyword&gt;
      &lt;keyword&gt;try&lt;/keyword&gt;
      &lt;keyword&gt;while&lt;/keyword&gt;
      &lt;keyword&gt;with&lt;/keyword&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;memory&quot; style-ref=&quot;keyword&quot;&gt;
      &lt;keyword&gt;new&lt;/keyword&gt;
      &lt;keyword&gt;super&lt;/keyword&gt;
      &lt;keyword&gt;this&lt;/keyword&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;future-reserved-words&quot; style-ref=&quot;reserved&quot;&gt;
      &lt;keyword&gt;const&lt;/keyword&gt;
      &lt;keyword&gt;goto&lt;/keyword&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;null-value&quot; style-ref=&quot;null-value&quot;&gt;
      &lt;keyword&gt;null&lt;/keyword&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;boolean&quot; style-ref=&quot;boolean&quot;&gt;
      &lt;keyword&gt;false&lt;/keyword&gt;
      &lt;keyword&gt;true&lt;/keyword&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;numeric&quot; style-ref=&quot;number&quot;&gt;
      &lt;match extended=&quot;true&quot;&gt;
        (b([0-9]+|0[xX][0-9a-fA-F]+)[Ll]?b|
         b(([0-9]+[Ee][-]?[0-9]+|
            ([0-9]*.[0-9]+|[0-9]+.)([Ee][-]?[0-9]+)?)[fFdD]?|
            [0-9]+[FfDd]))
      &lt;/match&gt;
    &lt;/context&gt;
&nbsp;
    &lt;context id=&quot;groovy&quot;&gt;
      &lt;include&gt;
        &lt;context ref=&quot;string&quot;/&gt;
        &lt;context ref=&quot;string-2&quot;/&gt;
        &lt;context ref=&quot;line-comment&quot;/&gt;
        &lt;context ref=&quot;block-comment&quot;/&gt;
        &lt;context ref=&quot;close-comment-outside-comment&quot;/&gt;
        &lt;context ref=&quot;externals&quot;/&gt;
        &lt;context ref=&quot;declarations&quot;/&gt;
        &lt;context ref=&quot;primitive-types&quot;/&gt;
        &lt;context ref=&quot;storage-class&quot;/&gt;
        &lt;context ref=&quot;scope-declarations&quot;/&gt;
        &lt;context ref=&quot;flow&quot;/&gt;
        &lt;context ref=&quot;memory&quot;/&gt;
        &lt;context ref=&quot;future-reserved-words&quot;/&gt;
        &lt;context ref=&quot;null-value&quot;/&gt;
        &lt;context ref=&quot;boolean&quot;/&gt;
        &lt;context ref=&quot;numeric&quot;/&gt;
      &lt;/include&gt;
    &lt;/context&gt;
&nbsp;
  &lt;/definitions&gt;
&lt;/language&gt;
EOF</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">&gt;</span> gsp.lang <span style="color: #cc0000; font-style: italic;">&lt;&lt; EOF
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;language id=&quot;gsp&quot; _name=&quot;GSP&quot; version=&quot;2.0&quot; _section=&quot;Markup&quot;&gt;
    &lt;metadata&gt;
      &lt;property name=&quot;mimetypes&quot;&gt;text/x-gsp&lt;/property&gt;
      &lt;property name=&quot;globs&quot;&gt;*.gsp&lt;/property&gt;
      &lt;property name=&quot;block-comment-start&quot;&gt;&amp;lt;!--&lt;/property&gt;
      &lt;property name=&quot;block-comment-end&quot;&gt;--&amp;gt;&lt;/property&gt;
    &lt;/metadata&gt;
&nbsp;
    &lt;styles&gt;
        &lt;style id=&quot;comment&quot; _name=&quot;Comment&quot; map-to=&quot;xml:comment&quot;/&gt;
        &lt;style id=&quot;tag&quot; _name=&quot;Tag&quot; map-to=&quot;xml:element-name&quot;/&gt;
        &lt;style id=&quot;attrib-name&quot; _name=&quot;Attribute Name&quot; map-to=&quot;xml:attribute-name&quot;/&gt;
        &lt;style id=&quot;attrib-value&quot; _name=&quot;Attribute Value&quot; map-to=&quot;xml:attribute-value&quot;/&gt;
        &lt;style id=&quot;dtd&quot; _name=&quot;DTD&quot; map-to=&quot;xml:doctype&quot;/&gt;
        &lt;style id=&quot;error&quot; _name=&quot;Error&quot; map-to=&quot;xml:error&quot;/&gt;
    &lt;/styles&gt;
&nbsp;
    &lt;default-regex-options case-sensitive=&quot;false&quot;/&gt;
&nbsp;
    &lt;definitions&gt;
        &lt;!-- Html comments are more permissive than xml comments --&gt;
        &lt;context id=&quot;comment&quot; style-ref=&quot;comment&quot;&gt;
            &lt;start&gt;&amp;lt;!--&lt;/start&gt;
            &lt;end&gt;--s*&amp;gt;&lt;/end&gt;
            &lt;include&gt;
                &lt;context ref=&quot;def:in-comment&quot;/&gt;
            &lt;/include&gt;
        &lt;/context&gt;
&nbsp;
        &lt;context id=&quot;dtd&quot; style-ref=&quot;dtd&quot;&gt;
            &lt;start&gt;&amp;lt;!&lt;/start&gt;
            &lt;end&gt;&amp;gt;&lt;/end&gt;
        &lt;/context&gt;
&nbsp;
        &lt;!-- This is a placeholder context intended to be &lt;replace&gt;d
             in languages like php that need to embedd contexts inside
             html tags and attributes.
        --&gt;
        &lt;context id=&quot;embedded-lang-hook&quot;&gt;
            &lt;start&gt;%{def:never-match}&lt;/start&gt;
            &lt;end&gt;&lt;/end&gt;
        &lt;/context&gt;
&nbsp;
        &lt;context id=&quot;generic-tag&quot;&gt;
            &lt;include&gt;
&nbsp;
                &lt;!-- Attribute in the form: name=&quot;value&quot; --&gt;
                &lt;context id=&quot;attrib-quoted&quot; style-ref=&quot;attrib-name&quot;&gt;
                    &lt;start extended=&quot;true&quot;&gt;
                        [A-Za-z0-9:_-]+ # attribute name
                        s*=s*         # &quot;=&quot;
                        (&quot;)            # string beginning
                    &lt;/start&gt;
                    &lt;end&gt;&quot;&lt;/end&gt;
                    &lt;include&gt;
                        &lt;context sub-pattern=&quot;1&quot; where=&quot;start&quot; style-ref=&quot;attrib-value&quot;/&gt;
                        &lt;context sub-pattern=&quot;0&quot; where=&quot;end&quot; style-ref=&quot;attrib-value&quot;/&gt;
                        &lt;context id=&quot;string&quot; extend-parent=&quot;false&quot; end-at-line-end=&quot;true&quot; style-ref=&quot;attrib-value&quot;&gt;
                            &lt;start&gt;%{def:always-match}&lt;/start&gt;
                            &lt;include&gt;
                                &lt;context ref=&quot;xml:entity&quot;/&gt;
                                &lt;context ref=&quot;xml:character-reference&quot;/&gt;
                                &lt;context ref=&quot;embedded-lang-hook&quot;/&gt;
                            &lt;/include&gt;
                        &lt;/context&gt;
                    &lt;/include&gt;
                &lt;/context&gt;
&nbsp;
                &lt;!-- Attribute in the form: name=value --&gt;
                &lt;context id=&quot;attrib-unquoted&quot; style-ref=&quot;attrib-value&quot;&gt;
                    &lt;start extended=&quot;true&quot;&gt;
                        [a-z0-9:_-]+ # attribute name
                        s*=s*      # &quot;=&quot;
                    &lt;/start&gt;
                    &lt;end&gt;(?=&amp;gt;|s)&lt;/end&gt;
                    &lt;include&gt;
                        &lt;context sub-pattern=&quot;0&quot; where=&quot;start&quot; style-ref=&quot;attrib-name&quot;/&gt;
                        &lt;context ref=&quot;xml:entity&quot;/&gt;
                        &lt;context ref=&quot;xml:character-reference&quot;/&gt;
                    &lt;/include&gt;
                &lt;/context&gt;
&nbsp;
                &lt;!-- Attribute in the form: name --&gt;
                &lt;context id=&quot;attrib-no-value&quot; style-ref=&quot;attrib-name&quot;&gt;
                    &lt;match extended=&quot;true&quot;&gt;
                        [a-z0-9:_-]+  # attribute name
                    &lt;/match&gt;
                &lt;/context&gt;
&nbsp;
                &lt;context ref=&quot;embedded-lang-hook&quot;/&gt;
&nbsp;
            &lt;/include&gt;
        &lt;/context&gt;
&nbsp;
        &lt;context id=&quot;script&quot;&gt;
            &lt;start&gt;&amp;lt;s*script%]&lt;/start&gt;
            &lt;end&gt;&amp;lt;s*/s*scripts*&amp;gt;&lt;/end&gt;
&nbsp;
            &lt;include&gt;
                &lt;context sub-pattern=&quot;0&quot; where=&quot;start&quot; style-ref=&quot;tag&quot;/&gt;
                &lt;context sub-pattern=&quot;0&quot; where=&quot;end&quot; style-ref=&quot;tag&quot;/&gt;
                &lt;context ref=&quot;generic-tag&quot;/&gt;
                &lt;context id=&quot;js-code&quot; extend-parent=&quot;false&quot;&gt;
                    &lt;start&gt;&amp;gt;&lt;/start&gt;
                    &lt;include&gt;
                        &lt;context sub-pattern=&quot;0&quot; where=&quot;start&quot; style-ref=&quot;tag&quot;/&gt;
                        &lt;context ref=&quot;js:js&quot;/&gt;
                    &lt;/include&gt;
                &lt;/context&gt;
            &lt;/include&gt;
        &lt;/context&gt;
&nbsp;
        &lt;context id=&quot;tag&quot;&gt;
            &lt;start&gt;&amp;lt;s*/?s*[a-z0-9_-]+&lt;/start&gt;
            &lt;end&gt;/?s*&amp;gt;&lt;/end&gt;
            &lt;include&gt;
                &lt;context sub-pattern=&quot;0&quot; where=&quot;start&quot; style-ref=&quot;tag&quot;/&gt;
                &lt;context sub-pattern=&quot;0&quot; where=&quot;end&quot; style-ref=&quot;tag&quot;/&gt;
                &lt;context ref=&quot;generic-tag&quot;/&gt;
            &lt;/include&gt;
        &lt;/context&gt;
&nbsp;
	&lt;context id=&quot;gtag&quot;&gt;
		&lt;start&gt;&amp;lt;g:s*/?s*[a-z0-9_-]+&lt;/start&gt;
                &lt;end&gt;/?s*&amp;gt;&lt;/end&gt;
            	&lt;include&gt;
                	&lt;context sub-pattern=&quot;0&quot; where=&quot;start&quot; style-ref=&quot;tag&quot;/&gt;
                	&lt;context sub-pattern=&quot;0&quot; where=&quot;end&quot; style-ref=&quot;tag&quot;/&gt;
                	&lt;context ref=&quot;generic-tag&quot;/&gt;
		&lt;/include&gt;
	&lt;/context&gt;
&nbsp;
        &lt;context id=&quot;gsp&quot;&gt;
            &lt;include&gt;
                &lt;context ref=&quot;xml:doctype&quot;/&gt;
                &lt;context ref=&quot;xml:entity&quot;/&gt;
                &lt;context ref=&quot;xml:character-reference&quot;/&gt;
                &lt;context ref=&quot;xml:cdata&quot;/&gt;
                &lt;context ref=&quot;comment&quot;/&gt;
                &lt;context ref=&quot;dtd&quot;/&gt;
                &lt;context ref=&quot;script&quot;/&gt;
                &lt;context ref=&quot;tag&quot;/&gt;
                &lt;context ref=&quot;gtag&quot;/&gt;
            &lt;/include&gt;
        &lt;/context&gt;
&nbsp;
    &lt;/definitions&gt;
&lt;/language&gt;
&nbsp;
EOF</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># Copy the mime</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> groovy-gsp-mime.xml <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>mime<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>groovy.xml
&nbsp;
<span style="color: #666666; font-style: italic;"># Copy the language spec's</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> groovy.lang gsp.lang <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>gtksourceview-<span style="color: #000000;">2.0</span><span style="color: #000000; font-weight: bold;">/</span>language-specs<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">sudo</span> update-mime-database <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>mime
&nbsp;
<span style="color: #666666; font-style: italic;"># Create an empty groovy file</span>
<span style="color: #c20cb9; font-weight: bold;">touch</span> foo.groovy
&nbsp;
<span style="color: #666666; font-style: italic;"># Check if the mime is properly defined</span>
gnomevfs-info foo.groovy</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/06/gedit-with-groovy/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Uploading files to a groovlet</title>
		<link>http://noor.ojuba.org/2008/06/uploading-files-to-a-groovlet/</link>
		<comments>http://noor.ojuba.org/2008/06/uploading-files-to-a-groovlet/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 05:47:09 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[groovy]]></category>
		<category><![CDATA[groovlet]]></category>

		<guid isPermaLink="false">http://ojuba.org/kefahblog/?p=6</guid>
		<description><![CDATA[Groovlets, could be the coolest thing since sliced-bread &#8230; except for the fact that it does n&#8217;t seem to support fileupload! what? why? is there a solution?
Yes!

After some initial research this didn&#8217;t seem as an easy thing to do.
 This patch  suggested changing code in groovy itself, which is something I am not inclined [...]]]></description>
			<content:encoded><![CDATA[<p>Groovlets, could be the coolest thing since sliced-bread &#8230; except for the fact that it does n&#8217;t seem to support fileupload! what? why? is there a solution?</p>
<p>Yes!</p>
<p><span id="more-6"></span></p>
<p>After some initial research this didn&#8217;t seem as an easy thing to do.</p>
<p><a href="http://jira.codehaus.org/browse/GROOVY-895"> This patch </a> suggested changing code in groovy itself, which is something I am not inclined to do. So, I used the ideas from that patch and made the fileupload (multipart) work without it &#8230;</p>
<p>I downloaded the commons-fileupload-1.2.1.jar  commons-io-1.4.jar from <a href="http://commons.apache.org/">Apache commons project</a><br />
into jetty-6.1.11/webapps/glet/WEB-INF/lib/</p>
<p>Then added the needed code to the beginning of the menu.groovy (renamed .glet to work with my web.xml)</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">org.apache.commons.fileupload.DiskFileUpload</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">org.apache.commons.fileupload.FileItem</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">org.apache.commons.fileupload.FileUpload</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">org.apache.commons.fileupload.FileUploadException</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">java.util.HashMap</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">java.util.List</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">java.util.Map</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #aaaadd; font-weight: bold;">Map</span> uploads <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">HashMap</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>FileUpload.<span style="color: #006600;">isMultipartContent</span><span style="color: #66cc66;">&#40;</span>request<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  DiskFileUpload parser <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DiskFileUpload<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
   <span style="color: #aaaadd; font-weight: bold;">List</span> items<span style="color: #66cc66;">;</span>
   <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span>
    items <span style="color: #66cc66;">=</span> parser.<span style="color: #006600;">parseRequest</span><span style="color: #66cc66;">&#40;</span>request<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
  <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span>FileUploadException e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">//Ooops! Something gone bad while parsing request.</span>
    <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">RuntimeException</span><span style="color: #66cc66;">&#40;</span>e<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #993333;">int</span> i <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span>
  <span style="color: #993333;">int</span> n <span style="color: #66cc66;">=</span> items.<span style="color: #663399;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span> i <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">;</span> i <span style="color: #66cc66;">&amp;</span>lt<span style="color: #66cc66;">;</span> n<span style="color: #66cc66;">;</span> i<span style="color: #66cc66;">++</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    FileItem item <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#40;</span>FileItem<span style="color: #66cc66;">&#41;</span> items.<span style="color: #663399;">get</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #aaaadd; font-weight: bold;">String</span> itemName <span style="color: #66cc66;">=</span> item.<span style="color: #006600;">getFieldName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>item.<span style="color: #006600;">isFormField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      params.<span style="color: #006600;">put</span><span style="color: #66cc66;">&#40;</span>itemName, item.<span style="color: #006600;">getString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
      uploads.<span style="color: #006600;">put</span><span style="color: #66cc66;">&#40;</span>itemName, item<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">def</span> mealType <span style="color: #66cc66;">=</span> params<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'mealType'</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #000000; font-weight: bold;">def</span> menuFile <span style="color: #66cc66;">=</span> uploads<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'menuFile'</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
html.<span style="color: #006600;">html</span> <span style="color: #66cc66;">&#123;</span>
  head <span style="color: #66cc66;">&#123;</span>
      title<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Gromit Menu&quot;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#125;</span>
  body <span style="color: #66cc66;">&#123;</span>
    table <span style="color: #66cc66;">&#123;</span>
      tr <span style="color: #66cc66;">&#123;</span>
        td <span style="color: #66cc66;">&#123;</span>
          span<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;This is your menu for gromit for ${mealType}&quot;</span><span style="color: #66cc66;">&#41;</span>
          br<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
          i<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;You uploaded file ${menuFile.name}, ${menuFile.size} bytes&quot;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#125;</span>
      <span style="color: #66cc66;">&#125;</span>
      tr <span style="color: #66cc66;">&#123;</span>
        td <span style="color: #66cc66;">&#123;</span>
          menuFile.<span style="color: #006600;">inputStream</span>.<span style="color: #FFCC33;">eachLine</span> <span style="color: #66cc66;">&#123;</span>
            html.<span style="color: #006600;">span</span><span style="color: #66cc66;">&#40;</span>it<span style="color: #66cc66;">&#41;</span>
            html.<span style="color: #006600;">br</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
          <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
      <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>Conclusion</strong><br />
Groovy is not just a wonderful new agile programming language, its much more than that. As it builds its success on the shoulders of giants (Java et al), the sky is the limit for any problem you might come across.</p>
]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/06/uploading-files-to-a-groovlet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Groovlets and GSP, setting up</title>
		<link>http://noor.ojuba.org/2008/06/groovlets-setting-up/</link>
		<comments>http://noor.ojuba.org/2008/06/groovlets-setting-up/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 05:32:29 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[groovy]]></category>
		<category><![CDATA[groovlet]]></category>

		<guid isPermaLink="false">http://ojuba.org/kefahblog/?p=4</guid>
		<description><![CDATA[Groovelts and Groovy Server Pages are unbelievably simple to set-up and use, quick and dirty web-api&#8217;s and proof of concept can be implemented in no time!

Using groovy as a serverlet (also known as Groovlet) is a really cool thing. Grails is a must if you want to develop a complex web-app, but what about the [...]]]></description>
			<content:encoded><![CDATA[<p>Groovelts and Groovy Server Pages are unbelievably simple to set-up and use, quick and dirty web-api&#8217;s and proof of concept can be implemented in no time!</p>
<p><span id="more-4"></span></p>
<p>Using groovy as a serverlet (also known as Groovlet) is a really cool thing. Grails is a must if you want to develop a complex web-app, but what about the small quickies that can be done in minutes? groovlets are surely the answer.</p>
<p>In just one-liner groovlet I could solve a problem at work that has been outstanding for weeks.</p>
<p>Here is how to set it up :</p>
<ol>
<li>Download and unzip groovy binary package and  jetty servlet engine. in my case the two folders are ~/Development/jetty-6.1.11 and ~/Development/groovy-1.5.6. Needless to say, you need Java (Standard Edition JDK)  preferably the latest release (mine is 1.6).</li>
<li>Create your groovlet webapp folder structure

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> ~<span style="color: #000000; font-weight: bold;">/</span>Development<span style="color: #000000; font-weight: bold;">/</span>jetty-6.1.11<span style="color: #000000; font-weight: bold;">/</span>webapps<span style="color: #000000; font-weight: bold;">/</span>glet<span style="color: #000000; font-weight: bold;">/</span>WEB-INF<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

</li>
<li>Copy groovy run-time jar file to your servlet lib folder

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> ~<span style="color: #000000; font-weight: bold;">/</span>Development<span style="color: #000000; font-weight: bold;">/</span>groovy-1.5.6<span style="color: #000000; font-weight: bold;">/</span>embeddable<span style="color: #000000; font-weight: bold;">/</span>groovy-all-1.5.6.jar \
~<span style="color: #000000; font-weight: bold;">/</span>Development<span style="color: #000000; font-weight: bold;">/</span>jetty-6.1.11<span style="color: #000000; font-weight: bold;">/</span>webapps<span style="color: #000000; font-weight: bold;">/</span>glet<span style="color: #000000; font-weight: bold;">/</span>WEB-INF<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

</li>
<li>Create  ~/Development/jetty-6.1.11/webapps/glet/WEB-INF/web.xml file with the following content

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #808080; font-style: italic;">&lt;!-- Setup Groovlets --&gt;</span>
&nbsp;
        glet
        groovy.servlet.GroovyServlet
&nbsp;
        glet
        *.glet
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- Setup Groovy Server Pages (GSP) --&gt;</span>
&nbsp;
        GroovyTemplate
        groovy.servlet.TemplateServlet
&nbsp;
        GroovyTemplate
        *.gsp
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- The Welcome File List --&gt;</span>
&nbsp;
        index.glet</pre></div></div>

</li>
<li>The Groovlet : Create ~/Development/jetty-6.1.11/webapps/glet/index.glet with the following content

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> mylist <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Hello&quot;</span>, <span style="color: #ff0000;">&quot;World!&quot;</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
html.<span style="color: #006600;">html</span> <span style="color: #66cc66;">&#123;</span>
  head <span style="color: #66cc66;">&#123;</span>
    title<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;My nice index page&quot;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#125;</span>
  body <span style="color: #66cc66;">&#123;</span>
    table <span style="color: #66cc66;">&#123;</span>
      tr <span style="color: #66cc66;">&#123;</span>
        td <span style="color: #66cc66;">&#123;</span>
          span<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;This is a test page ...&quot;</span><span style="color: #66cc66;">&#41;</span>
          br<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
          i<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;In case you want italic&quot;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#125;</span>
      <span style="color: #66cc66;">&#125;</span>
      tr <span style="color: #66cc66;">&#123;</span>
        td <span style="color: #66cc66;">&#123;</span>
          mylist.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span>
            html.<span style="color: #006600;">span</span><span style="color: #66cc66;">&#40;</span>it<span style="color: #66cc66;">&#41;</span>
            html.<span style="color: #006600;">br</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
          <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
      <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
                span<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Hello there&quot;</span><span style="color: #66cc66;">&#41;</span>
                h1<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Hala&quot;</span><span style="color: #66cc66;">&#41;</span>
                h2<span style="color: #66cc66;">&#123;</span>
                        i<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;nice meeting you&quot;</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#125;</span>
                b<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;cake&quot;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
                <span style="color: #66cc66;">&#40;</span>0..3<span style="color: #66cc66;">&#41;</span>.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span> p <span style="color: #66cc66;">&#40;</span>it<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;hala 3ammi&quot;</span>
&nbsp;
        h1 <span style="color: #ff0000;">&quot;XML encoding with Groovy&quot;</span>
        p <span style="color: #ff0000;">&quot;this format can be used as an alternative markup to XML&quot;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/* an element with attributes and text content */</span>
        a href:<span style="color: #ff0000;">'http://groovy.codehaus.org'</span>, <span style="color: #ff0000;">&quot;Groovy&quot;</span>
&nbsp;
        p <span style="color: #ff0000;">&quot;some text&quot;</span>
&nbsp;
        p <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;this is some&quot;</span>, b <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;mixed&quot;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">&quot;text.&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
        pre <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;a&quot;</span>, <span style="color: #ff0000;">&quot;b&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #66cc66;">&#40;</span>0..3<span style="color: #66cc66;">&#41;</span>.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span><span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;danni&quot;</span><span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
        p <span style="color: #ff0000;">&quot;other text&quot;</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The above html style is called HTML Builder, and it gives a different paradigm for servlet development.<br />
Another dummy example .. :</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>session<span style="color: #66cc66;">&#41;</span>
  session <span style="color: #66cc66;">=</span> request.<span style="color: #006600;">getSession</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>session.<span style="color: #006600;">counter</span><span style="color: #66cc66;">&#41;</span>
      session.<span style="color: #006600;">counter</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span>
&nbsp;
html.<span style="color: #006600;">html</span> <span style="color: #66cc66;">&#123;</span>    <span style="color: #808080; font-style: italic;">// html is implicitly bound to new MarkupBuilder(out)</span>
  head <span style="color: #66cc66;">&#123;</span> title<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Groovy Servlet&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span>
  body <span style="color: #66cc66;">&#123;</span>
    h1<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Hello, ${request.remoteHost}:&quot;</span><span style="color: #66cc66;">&#41;</span>
    p<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;${session.counter}! ${new Date()}&quot;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
session.<span style="color: #006600;">counter</span> <span style="color: #66cc66;">=</span> session.<span style="color: #006600;">counter</span>.<span style="color: #006600;">toInteger</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #cc66cc;">1</span></pre></div></div>

<p><a href="http://groovy.codehaus.org/Groovlets">More on groovlets</a></li>
<li> The Groovy Server Page Create ~/Development/jetty-6.1.11/webapps/glet/mypage.gsp with the following content

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">&nbsp;
<span style="color: #66cc66;">&lt;</span>strong<span style="color: #66cc66;">&gt;&amp;</span>lt<span style="color: #66cc66;">;%</span> <span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;mypage gsp&quot;</span> <span style="color: #66cc66;">%&amp;</span>gt<span style="color: #66cc66;">;&lt;</span>/strong<span style="color: #66cc66;">&gt;</span>
&nbsp;
<span style="color: #66cc66;">&amp;</span>lt<span style="color: #66cc66;">;%</span> wrd <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;Groovy&quot;</span>
   <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i <span style="color: #b1b100;">in</span> wrd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
 <span style="color: #66cc66;">%&amp;</span>gt<span style="color: #66cc66;">;</span>
<span style="color: #66cc66;">&lt;</span>h1<span style="color: #66cc66;">&gt;</span> <span style="color: #66cc66;">&amp;</span>lt<span style="color: #66cc66;">;%=</span>i<span style="color: #66cc66;">%&amp;</span>gt<span style="color: #66cc66;">;</span> 
&nbsp;
 <span style="color: #66cc66;">&amp;</span>lt<span style="color: #66cc66;">;%</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">%&amp;</span>gt<span style="color: #66cc66;">;&lt;</span>/h1<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>Just for the record, this is not exactly the same GSP that comes with grails. The GSP module that comes with grails offers more features.</li>
<li>Start jetty and browse to http://localhost:8080/glet</li>
</ol>
<p>You can also do it in other ways, like using print &#8220;&lt;html&gt; &#8230; &#8220;  instead of the html DSL.</p>
<p>Here is a oneliner example groovlet :</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;
&lt;h1&gt; Hello  ${params[&quot;</span>name<span style="color: #ff0000;">&quot;]} to the world of groovlets&lt;/h1&gt;
&quot;</span></pre></div></div>

<p>put this line in say this file :jetty-6.1.11/webapps/glet/hello.glet</p>
<p>then call it from here : http://localhost:8080/glet/hello.glet?name=kefah</p>
<p>I thought glet is a nice shortname for groovlet.</p>
<p>The nice thing about groovlets is that you can edit them and create new ones and they will work on the fly. no need to restart jetty or recompile code.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/06/groovlets-setting-up/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>My search for a web-development framework</title>
		<link>http://noor.ojuba.org/2008/06/my-search-for-a-web-development-framework/</link>
		<comments>http://noor.ojuba.org/2008/06/my-search-for-a-web-development-framework/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 05:01:29 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[web-framework]]></category>

		<guid isPermaLink="false">http://ojuba.org/kefahblog/?p=3</guid>
		<description><![CDATA[Would the debate on the best Web-development framework evern end? probably not, becuase debate reflects the very nature of us humans. We see things from different angles, and apply them to different cases &#8230;
Nevertheless, for the yours truly this does not have to be the case&#8230; here is my angle &#8230;

The need and demand to [...]]]></description>
			<content:encoded><![CDATA[<p>Would the debate on the best Web-development framework evern end? probably not, becuase debate reflects the very nature of us humans. We see things from different angles, and apply them to different cases &#8230;</p>
<p>Nevertheless, for the yours truly this does not have to be the case&#8230; here is my angle &#8230;</p>
<p><span id="more-3"></span></p>
<p>The need and demand to build content-oriented websites have been knocking my door for that last 10 years. I built several solutions, using ASP, PHP, Cocoon, Lenya, Ruby on Rails, Java Servlets &#8230; along few others. Each of them had its own shortcomings that made me not to choose again in my next project.</p>
<p>I spent good portion of my time just searching for a better alternative &#8230;</p>
<p>Ruby on Rails (RoR): My experience with Rails has started around two years ago. Rails was a cool technology. However it didn&#8217;t live up to the expectations. I think both Ruby and the Rails framework has fundamental implementation issues that should have been solved two years ago, but nothing was done about it. so, after the huge hype and promotion, its cooling down slowly. Now, as they say &#8220;Good things never go away&#8221; Ruby on Rails made every one think again about how to write web-frame works and how to make it easy and sensible. Java and PHP communities among many others made the move and benefited from the wonderful approach that Rails has offered to web-development.</p>
<p>That being said, RoR has become more like a reference to an original concept.</p>
<p>But what are the limitations of RoR? one may ask, the answer is simple : Performance and Scalability.</p>
<p>Should Ruby 2.0 have been released two years ago, RoR would probably have been the preferred choice. but any advancement in Ruby has been staggering for too too long.</p>
<p>I would never blame any one for that, things are what they are. I&#8217;m sure the ruby-developer-community have their reasons. but for me, it means that i have to find my way again in my search for a web-development framework. That was around the beginning of this year.</p>
<p>Lenya 2.0 :A well-architected option that simply has major problems in running up to its advertised features. its very hard to get things working, and if you come up with any specific need that wasn&#8217;t previously thought of it would also be super hard to implement. I know that my comments on Lenya might sound too subjective, but they are not; they are based on months of trying and digging and learning without any avail.</p>
<p>PHP (CakePHP, codeIginator, Symphony) : I never got into PHP really. I know that the computer language is but a tool, but I think PHP being made very easy by design made it too difficult for someone like myself. <img src='http://noor.ojuba.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Groovy and Grails : Although I heard about it couple of years, it never really caught my attention. &#8220;what would just-another-ruby-on-rails replica bring to the world!?&#8221; I asked by then.<br />
Things have changed, though. For the last four weeks, I have got my hands dirty and my feet wet with Groovy and Grails&#8230; and I must say that I am amazed.</p>
<p>What I found so cool about it &#8230;</p>
<ol>
<li>Compiled and not interpreted. So its not an interpreter on top a virtual machine.</li>
<li>Full Java interchangeability, even the syntax pretty much overlaps. to the degree that if you change the extension of a java file to groovy it would probably work with minimal changes. which means that you can inter-mingle java code and libraries with groovy ones.</li>
<li>Grails builds on top of industrial-strength components such as Hibernate and Spring. Hence you will find your most demanding needs covered.</li>
</ol>
<p>The one shortcoming would be performance (but not scalability). That is grails is multi-threaded (unlike Rails that is single threaded, even on JRuby, rails remain to be single threaded).</p>
<p>But performance is improving, groovy 1.6 promises to bring it closer.</p>
<p>On the grails website, they say &#8220;The search is over&#8221; I started to realize and believe in that &#8230; hope my search will be over at least for the next few years.<br />
more to come &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/06/my-search-for-a-web-development-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://noor.ojuba.org/2008/06/hello-world/</link>
		<comments>http://noor.ojuba.org/2008/06/hello-world/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 04:20:40 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://ojuba.org/kefahblog/?p=1</guid>
		<description><![CDATA[I never thought that I would have a blog, I am not a talking-kind-of-person. But now I started to see it as a good method to keep my notes in one place and make them availalbe. Just a 2 cents kind of stuff.
]]></description>
			<content:encoded><![CDATA[<p>I never thought that I would have a blog, I am not a talking-kind-of-person. But now I started to see it as a good method to keep my notes in one place and make them availalbe. Just a 2 cents kind of stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/06/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
