<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>groovy &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/groovy/</link>
	<description>Feed of posts on WordPress.com tagged "groovy"</description>
	<pubDate>Tue, 14 Oct 2008 05:50:47 +0000</pubDate>

	<generator>http://wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Groovy and java inheritance]]></title>
<link>http://alexlexecorp.wordpress.com/?p=584</link>
<pubDate>Mon, 13 Oct 2008 19:40:10 +0000</pubDate>
<dc:creator>Alex</dc:creator>
<guid>http://lexecorp.com/2008/10/14/groovy-and-java-inheritance/</guid>
<description><![CDATA[The meek may inherit the earth, but Java can inherit Groovy. Yes, Groovy can not only extend a base ]]></description>
<content:encoded><![CDATA[<p>The meek may inherit the earth, but Java can inherit Groovy. Yes, Groovy can not only extend a base Java class, but once done, Java can do exactly the same with that derived groovy class. Thanks Bob for you input, and I see no point in doing anything but quoting you directly :-)</p>
<blockquote><p>W.r.t your example: all the other 'pretenders' (JRuby, Jython, etc) can do<br />
something similar, none of them can then further extend the GUsesJ class<br />
with another Java class (ie J -&#62; G -&#62; J -&#62; J -&#62; G -&#62; J, etc.)</p></blockquote>
<p>yes, did I make this point before, it can all be compiled to bytecodes and so are equal within the JVM. </p>
<p>This leads me to the recent announcement by the Mono Project (cross platform .NET) about their <a href="http://www.mono-project.com/news/archive/2008/Oct-06.html">Version 2.0 release</a>. I used Mono a few years back to allow a new Java Windows server product to have a fast result on a fax delivery end point for scanned images (using faxcomlib). C# made accessing the operating system a doddle, plus the C#/.NET high level abstraction meant that a complex task was reduced to a days coding. It took as long to suggest the technology and get a Java shop to accept that results were better than third party licences eroding profits on a purists "Java only" solution.</p>
<p>OK I mention Mono because, even though a google search for Groovy + .NET doesn't pull much up, it should be quite feasible to have Groovy supported by the IKVM, i.e. running in a CLR on a par with C# code! Now I enjoyed coding in C# and it might be up to discussion as to whether Groovy has a place in the .NET space!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Making Swing Groovy, Part III: EDT]]></title>
<link>http://kousenit.wordpress.com/?p=146</link>
<pubDate>Mon, 13 Oct 2008 16:48:09 +0000</pubDate>
<dc:creator>Ken Kousen</dc:creator>
<guid>http://kousenit.es.wordpress.com/2008/10/13/making-swing-groovy-part-iii-edt/</guid>
<description><![CDATA[In this entry in my &#8220;Making Swing Groovy&#8221; series, I want to talk about threading issues.]]></description>
<content:encoded><![CDATA[<p>In this entry in my "Making Swing Groovy" series, I want to talk about threading issues.  Specifically, how to work with the Event Dispatch Thread.  As a step along the way, let me first respond to a comment made about <a href="http://kousenit.wordpress.com/2008/09/29/making-swing-groovy-part-i/">my first post in this series</a>.</p>
<p>Kirill Grouchnikov collects <a href="http://www.pushing-pixels.org/?p=549">interesting Swing-related links every week</a>.  He was kind enough to link to my first post, and rightly pointed out that in my Java example, I'd make some errors.  As he said,</p>
<p>"... the Swing example is not the best one, violating the EDT rules, working with the content pane and not centering the frame in the monitor, and the author admits some of these points."</p>
<p>Let me say up front that I'm grateful for his comments.  That's how I learn.  Part of the reason I post here (other than just the joy of sharing what I've learned) is to find out what I've been doing wrong, or, if I'm okay, what I can do better.  One of the principles I live by is, "I'm often wrong, but I don't stay wrong."  So keep those cards and letters coming. :)</p>
<p>Here's the code that Kirill addressed:</p>
<p>[sourcecode language="java"]<br />
import java.awt.Container;<br />
import java.awt.GridLayout;<br />
import java.awt.event.ActionEvent;<br />
import java.awt.event.ActionListener;</p>
<p>import javax.swing.JFrame;<br />
import javax.swing.JLabel;<br />
import javax.swing.JTextField;<br />
import javax.swing.WindowConstants;</p>
<p>public class EchoGUI extends JFrame {<br />
	private JTextField input = new JTextField(20);<br />
	private JLabel prompt = new JLabel("Input text: ");<br />
	private JLabel echo = new JLabel("Echo: ");<br />
	private JLabel output = new JLabel();</p>
<p>	private Container cp = this.getContentPane();</p>
<p>	public EchoGUI() {<br />
		super("Echo GUI");<br />
		cp.setLayout(new GridLayout(0,2));  // 2 cols, as many rows as necessary</p>
<p>		cp.add(prompt);<br />
		cp.add(input);<br />
		cp.add(echo);<br />
		cp.add(output);</p>
<p>		input.addActionListener(new ActionListener() {<br />
			@Override<br />
			public void actionPerformed(ActionEvent e) {<br />
				output.setText(input.getText());<br />
			}<br />
		});</p>
<p>		this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);<br />
		setSize(300,100);<br />
		setVisible(true);<br />
	}</p>
<p>	public static void main(String[] args) {<br />
		new EchoGUI();<br />
	}<br />
}<br />
[/sourcecode]</p>
<p>First, Kirill was right about my working with the content pane rather than adding my components directly to the <code>JFrame</code> instance.  I remember way back in the Java 1.0 days (holy AWT, Batman), you added components directly to the instance of <code>java.awt.Frame</code>.  Then, when Swing came along, you weren't supposed to do that any more.  Instead, you added to the content pane in front of the <code>JFrame</code>.  That held true for Java 1.2, 1.3, and 1.4.  Finally, in Java 1.5, you could go directly to the <code>JFrame</code> again, because now adding to the frame redirects to adding to the content pane.  I need to retrain myself to do that.</p>
<p>Here is a link to <a href="http://weblogs.java.net/blog/hansmuller/archive/2005/11/jframeadd_conte.html">a good post that explains why everything changed and then changed back</a>.</p>
<p>Another of Kirill's comments was that I didn't center the frame on the monitor.  I used to do that via code like<br />
[sourcecode language="java"]<br />
Toolkit tk = Toolkit.getDefaultToolkit();<br />
Dimension screenSize = tk.getScreenSize();<br />
[/sourcecode]<br />
From that I can get the width and height of the screen, and then using the width and height of the frame I can center everything.  I can do that, but here it seems a bit like overkill.</p>
<p>Finally, we come to the real issue, which is also the subject of this post.  As he said, I violated the EDT rules, and that's bad.</p>
<p>Arguably Rule #1 of Swing GUI's is "<strong>Only update GUI Elements in the Event Dispatch Thread (EDT)</strong>."  From what I gather from frequent posts about that issue across the web, this is an error as common to Swing developers as forgetting to close database connections is when writing JDBC code.  And again, this is one of those situations in Swing where the rules have changed multiple times, although maybe it's more accurate to say that the rule hasn't changed, but the way to implement it has.</p>
<p>First, some quick background.  Every Swing program involves multiple threads.  First, there are the initializing threads, which start up the GUI.  In a Java application, that's the <code>main</code> method.  Then there is the Event Dispatch Thread, which maintains an Event queue that handles all the GUI updates, and finally there are any background threads that are used to manage long-running processes.  If you make sure that non-GUI processes are off the EDT, then the GUI will remain responsive while the application is doing other work.</p>
<p>As of JDK 1.6, the standard library now has the class <code>javax.swing.SwingUtilities</code>, which contains the methods <code>invokeLater</code> and <code>invokeAndWait</code>.  According to <a href="http://java.sun.com/docs/books/tutorial/uiswing/concurrency/">the concurrency lesson in the Swing tutorial</a>, the proper way to create a GUI is<br />
[sourcecode language="java"]<br />
public static void main(String[] args) {<br />
    SwingUtilities.invokeLater(new Runnable() {<br />
        @Override<br />
        void run() {<br />
            \\  ... instantiate the GUI ...<br />
        }<br />
    );<br />
}<br />
[/sourcecode]<br />
The <code>invokeLater</code> method creates the <code>Runnable</code> object and gives it to the EDT to add to the event queue.  The alternative method <code>invokeAndWait</code> does the same thing, but it blocks until the task is completed.</p>
<p>What does Groovy bring to this picture?  As usual, Groovy simplifies matters.  Groovy adds three helpful methods to <code>groovy.swing.SwingBuilder</code>: <code>edt</code>, <code>doLater</code>, and <code>doOutside</code>.</p>
<p>What do they do?  One of the best things about using an open source API is that, well, you have access to the source code.  For the <code>edt</code> method, the implementation looks like (paraphrased):<br />
[sourcecode language="java"]<br />
public SwingBuilder edt(Closure c) {<br />
    if (SwingUtilities.isEventDispatchThread()) {<br />
        c.call(this)<br />
    } else {<br />
        // ...<br />
       SwingUtilities.invokeAndWait(c)<br />
       // ...<br />
    }<br />
}<br />
[/sourcecode]<br />
In other words, if we're in the EDT already, invoke the closure.  If not, call <code>invokeAndWait</code> to get to the EDT.</p>
<p>Likewise, for <code>doLater</code>:<br />
[sourcecode language="java"]<br />
public SwingBuilder doLater(Closure c) {<br />
    // ...<br />
   SwingUtilities.invokeLater(c)<br />
   // ...<br />
}<br />
[/sourcecode]<br />
and for <code>doOutside</code>:<br />
[sourcecode language="java"]<br />
public SwingBuilder doOutside(Closure c) {<br />
    // ...<br />
   Thread.start(c)<br />
    // ...<br />
}<br />
[/sourcecode]</p>
<p>So what's the bottom line?</p>
<ul>
<li><strong>edt</strong>: use the EDT through <code>invokeAndWait</code></li>
<li><strong>doLater</strong>: use the EDT through <code>invokeLater</code></li>
<li><strong>doOutside</strong>: create a worker thread and start it (off the EDT)</li>
</ul>
<p>Incidentally, SwingBuilder also has a <code>build</code> method specifically designed to construct the GUI.  How does it handle threading?<br />
[sourcecode language="java"]<br />
public static SwingBuilder build(Closure c) {<br />
    SwingBuilder builder = new SwingBuilder()<br />
    return builder.edt(c)<br />
}<br />
[/sourcecode]<br />
That's the whole method -- create the buillder and then build the GUI on the EDT, synchronously.  That's why all of our previous examples of <code>SwingBuilder</code>, which only used the <code>build</code> method on the builder, ran correctly.  They're doing the initial construction on the EDT, as they should.</p>
<p>Ultimately, practical examples of Groovy Swing code uses actions that take advantage of these methods, as in<br />
[sourcecode language="java"]<br />
swing.actions() {<br />
    action(name:'myMethod') {</p>
<p>        doOutside {<br />
            model.prop = textField.text<br />
            // ... other model property updates ...<br />
            def ok = someLongRunningService(model)</p>
<p>            doLater {<br />
                model.ok = ok<br />
}  }   }  }<br />
[/sourcecode]</p>
<p>And there you have it.  Grab the data and update the model outside the EDT, then run the long running application.  When it's finished, update the GUI in the EDT.  (Note that here we're updating the model in the EDT because the model properties are bound to the GUI elements, so changes in model properties will result in a GUI update.  See <a href="http://kousenit.wordpress.com/2008/10/03/making-swing-groovy-part-ii-binding/">my previous post in this series</a> for details.)</p>
<p>From here it's only a short step to <a href="http://griffon.codehaus.org">Griffon</a>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Grails resources]]></title>
<link>http://ghads.wordpress.com/?p=49</link>
<pubDate>Mon, 13 Oct 2008 08:32:26 +0000</pubDate>
<dc:creator>ghads</dc:creator>
<guid>http://ghads.es.wordpress.com/2008/10/13/grails-resources/</guid>
<description><![CDATA[Hello again  
This time I found a nice blog entry about Grails and an overview of must-reads and res]]></description>
<content:encoded><![CDATA[<p>Hello again :-)</p>
<p>This time I found a nice blog entry about Grails and an overview of must-reads and resources for developing your first grails website: <a title="http://blog.saddey.net/2008/10/11/grails-links-from-my-first-week-with-grails/" href="http://blog.saddey.net/2008/10/11/grails-links-from-my-first-week-with-grails/" target="_blank">http://blog.saddey.net/2008/10/11/grails-links-from-my-first-week-with-grails/</a></p>
<p>Looks worthy for a closer investigation of grails. Well, I wanted to develop my own grails site as a little private side project since summer, but I still have no time. I first need to get my infrastructure right, as my 2 1/2 year old notebook is getting buggy and slow and needs a replacemt and that needs money, which I don't have (not even banks have money nower days...). Maybe next three month I'll get new hardware and energy for my side projects. At least I hope so.</p>
<p>Greetz, GHad</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Groovy and java]]></title>
<link>http://alexlexecorp.wordpress.com/?p=571</link>
<pubDate>Sun, 12 Oct 2008 18:29:37 +0000</pubDate>
<dc:creator>Alex</dc:creator>
<guid>http://lexecorp.com/2008/10/12/groovy-and-java/</guid>
<description><![CDATA[Dynamic scripting languages are terse. This makes for quick solutions and more maintainable code. In]]></description>
<content:encoded><![CDATA[<p>Dynamic scripting languages are terse. This makes for quick solutions and more maintainable code. In the past I have embedded scripting languages like TCL/TK in C/C++ based applications. Consultants can then add functionality to a product at a client site with much less effort than is required by the R&#38;D staff. BUT the two languages sit apart and to provide C++ functions to TCL, well add it to the R&#38;D guys job list.</p>
<p>Groovy makes the sometimes verbose Java more palatable. But more importantly, it is very easy to mix the two and in a far more advanced way than one could have ever done with TCL and C/C++.</p>
<p>Sometimes a simple example is all that one needs to get the idea. Here is that example.</p>
<p>Edit a simple java base class, something obvious like</p>
<p><code>$ cat JBase.java</code></p>
<pre>public class JBase {
  public void doIt() {
    System.out.println("Java: JBase");
  }

  public static void main(String [] args) {
    JBase jbase = new JBase();
    jbase.doIt();
  }
}</pre>
<p>Create your bytecode (JBase.class)</p>
<p><code>$ javac JBase.java</code></p>
<p>Edit a Groovy script to use the above</p>
<p><code>$ cat G_uses_J.groovy</code></p>
<pre>JBase jbase = new JBase()
jbase.doIt()</pre>
<p>And create your Groovy bytecode (G_uses_J.class)</p>
<p><code>$ groovyc G_uses_J.groovy</code></p>
<p>And finally run it</p>
<pre>$ groovy G_uses_J
Java: JBase</pre>
<p>Hey presto. I think you will get the idea, the two languages can be mixed up much more than a simple example will show, but let me spell it out though, "Mixing scripting with Java is dead easy, and if you use Java then you can already use Groovy!"</p>
<p>Give it a go, make your product more customizable at client sites!</p>
<p>ADDENDUM: Thank you Bob for this very important point. Call our groovy code directly from Java like so (note the groovy library). It is indeed all JVM bytecode compatible.</p>
<pre>    java -classpath .;c:/Dev/groovy-1.5.7/embeddable/groovy-all-1.5.7.jar G_uses_J
Java: JBase</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Smacking up a Groovy demo in less than 10 seconds]]></title>
<link>http://stigl.wordpress.com/?p=88</link>
<pubDate>Sat, 11 Oct 2008 11:39:43 +0000</pubDate>
<dc:creator>stigl</dc:creator>
<guid>http://stigl.es.wordpress.com/2008/10/11/smacking-up-a-groovy-demo-in-less-than-10-seconds/</guid>
<description><![CDATA[Write mvn org.codehaus.groovy.maven:gmaven-plugin:console , and you will get a console where you can]]></description>
<content:encoded><![CDATA[<p>Write <strong>mvn org.codehaus.groovy.maven:gmaven-plugin:console</strong> , and you will get a console where you can execute Java/Groovy code by typing ctrl+enter/+enter.</p>
<p>If I were to learn a new language, or Java from scratch again in the University, This way of packaging would make a HUGE difference!</p>
<p><a href="http://stigl.wordpress.com/files/2008/10/gmaven-console1.png"><img class="alignnone size-full wp-image-90" title="gmaven-console1" src="http://stigl.wordpress.com/files/2008/10/gmaven-console1.png" alt="" width="543" height="291" /></a></p>
<h2>What next?</h2>
<p>The sweet spot for using Groovy is</p>
<ul>
<li>Familiarity to Java developers. Paste in your favorite Java code, and it will compile</li>
<li>Java classes are imported and used as normal</li>
<li><a href="http://groovy.codehaus.org/JN1525-Strings">Strings</a>, <a href="http://groovy.codehaus.org/JN2015-Files">Files</a> and many other standard classes have been extended with often-used functionality</li>
<li>Handling stuff on the file system - copying, deleting aso</li>
<li><a href="http://groovy.codehaus.org/Reading+XML+using+Groovy's+XmlSlurper">Parsing XML</a> in a nice DSL</li>
<li><a href="http://groovy.codehaus.org/Tutorial+6+-+Groovy+SQL">Simple SQL</a>/JDBC</li>
<li>Binding together a Java application</li>
</ul>
<h2>Resources</h2>
<ul>
<li><a href="http://groovy.codehaus.org/Documentation">Groovy online Documentation</a></li>
<li><a href="http://www.amazon.com/Groovy-Action-Dierk-Koenig/dp/1932394842/">Groovy In Action - Teh Bible</a></li>
<li><a href="http://onp.java.no/video/jz08/lab1/day1/S7-Groovy,%20blue%20pill/">Simple introductionary video from JavaZone</a></li>
<li><a href="http://onp.java.no/video/jz08/lab1/day1/S8-Groovy,%20red%20pill/">Advanced usage of Groovy video from JavaZone</a></li>
</ul>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Groovy 1.6 Released]]></title>
<link>http://significantbit.wordpress.com/?p=127</link>
<pubDate>Sat, 11 Oct 2008 08:06:16 +0000</pubDate>
<dc:creator>Virtual Machine</dc:creator>
<guid>http://significantbit.es.wordpress.com/?p=127</guid>
<description><![CDATA[Groovy 1.6 has just been released. These are some of the main new features:
Performance improvements]]></description>
<content:encoded><![CDATA[<p>Groovy 1.6 has just been released. These are some of the main new features:</p>
<h4><strong>Performance improvements</strong></h4>
<p>Compilation and runtime performance were the main focus of this release. The developers claim improvements of up to 5 times, although I could not attest it.</p>
<h4>Multiple Assignments</h4>
<p>This is called <em>tuples</em> in some programming languages. It is actually a pretty useful concept:</p>
<p>[sourcecode language="java"]<br />
def a, b</p>
<p>(a, b) = 1..2</p>
<p>assert a == 1<br />
assert b == 2</p>
<p>// variable swap</p>
<p>(a, b) = (b, a)</p>
<p>assert a == 2<br />
assert b == 1<br />
[/sourcecode]</p>
<p>You can even use it to return multiple values from a method, something I have been missing from Java for a while.</p>
<h4>if Returns</h4>
<p><code>if</code> statements may now be used for implicit returns:</p>
<p>[sourcecode language="java"]<br />
// Groovy 1.5</p>
<p>def max(a, b){</p>
<p>	if (a > b)<br />
		return a</p>
<p>	else<br />
		return b<br />
}</p>
<p>// Groovy 1.6</p>
<p>def max(a, b){</p>
<p>	if (a > b) a else b<br />
}<br />
[/sourcecode]</p>
<h4>Grape</h4>
<p>The Groovy Advanced Packaging Engine automatically downloads dependencies at runtime, allowing programs to be distrubuted wihtout additional JAR files. See <a href="http://groovy.codehaus.org/Grape">http://groovy.codehaus.org/Grape</a> for details.</p>
<h4>AST Transformations</h4>
<p>Think of AST Transformations as compile-time meta-programming. Some sample transformations include @Singleton, @Immutable, @Delegate, @Lazy, and @Newify.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Instalando Groovy e Grails]]></title>
<link>http://bitsignificativo.wordpress.com/?p=10</link>
<pubDate>Thu, 09 Oct 2008 19:54:46 +0000</pubDate>
<dc:creator>Virtual Machine</dc:creator>
<guid>http://bitsignificativo.es.wordpress.com/2008/10/09/instalando-groovy-e-grails/</guid>
<description><![CDATA[Neste post vamos mostrar como instalar Groovy e Grails.
A instalação é bastante simples: baixe, d]]></description>
<content:encoded><![CDATA[<p>Neste post vamos mostrar como instalar <a href="http://groovy.codehaus.org/">Groovy</a> e <a href="http://grails.org/">Grails</a>.</p>
<p>A instalação é bastante simples: baixe, descompacte, configure as variáveis de ambiente, e atualize seu <code>PATH</code>. O único pré-requisito é ter o Java SDK 1.5 ou superior instalado no computador. Certifique-se que a variável de ambiente <code>JAVA_HOME</code> esteja configurada de acordo com sua instalação Java:</p>
<p>[sourcecode language='java']<br />
$ export JAVA_HOME=/Library/Java/Home<br />
[/sourcecode]</p>
<p>Primeiro, baixe as distribuições a partir de <a href="http://groovy.codehaus.org/Download">http://groovy.codehaus.org/Download</a> e <a href="http://grails.org/Download">http://grails.org/Download</a>, descompacte os arquivos:</p>
<p>[sourcecode language='java']<br />
$ unzip groovy-binary-*.zip<br />
$ ln -s groovy-* groovy<br />
$ unzip grails-bin-*.zip<br />
$ ln -s grails-* grails<br />
[/sourcecode]</p>
<p>E configure as variáveis de ambiente <code>GROOVY_HOME</code> e <code>GRAILS_HOME</code>:</p>
<p>[sourcecode language='java']<br />
$ export GROOVY_HOME=[...]/groovy<br />
$ export GRAILS_HOME=[...]/grails<br />
[/sourcecode]</p>
<p>Se for conveniente, atualize <code>PATH</code> e <code>CLASSPATH</code>:</p>
<p>[sourcecode language='java']<br />
$ export PATH=$PATH:$GROOVY_HOME/bin:$GRAILS_HOME/bin<br />
$ export CLASSPATH=$CLASSPATH:$GROOVY_HOME/embeddable/groovy-all-[...].jar<br />
[/sourcecode]</p>
<p>Para testar a instalação, digite <code>groovy -v</code> e <code>grails</code>:</p>
<p>[sourcecode language='java']<br />
$ groovy -v<br />
Groovy Version: 1.5.7 JVM: 1.5.0_16</p>
<p>$ grails<br />
Welcome to Grails 1.0.3 - http://grails.org/<br />
[/sourcecode]</p>
<p>E pronto, é só isso. Tanto o Groovy quanto o Grails incluem suas respectivas dependências. O Grails inclui, para propósitos de desenvolvimento, até mesmo servidores Web (<a href="http://jetty.mortbay.org/">Jetty</a>) e de banco de dados (<a href="http://hsqldb.org/">HSQLDB</a>) além do <a href="http://springframework.org/">Spring</a> e do <a href="http://hibernate.org/">Hibernate</a>. Não é necessário instalar nenhum outro programa, como Tomcat ou MySQL, apenas para começar a trabalhar. Na verdade, a distribuição do Grails inclui os arquivos Groovy necessários. Portanto, não precisamos manter uma instalação dedicada do Groovy se quisermos usar apenas o Grails.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Installing Groovy and Grails]]></title>
<link>http://significantbit.wordpress.com/?p=57</link>
<pubDate>Thu, 09 Oct 2008 19:28:18 +0000</pubDate>
<dc:creator>Virtual Machine</dc:creator>
<guid>http://significantbit.es.wordpress.com/2008/10/09/installing-groovy-and-grails/</guid>
<description><![CDATA[In this post we will quickly describe how to install Groovy and Grails.
The installation is simple a]]></description>
<content:encoded><![CDATA[<p>In this post we will quickly describe how to install <a href="http://groovy.codehaus.org/">Groovy</a> and <a href="http://grails.org/">Grails</a>.</p>
<p>The installation is simple and straightforward: download, unpack, set the environment variables, and update your <code>PATH</code>. The only requirement is to have the Java SDK 1.5 or higher installed on the machine. Make sure the <code>JAVA_HOME</code> environment variable matches the Java installation:</p>
<p>[sourcecode language='java']<br />
$ export JAVA_HOME=/Library/Java/Home<br />
[/sourcecode]</p>
<p>First, download the binary distribution from <a href="http://groovy.codehaus.org/Download">http://groovy.codehaus.org/Download</a> and <a href="http://grails.org/Download">http://grails.org/Download</a>, unpack the files:</p>
<p>[sourcecode language='java']<br />
$ unzip groovy-binary-*.zip<br />
$ ln -s groovy-* groovy<br />
$ unzip grails-bin-*.zip<br />
$ ln -s grails-* grails<br />
[/sourcecode]</p>
<p>And set the <code>GROOVY_HOME</code> and <code>GRAILS_HOME</code> environment variables:</p>
<p>[sourcecode language='java']<br />
$ export GROOVY_HOME=[...]/groovy<br />
$ export GRAILS_HOME=[...]/grails<br />
[/sourcecode]</p>
<p>It might be convenient to update <code>PATH</code> and <code>CLASSPATH</code>:</p>
<p>[sourcecode language='java']<br />
$ export PATH=$PATH:$GROOVY_HOME/bin:$GRAILS_HOME/bin<br />
$ export CLASSPATH=$CLASSPATH:$GROOVY_HOME/embeddable/groovy-all-[...].jar<br />
[/sourcecode]</p>
<p>To test our installation, type <code>groovy -v</code> and <code>grails</code>:</p>
<p>[sourcecode language='java']<br />
$ groovy -v<br />
Groovy Version: 1.5.7 JVM: 1.5.0_16</p>
<p>$ grails<br />
Welcome to Grails 1.0.3 - http://grails.org/<br />
[/sourcecode]</p>
<p>And that's it. Both Groovy and Grails come with all dependencies included. Grails even includes a Web server (<a href="http://jetty.mortbay.org/">Jetty</a>) and a database server (<a href="http://hsqldb.org/">HSQLDB</a>) for development purposes, along with the <a href="http://springframework.org/">Spring</a> and <a href="http://hibernate.org/">Hibernate</a> frameworks. No need to install any third parties, such as Tomcat or Mysql, just to get started working. In fact, the Grails distribution includes the required Groovy files, so we don't have to keep a stand-alone Groovy installation if we only want to work with Grails.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Feelin' Groovy]]></title>
<link>http://daleinnis.wordpress.com/?p=141</link>
<pubDate>Wed, 08 Oct 2008 18:26:31 +0000</pubDate>
<dc:creator>daleinnis</dc:creator>
<guid>http://daleinnis.es.wordpress.com/2008/10/08/feelin-groovy/</guid>
<description><![CDATA[Here I am, just Being, in my little piece of the SecondStock sim, where they&#8217;re doing a recrea]]></description>
<content:encoded><![CDATA[<p>Here I am, just Being, in my little piece of the SecondStock sim, where they're doing a recreation / celebration of the original Woodstock festival. One of the organizers TPd me over and convinced me to rent one of their little stalls. I made some Tshirts and some books, put them out as freebies, and put out a tipjar. Grooviness!</p>
<p><a href="http://www.flickr.com/photos/ceoln/2915544122/" title="Common Goods Snapshot by ceoln, on Flickr"><img src="http://farm4.static.flickr.com/3208/2915544122_14a7933ec7.jpg" width="500" height="298" alt="Common Goods Snapshot" /></a></p>
<p>(Click through to flickr for access to more detailed larger size.) Books (not counting the Hobo bookcase) include Dharma Bums, Be Here Now (and see also the Be Here Now carpet), The Lazy Man's Guide to Enlightenment (my favorite obscure hippie philosophy book), Hippies from A to Z (lols), and (on the ground slightly under a crate) the first annual Swimsuit Edition of High Times. Various T-shirts in the T-shirt vendor, two classic Arcadia Asylum freebie vendors with very cool (if high-prim) hobo things, a lovely colorful mushroom by Sabrinaa Nightfire (who was kind enough to let me give that away too), a couple of meditation balls, and a freebie psychedelic chair. What more could one want? Well, drugs of course, but there are lots of those in the other booths nearby. :) </p>
<p><strong>Note:</strong> I seem to have been in SL quite a bit less lately (there may even have been a day when I didn't get inworld at all!).  Not taking a hiatus or anything, and definitely not a reflection on any of many beloved v good friends there.  Just feeling a sort of early-fall hibernating mood, I think, and also a huge unpaid sleep debt.  :)  I imagine I'll be back to more or less my old ways before long.  So don't worry!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Making Swing Groovy, Part II: Binding]]></title>
<link>http://kousenit.wordpress.com/?p=144</link>
<pubDate>Fri, 03 Oct 2008 18:55:01 +0000</pubDate>
<dc:creator>Ken Kousen</dc:creator>
<guid>http://kousenit.es.wordpress.com/2008/10/03/making-swing-groovy-part-ii-binding/</guid>
<description><![CDATA[In my previous post in this series, I presented a trivial Echo GUI written in Groovy.  By using Swi]]></description>
<content:encoded><![CDATA[<p>In <a href="http://kousenit.wordpress.com/2008/09/29/making-swing-groovy-part-i/">my previous post in this series</a>, I presented a trivial Echo GUI written in Groovy.  By using <code>SwingBuilder</code> and closures, the code for the GUI was dramatically simplified compared to the Java version.  But Groovy can go beyond that.  In this post, I'll talk about the <code>bind</code> method and the <code>@Bindable</code> annotation, which help transform Swing development into the MVC structure of Griffon.</p>
<p>The code for the Echo GUI currently consists of:</p>
<p>[sourcecode language="java"]<br />
import groovy.swing.SwingBuilder<br />
import javax.swing.WindowConstants as WC</p>
<p>SwingBuilder.build() {<br />
    frame(title:'Echo GUI', size:[300,100],<br />
        visible:true, defaultCloseOperation:WC.EXIT_ON_CLOSE) {<br />
        gridLayout(cols: 2, rows: 0)<br />
        label 'Input text: '<br />
        input = textField(columns:10,<br />
            actionPerformed: { output.text = input.text })<br />
        label 'Echo: '<br />
        output = label()<br />
    }<br />
}[/sourcecode]</p>
<p>The closure assigned to the <code>actionPerformed</code> property transfers the input from the text field to the output label.  In order to make that happen, both the field and the label were given names that could be referenced inside the closure.</p>
<p>Groovy 1.5+ includes a method called <code>bind</code>, which works with bound properties in the ancient JavaBeans specification.  For those whose only exposure to JavaBeans is through POJO's on the server side, the original JavaBeans framework was designed to support GUI builders.  It looked and felt much like building GUIs in VB, in that you dragged these "beans" onto a palette, hooked them together, and set the values of their properties.  It was a way of writing Java user interfaces without writing any Java code, at least until you wanted the various widgets to actually do something.</p>
<p>I remember back around 1998, I convinced my boss at the time to purchase Sun's proposed IDE based on beans.  I think it was called Sun Java WorkBench, or something like that.  It cost about $99, and it came with beans that you could drag and drop, and you could add your own jar files full of beans as well.  While it looked pretty cool, you didn't have the source code for any of the beans, which limited their usefulness.</p>
<p>Java on the client side didn't really take off, and the market for the IDE certainly didn't pan out.  I do remember that the JavaBeans specification -- written largely to support the client-side development model -- brought us many aspects of Java that we take for granted now.  My first encounter with serialization came from there, as well as reflection, though they used the extremely awkward name introspection for it.  In addition to implementing <code>java.io.Serializable</code>, JavaBeans according to the spec were also supposed to have default constructors and the now-infamous naming convention for getters and setters for all the properties.  Actually, providing a getter method was sufficient to define a property of a JavaBean.</p>
<p>The spec also referred to various types of properties, like bound and constrained, and JavaBeans were also supposed to implement the <code>PropertyChangeListener</code> interface.</p>
<p>Very few Java programs were actually written using those JavaBeans, and the expected third-party market in JavaBeans libraries never seemed to develop.  I seem to recall that there were a couple of success stories (wasn't IBM's VisualAge for Java supposed to be written using the original JavaBeans spec?), but mostly the whole technology went away.</p>
<p>It wasn't until a few years later that JavaBeans re-emerged, as the way to get Java code out of JavaServer Pages.  Sun's Model 1 architecture consisted entirely of JSPs and JavaBeans, with no explicit servlets anywhere.  Model 2 changed all that by using servlets for controllers, but that came later.  By then, though, people used what we now call POJO's for model classes, and you were still supposed to make your beans serializable, but all that stuff about property change listeners was largely ignored.</p>
<p>Groovy gives us a chance to use JavaBeans as model classes in an especially easy way.  First, here's an illustration of a simple GUI that uses the <code>bind</code> method in Groovy.</p>
<p>[sourcecode language="java"]<br />
import groovy.swing.SwingBuilder<br />
import javax.swing.WindowConstants as WC<br />
import java.awt.BorderLayout as BL</p>
<p>SwingBuilder.build() {<br />
    frame(title:'Binding to Slider', pack:true, visible:true,<br />
        defaultCloseOperation:WC.EXIT_ON_CLOSE) {<br />
        panel(constraints:BL.CENTER) {<br />
          slider(id:'sl')<br />
        }<br />
        panel(constraints:BL.SOUTH) {<br />
          label 'Slider value: '<br />
          label(text:bind(source:sl, sourceProperty:'value'))<br />
        }<br />
    }<br />
}<br />
[/sourcecode]</p>
<p>Here we're taking advantage of the fact that all Swing widgets extend <code>Component</code>, which means they support property change listeners.  In this case, we have a slider with a property called <code>value</code>.  The <code>bind</code> method assigns the <code>text</code> of the label to the <code>value</code> property of the slider.  Dragging the slider immediately updates the label.</p>
<p>This is seriously cool, and means that the Echo GUI shown above can be made even more responsive by replacing the <code>actionListener</code> by binding the output label directly to the input text field.</p>
<p>[sourcecode language="java"]<br />
import groovy.swing.SwingBuilder<br />
import javax.swing.WindowConstants as WC</p>
<p>SwingBuilder.build {<br />
    frame(title: 'Regular Binding (Groovy)', size: [300,100],<br />
        visible:true, defaultCloseOperation: WC.EXIT_ON_CLOSE ) {<br />
        gridLayout(cols: 2, rows: 0)<br />
        label 'Input text: '<br />
        textField(columns:10, id:'tf')<br />
        label 'Echo: '<br />
        label(text:bind(source:tf, sourceProperty:'text'))<br />
    }<br />
}<br />
[/sourcecode]</p>
<p>The result is that now, any characters typed into the text field are immediately transferred into the label.  Deletes work the same way.  The text in the output label is bound to the value of the input text field.</p>
<p>While this is interesting and even useful, a true model-view-controller architecture wouldn't always  bind widgets to other widgets.  Instead, input values would be transfered to a model class, and then the model values would be sent to the output view.  What we need, therefore, is a way to bind the view elements to an actual Java bean.</p>
<p>If this was Java, we would introduce a class that supported property change capabilities.  Consider such a model class in Java:<br />
[sourcecode language="java"]<br />
import java.beans.PropertyChangeListener;<br />
import java.beans.PropertyChangeSupport;</p>
<p>public class Message {<br />
    private String text;<br />
    private PropertyChangeSupport pcs = new PropertyChangeSupport(this);</p>
<p>    public String getText() {<br />
        return text;<br />
    }</p>
<p>    public void setText(String text) {<br />
        pcs.firePropertyChange("text", this.text, this.text = text);<br />
    }</p>
<p>    public void addPropertyChangeListener(PropertyChangeListener listener) {<br />
        pcs.addPropertyChangeListener(listener);<br />
    }</p>
<p>    public void removePropertyChangeListener(PropertyChangeListener listener) {<br />
        pcs.removePropertyChangeListener(listener);<br />
    }<br />
}<br />
[/sourcecode]<br />
The <code>Message</code> class has a single property, called <code>text</code>.  It also relies on the <code>PropertyChangeSupport</code> class to enable it to add and remove property change listeners.  When the <code>text</code> property is changed, the <code>setText</code> method fires a property change event to all the listeners, where the arguments to the <code>firePropertyChange</code> method are the name of the property, its old value, and the new value.</p>
<p>How does Groovy simplify this?  The key is the <code>@Bindable</code> annotation, which is currently only in Groovy 1.6 beta 2.  Fortunately, that version is included in Griffon, though I did go to the trouble to download and rebuild it myself (a post for another time).</p>
<p>Using Groovy 1.6b2, here's the equivalent Groovy bean:<br />
[sourcecode language="java"]<br />
import groovy.beans.Bindable</p>
<p>class Message {<br />
    @Bindable def text<br />
}<br />
[/sourcecode]<br />
Seems almost unfair, doesn't it?  Add an annotation to the field, and you're done.  It's hard to get much simpler than that.</p>
<p>Now all you need is a listener.  In Java land, the GUI would use something like:<br />
[sourcecode language="java"]<br />
//...<br />
    private Message msg = new Message();<br />
//...<br />
    msg.addPropertyChangeListener(new PropertyChangeListener(){<br />
        @Override<br />
        public void propertyChange(PropertyChangeEvent evt) {<br />
            output.setText((String) evt.getNewValue());<br />
        }<br />
    });<br />
//...<br />
[/sourcecode]<br />
again using an anonymous inner class to respond to the change.  By contrast, here is the Groovy version (where in this case the code is sufficiently succinct that I can include the whole thing):<br />
[sourcecode language="java"]<br />
import groovy.swing.SwingBuilder<br />
import javax.swing.WindowConstants as WC</p>
<p>def model = new Message()</p>
<p>SwingBuilder.build() {<br />
    frame(title:'Echo GUI', size:[300,100],<br />
        visible: true, defaultCloseOperation:WC.EXIT_ON_CLOSE) {<br />
        gridLayout(cols: 2, rows: 0)<br />
        label 'Input text: '<br />
        input = textField(columns:10,<br />
            actionPerformed: { model.text = input.text })<br />
        label 'Echo: '<br />
        label(text: bind { model.text })<br />
    }<br />
}<br />
[/sourcecode]<br />
Once again, this won't work unless you're using Groovy 1.6b2 or above.  The <code>bind</code> method has been modified to take a closure as its last argument, and the closure in question refers to the <code>text</code> property of the model, rather than to another widget.  Note that now I've gone back to implementing <code>actionListener</code>, because I have to get the text value from the view into the model, so it's not quite as clean as before.  That could be changed, but at the moment it seems reasonable to do it that way.</p>
<p>Of course, if we have a model and we have a view, what we need next is a controller.  Griffon shows how to do that, but I'll leave it for another post.</p>
<p>The bottom line is that by using Groovy's <code>bind</code> method and <code>@Bindable</code> annotation, constructing a GUI based on a realistic MVC architecture is now viable, and even easy.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Using Gant to build Java Projects]]></title>
<link>http://rrees.wordpress.com/?p=258</link>
<pubDate>Tue, 30 Sep 2008 23:22:48 +0000</pubDate>
<dc:creator>rrees</dc:creator>
<guid>http://rrees.es.wordpress.com/2008/09/30/using-gant-to-build-java-projects/</guid>
<description><![CDATA[I know I said I would be taking a step by step introduction to Gant in my last post on the subject b]]></description>
<content:encoded><![CDATA[<p>I know I said I would be taking a step by step introduction to Gant in my last post on the subject but sometimes the devil drives and you need things done in a less systematic way.</p>
<p>Recently I have been building Java and Scala projects with Gant. I think it has been a successful exercise so I am just going to jump on and show you some example buildfiles. The first one is going to be a Java project. This project is obviously toy code but I think if you <a title="Java Gant Project Zipfile" href="http://0sstj6j9gwvcsg3tpsr2.code.public.s3.amazonaws.com/java-gant-example.zip">just download the sample project</a> and start filling in your own code (it's an Eclipse project, Intellij and NetBeans should both import it successfully) you will be happy with how little you have to change the build file.</p>
<p>First <a title="Project's Gant File at Pastebin" href="http://groovy.pastebin.com/m326dc603">have a look at the Gant file itself</a> and then I am going to talk about the things that I think make Gant such a powerful and productive tool. The first thing to point out is the line count, this represents a complete build file for a Java SE project in under 100 lines. That includes the Hello World target I've left in as an echo test. Gant might have a slightly weird syntax if you are unfamiliar with Groovy but it isn't verbose.</p>
<p>Targets and dependencies were in the last post so this time the new thing is using AntBuilder. Any method call that starts with Ant is a invocation of an Ant task. These are nothing but thin wrappers around the normal Ant task (and in fact I usually write them using the Ant Task documentation). Things that are attributes in Ant XML become hash properties in the parameter list. Things that would normally be nested elements are calls to the enclosing builder.</p>
<p>One area where Gant wins big is the way you can mix normal variables, Groovy string interpolation and Ant properties. Declaring the directory paths as Groovy variables near the head of the file allows me to create new paths via interpolation and assign the variable to the properties of an Ant task. Ant XML has properties and macro interpolation but this is both clearer and easier.</p>
<p>I am also using the Gant built-in clean task and in the course of using it, Groovy's operator overloading for lists. I'm not a huge fan of operator overloading but if it's clear enough here then it is great to have a DRY list assignment.</p>
<p>I also like the way that the directories are created in the init task. This kind of closure looping over a list again shows some of the power and conciseness that can be achieved by a language rather than a configuration file. If you don't read Groovy then the each method iterates over the list its attached to and each item resulting from the iteration is stored in the whimsical "it" local variable.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[What I'm into right now ]]></title>
<link>http://stigl.wordpress.com/?p=83</link>
<pubDate>Tue, 30 Sep 2008 18:38:52 +0000</pubDate>
<dc:creator>stigl</dc:creator>
<guid>http://stigl.es.wordpress.com/2008/09/30/what-im-into-right-now/</guid>
<description><![CDATA[I thought I&#8217;d post updates on what I&#8217;m interested in, to give a glimpse of what I&#8217;]]></description>
<content:encoded><![CDATA[<p>I thought I'd post updates on what I'm interested in, to give a glimpse of what I'm looking into and have moved away from. Perhaps I'll have enough data to create a graph someday :)</p>
<h2>Up and coming</h2>
<ul>
<li><a href="http://neo4j.org">Neo4J</a> - A graph store - no more ORMappings</li>
<li><a href="http://qi4j.org">Qi4J</a> - A composite development framework, a new way of writing Java applications, a way of life</li>
<li><a href="http://groovy.codehaus.org">Groovy</a> <a href="http://grails.org">GRAILS</a> - Excellent for prototyping Java stuff</li>
<li><a href="www.selenic.com/mercurial">Mercurial</a> - When thinking different, why not Version Control as well?</li>
<li><a href="https://appframework.dev.java.net/">Swing Appframework, </a><a href="http://java.sun.com/developer/technicalArticles/javase/java6u10/">Java6u10</a> - Propably the next big thing in Rich Internet Applications</li>
<li><a href="http://stigl.wordpress.com/graph-visualization-of-a-java-application/">Visualization of graphs</a> - Am looking for a nice, easy API for creating several hierarchical trees that I can drag and manipulate</li>
<li><a href="aws.amazon.com/ec2/">Amazon EC2</a> - Java enabled servers on demand!</li>
<li><a href="http://twitter.com/stig_lau">Twitter</a>, <a href="http://stigl.wordpress.com/">Blog</a>, <a href="irc://efnet/java.no">IRC</a> -New (and revisited) ways of communicating intra-project/company</li>
<li><a href="http://java.no">javaBin</a>, <a href="http://javazone.no">JavaZone</a> - Working with the JavaZone conference for a year was damn fun!<br />
<!--more--></li>
</ul>
<h2>Same old</h2>
<p><a href="https://wiki.bouvet.no">Knowledge Sharing, Wiki</a>, Ideas, Architecture, RFID, Sun Spot, Music, Topic Maps, Maven, Linux, OS X, Continous Integration, <a href="http://code.google.com/p/mockito">Mockito</a>, Testng, REST</p>
<h2>Moving away from</h2>
<p>Hibernate, Spring, Web, Integration, Grid Frameworks, Web Services, Windows</p>
<h2>Current projects</h2>
<ul>
<li>Music DJ program</li>
<li><a href="http://stigl.wordpress.com/mavenized-neo4j-example/">Neo4JDemo</a></li>
<li>AnarQi4JDemo - Qi4J</li>
<li>JavaZone RFID applications <img class="alignright" src="http://www4.java.no/web/image.do?orig_id=1095&#38;w=300" alt="JavaZone RFID Heltepils Duke" width="300" height="225" /></li>
</ul>
<h2>Closed projects</h2>
<ul>
<li>Web applications on demand - Gigaspaces , web apps</li>
<li>Kvittr - Grails, posting sms and emailing based on an RSS Feed</li>
<li><a href="http://code.google.com/p/ultimate-roundtrip/">Ultimate Roundtrip</a> - A scaffold for improving development roundtrip for web applications with Maven, embedded Jetty and JWebunit webtests</li>
<li><a href="http://code.google.com/p/webugger/">Webugger</a> - Embedding a Groovy console efor debugging web and applications with high roundtrip</li>
</ul>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Magic Build Tool Needed!!!]]></title>
<link>http://innovationstartups.wordpress.com/?p=224</link>
<pubDate>Tue, 30 Sep 2008 13:55:58 +0000</pubDate>
<dc:creator>innovationstartups</dc:creator>
<guid>http://innovationstartups.es.wordpress.com/2008/09/30/magic-build-tool-needed/</guid>
<description><![CDATA[Greetings my fellow Innovators!
Ok, lets start with WebSynergy, the very cool thing out there by the]]></description>
<content:encoded><![CDATA[<p>Greetings my fellow Innovators!</p>
<p>Ok, lets start with WebSynergy, the very cool thing out there by the colloberation of Sun, Liferay!</p>
<p>Now, our dream development package includes liferay portal + Glassfish server with lots of capabilities i.e. SAW, openESB + Netbeans IDE (I still prefer Eclipse!)+ PortalPack + Groovy DSL/Grails support + Spring + hibernate + MySQL</p>
<p>Ok, if you want to use all these into your company's project, wouldn't it be smart to think of a GEnIUS Build tool to automate getting these sources into one updated package for you to use in development or for production!!</p>
<p>I think that would be incrediably cool to have such tool inhouse while you are developing, I think this calls for a new jcp proposal!</p>
<p>what do you think?</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[load testing with SOAP request having variable parameter(s)]]></title>
<link>http://groovyinsoapui.wordpress.com/?p=101</link>
<pubDate>Tue, 30 Sep 2008 05:15:59 +0000</pubDate>
<dc:creator>devakara</dc:creator>
<guid>http://groovyinsoapui.es.wordpress.com/2008/09/30/load-testing-with-soap-request-having-variable-parameters/</guid>
<description><![CDATA[ 

At times there could be requirement of Load Testing a Web Service following different strategies]]></description>
<content:encoded><![CDATA[<p> </p>
<div>
<p>At times there could be requirement of Load Testing a Web Service following different strategies based on the requirement.</p>
<p>But say if there are fields in the SOAP request which are supposed to be unique for every request that hits the service while load testing...really this could be tough to deal with.</p>
<p>With the new feature called in line scripting of SOAP UI 2.5, this could achieved with ease. </p>
<p>For example, lets say we have a web service deployed on a server. And the service writes report files to the server's file system, with the name having some unique value derived from the SOAP request.</p>
<p> </p>
[caption id="attachment_108" align="aligncenter" width="480" caption="Sample GenReportXml for the above service"]<a href="http://groovyinsoapui.files.wordpress.com/2008/10/genreportrequest.jpg"><img class="size-full wp-image-108 " title="GenReportRequest" src="http://groovyinsoapui.wordpress.com/files/2008/10/genreportrequest.jpg" alt="Sample GenReportXml for the above service" width="480" height="216" /></a>[/caption]
<p> </p>
<p>We have a node called <strong>RefNum</strong> having value <strong>123456</strong> in the above request, using which the service writes a report to the file system with name say <strong>Report_123456.txt</strong>. Every time a request with some RefNum triggers the service to generate a report file, one hindrance would be the RefNum of every request that hits the servicve should be unique, to have a valid file in the local system.(weird web service right!.. i understand...just take it as an example).</p>
<p>Issue now would be to load test such service, which demands some unique value in the SOAP request evrey time it hits it.  In SOAP UI 2.5 we have a very simple solution for such weirdly complicated services, called <strong>in-line scripting</strong>!<br />
 </p>
[caption id="attachment_109" align="aligncenter" width="480" caption="SOAP request with in line groovy script"]<a href="http://groovyinsoapui.files.wordpress.com/2008/10/genreportrequest1.jpg"><img class="size-full wp-image-109" title="GenReportRequest" src="http://groovyinsoapui.wordpress.com/files/2008/10/genreportrequest1.jpg" alt="SOAP request with in line groovy script" width="480" height="208" /></a>[/caption]
<p> </p>
<p>In the above request, under RefNum node I included a Groovy Step to fetch the current time in milliseconds. The notation <strong>${=...}</strong> is the next level of Property Expansion technique. The <strong>'='</strong> shall evaluate the script and provide the result as that nodes' value.</p>
<p>This serves the purpose of Load Testing the service, providing unique RefNums for every request, no matter what strategy we follow to in testing, without doing any work around at the application level...(which sounds great!).</p>
<p>The above example seems to be explicitly specific, but I hope it would be usefull. There are still lot of ways we can explore the cool in line Groovy scripting feature , which the SOAP UI's new version has got along.</p>
<p> </p>
<h6><em><span title="mailto:d.devakara@yahoo.co.in"><span style="color:#0000ff;">(Please feel free to get back if u hav any trouble...as i'm just a mail away..leave a comment otherwise)</span></span></em></h6>
<p> </p></div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Making Swing Groovy, Part I]]></title>
<link>http://kousenit.wordpress.com/?p=142</link>
<pubDate>Mon, 29 Sep 2008 04:11:16 +0000</pubDate>
<dc:creator>Ken Kousen</dc:creator>
<guid>http://kousenit.es.wordpress.com/2008/09/29/making-swing-groovy-part-i/</guid>
<description><![CDATA[I&#8217;ve been spending a lot of time lately trying to understand how much Groovy improves Swing us]]></description>
<content:encoded><![CDATA[<p>I've been spending a lot of time lately trying to understand how much Groovy improves Swing user interfaces.  Like so many Java developers, I rarely write client-side programs.  Almost all of my time and effort with Java over at least the last five years has been on the server side, mostly with frameworks like <a href="http://struts.apache.org">Struts</a>, and then open source projects like <a href="http://springframework.org">Spring</a> and <a href="http://hibernate.org">Hibernate</a>.  During all that time, the client-side interface was restricted to what HTML and CSS can handle.</p>
<p>Of course, the growth of Ajax changed a lot of that.  I like several of the major Ajax libraries, like <a href="http://prototypejs.org">prototype</a>, <a href="http://script.aculo.us">scriptaculous</a>, <a href="http://jquery.org">jQuery</a>, <a href="http://developer.yahoo.com/yui/">YUI</a>, and so on.  One of the interesting trends I've been watching in the industry is whether browser-based GUIs in the future will be written in a Java component library that renders in HTML (like <a href="http://java.sun.com/javaee/javaserverfaces/">JSF</a>), or written in Java libraries that translate to Ajax/JavaScript (like <a href="http://code.google.com/webtoolkit/">GWT</a>), or are written using JavaScript components directly (like in YUI or <a href="http://dojotoolkit.org/">dojo</a>).</p>
<p>Still, I used to write user interfaces in Swing.  Several years ago I wrote a Jeopardy-like game that I still use in training classes, where the game board itself is a Swing UI and the clients all have "buzzers" that connect to the game board via RMI.  One of my most interesting, and certainly most fragile, projects was about ten years ago when I had to put a Swing GUI on top of a Fortran program (shudder).  In case you're wondering, you can't get there from here.  You have to go Java to C via JNI, and then C to Fortran (even though they handle arrays differently).  It's basically like putting an notch in a beam and telling it to break <em>right here</em>.</p>
<p>But those are stories for another day.  Suffice it to say that I feel quite comfortable writing Swing GUIs in raw code (as opposed to graphical drag-and-drop interfaces), complete with inner classes to implement <code>ActionListener</code>s or the like for each button, and so on.  I still struggle a bit with the intricacies of <code>GridBagLayout</code>, but I can get pretty far with lots of <code>JPanel</code>s and combinations of <code>BorderLayout</code> and <code>FlowLayout</code>.</p>
<p>So when it came time to see what Groovy brought to the table, I thought I was quite prepared.  Imagine my surprise to find that, believe it or not, in the last several years the field actually moved on, despite the fact that I almost never get requests for training classes in Swing or related technologies.  A lot of people (<a href="http://www.jroller.com/aalmiray/">Andres Almiray</a>, <a href="http://shemnon.com/speling/">Danno Ferrin</a>, <a href="http://blogs.sun.com/geertjan/">Geertjan</a>, and many more) have spent considerable time and effort applying Groovy to user interfaces and making all kinds of progress.</p>
<p>The culmination of all of this effort is the new, seriously cool, <a href="http://groovy.codehaus.org/Griffon">Griffon</a> framework.  Griffon promises to bring Grails-like productivity improvements to client-side Java applications.  The more I learn about it, the more impressed I am.  It's been a bit disheartening, however, to find out how much I still have to learn before I really understand it.</p>
<p>No matter.  I like to say that I'm often wrong, but I rarely stay wrong.  My next few posts here will be dedicated to principles that I've been learning about user interfaces in Groovy.  Hopefully, in addition to providing a nice record for me of what I'm learning, maybe this will help someone else avoid my mistakes.</p>
<p>In this first post, let's get the really well-known stuff out of the way.  That's the wonderful elegance of Groovy's <code>groovy.swing.SwingBuilder</code>.  <code>SwingBuilder</code> is a great Groovy class, well-described in <a href="http://www.manning.com/koenig/">GinA</a>, that let's you create Swing interfaces almost declaratively.</p>
<p>Here's a trivial Swing application in Java.  All it does is take text typed in a text field and echoes it in the text of a label.  It's about a simple as Swing applications come.</p>
<p>[sourcecode language="java"]<br />
import java.awt.Container;<br />
import java.awt.GridLayout;<br />
import java.awt.event.ActionEvent;<br />
import java.awt.event.ActionListener;</p>
<p>import javax.swing.JFrame;<br />
import javax.swing.JLabel;<br />
import javax.swing.JTextField;<br />
import javax.swing.WindowConstants;</p>
<p>public class EchoGUI extends JFrame {<br />
	private JTextField input = new JTextField(20);<br />
	private JLabel prompt = new JLabel("Input text: ");<br />
	private JLabel echo = new JLabel("Echo: ");<br />
	private JLabel output = new JLabel();</p>
<p>	private Container cp = this.getContentPane();</p>
<p>	public EchoGUI() {<br />
		super("Echo GUI");<br />
		cp.setLayout(new GridLayout(0,2));  // 2 cols, as many rows as necessary</p>
<p>		cp.add(prompt);<br />
		cp.add(input);<br />
		cp.add(echo);<br />
		cp.add(output);</p>
<p>		input.addActionListener(new ActionListener() {<br />
			@Override<br />
			public void actionPerformed(ActionEvent e) {<br />
				output.setText(input.getText());<br />
			}<br />
		});</p>
<p>		this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);<br />
		setSize(300,100);<br />
		setVisible(true);<br />
	}</p>
<p>	public static void main(String[] args) {<br />
		new EchoGUI();<br />
	}<br />
}<br />
[/sourcecode]</p>
<p>First of all, this shows me to be an "old school" Swing developer, because I made my application extend <code>JFrame</code> rather than contain a <code>JFrame</code> instance.  The trend these days is always to favor composition over inheritance, partly to reduce the coupling and partly to make testing easier (I'll have more to say about testing Swing UIs in a future post).  Still, this is the way I learned to do it, and I still fall into old habits, especially for trivial examples.</p>
<p>Second, I'm also arguably violating best practices because my main method instantiates the GUI directly, rather than calling <code>SwingWorker.invokeLater</code> to make sure all user interface updates are done in the Event Dispatch Thread (EDT).  You can generally get away with this here, though, because until the GUI is actually rendered it isn't much of a problem.  Understanding the details of running on the EDT or not, however, is a big issue for later, too.</p>
<p>Also, I'm still in the habit of adding components to the content pane.  I remember vividly when I had to rewrite all my existing Swing apps to add to content pane instead of directly to the frame itself, and I still do that, even though I don't think it's strictly necessary any more.</p>
<p>Finally, I did something here I generally don't do, which is to use an anonymous inner class to handle the action listener for the button.  Normally I create an actual (named) inner class for each component that generates events, and add an instance of each to the relevant component.  Here, for example, I would normally write an inner class called something like <code>EchoListener</code>, and then add an instance of it to the button.  Still, with only one button and an almost trivial inner class, it seemed easier to add it directly, even though arguably this is the ugliest syntax in all of Java, with the possible exception of generics.</p>
<p>Groovy's <code>SwingBuilder</code> cuts this example down to practically nothing.<br />
[sourcecode language="java"]<br />
import groovy.swing.SwingBuilder<br />
import javax.swing.WindowConstants as WC</p>
<p>SwingBuilder.build() {<br />
	frame(title:'Echo GUI', size:[300,100],<br />
		visible:true, defaultCloseOperation:WC.EXIT_ON_CLOSE) {<br />
		gridLayout(rows: 0, cols: 2)<br />
		label 'Input text: '<br />
		input = textField(columns:10,<br />
			actionPerformed: { output.text = input.text })<br />
		label 'Echo: '<br />
		output = label()<br />
	}<br />
}<br />
[/sourcecode]<br />
The <code>SwingBuilder</code> means that I can just write words like <code>frame</code>, <code>label</code>, and <code>textField</code>, and, through the magic of metaprogramming, they are interpreted by the builder as Swing components.  The other great part is that Groovy doesn't force you to create an inner class just to hold a method.  Closures are perfectly valid objects in their own right, so I can just assign one to the <code>actionPerformed</code> property of the text field, and I'm all set.</p>
<p>That's an amazing savings, and it's just the beginning.  The combination of builder methods and closures cuts the amount of code required in a typical Swing GUI by a huge amount.</p>
<p>(I don't know exactly how much, but I'm going to say 80%, because, as you may have heard, 80% of all statistics are made up on the spot.)</p>
<p>For more details, see GinA (<a href="http://www.manning.com/koenig/">Groovy in Action</a> for the uninitiated, and if you are uninitiated and find Groovy cool, get thee hence to a bookstore and buy thee a copy) and <a href="http://groovy.codehaus.org/Swing+Builder">the wiki pages at groovy.codehaus.org</a>.</p>
<p>Still, this much I knew when I started my recent adventure.  I had no idea about Groovy's cool <code>bind</code> method, which dramatically simplifies the use of <code>PropertyChangeListener</code>s and is a great step along the way to a pure MVC architecture.  Then there's the <code>@Bindable</code> annotation that's part of Groovy 1.6 beta 2, which makes it even easier.  Then there's the elegant way that Griffon lets you handle scheduling tasks inside or outside the EDT.  I also realized that Swing hasn't been idle, too, with the creation of the whole <a href="https://swingx.dev.java.net/">SwingX project</a> and its associated set of components.</p>
<p>It's been a wild ride for me recently, and I don't feel I'm anywhere near finished.  My feeling, though, is that Griffon is eventually going to be a very big deal.  I know it's making a big difference in how I think about Swing, and I'm looking forward to playing with it more and more.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[groovy cow]]></title>
<link>http://cownesstv.wordpress.com/?p=147</link>
<pubDate>Wed, 24 Sep 2008 21:39:32 +0000</pubDate>
<dc:creator>CowNeSsTv</dc:creator>
<guid>http://cownesstv.es.wordpress.com/2008/09/24/groovy-cow/</guid>
<description><![CDATA[groovy cow
]]></description>
<content:encoded><![CDATA[[caption id="" align="alignleft" width="424" caption="groovy cow"]<a href="http://www.wernermaresta.com/immagini_blog/vaca_granadina.jpg"><img title="groovy cow" src="http://www.wernermaresta.com/immagini_blog/vaca_granadina.jpg" alt="groovy cow" width="424" height="337" /></a>[/caption]
]]></content:encoded>
</item>
<item>
<title><![CDATA[What programming languages make my day a little brighter?]]></title>
<link>http://alexlexecorp.wordpress.com/?p=442</link>
<pubDate>Tue, 23 Sep 2008 18:51:27 +0000</pubDate>
<dc:creator>Alex</dc:creator>
<guid>http://lexecorp.com/2008/09/24/what-programming-languages-make-my-day-a-little-brighter/</guid>
<description><![CDATA[It just takes a little hardware
I have previously had my say about IDE&#8217;s. They make one&#8217;]]></description>
<content:encoded><![CDATA[[caption id="attachment_444" align="alignleft" width="225" caption="It just takes a little hardware"]<a href="http://alexlexecorp.files.wordpress.com/2008/09/charlesbabbage.jpg"><img class="size-full wp-image-444" title="charlesbabbage" src="http://alexlexecorp.wordpress.com/files/2008/09/charlesbabbage.jpg" alt="" width="225" height="267" /></a>[/caption]
<p>I have previously had my say about IDE's. They make one's day better by facilitating the development process. They wrap up the tools that individually require considerable skill, turning the whole into a fast and effective point and click experience.</p>
<p>Over the years I have experimented with a range of tools, some now extinct, some withstanding the test of time. I'd like to explore those that make my work effective and get me results.</p>
<p>When it comes to low level work, or just getting something done with no restrictions, I still find that the <a href="http://en.wikipedia.org/wiki/C_(programming_language)">C programming language</a> is my tool of choice. It does indeed have flaws. But there is (I believe) more Open Source source code out there written in C than any other language. Most importantly my operating systems, my compilers and my Java runtimes are all written in C. Enough said.</p>
<p>When it comes to generic programming work I am torn between two basic choices.</p>
<ol>
<li><a href="http://en.wikipedia.org/wiki/Java_(programming_language)">The Java programming language</a>, its libraries and platforms (not to mention its developer community) are everywhere. I use Java because when it is appropriate, it is so much better than C, and I can achieve great things with less effort and more certainty.</li>
<li>Now I said I was torn between two basic choices. The second is the <a href="http://en.wikipedia.org/wiki/Dynamic_programming_language">Dynamic scripting language</a>. I have a few that I like and will use for different reasons. I will use them in place of C and Java if the choice is appropriate. It doesn't matter which ones you choose as long as you choose them for their speed of development so garnered by their more terse expressive qualities. I consider Perl, Python and Groovy to be my candidates.</li>
</ol>
[caption id="attachment_445" align="alignright" width="200" caption="and the right programmer"]<a href="http://alexlexecorp.files.wordpress.com/2008/09/ada_lovelace_1838.jpg"><img class="size-full wp-image-445" title="ada_lovelace_1838" src="http://alexlexecorp.wordpress.com/files/2008/09/ada_lovelace_1838.jpg" alt="" width="200" height="249" /></a>[/caption]
<p>There are indeed many programming languages out there, but the aforementioned have, to date, either made the most sense or simply given me the most mileage. I hope that you too can find that particular mix which suits your own development end goals. Happy programming :-)</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Domainer: Software/Web Developer(s)]]></title>
<link>http://torontotechjobs.wordpress.com/?p=350</link>
<pubDate>Mon, 22 Sep 2008 04:18:45 +0000</pubDate>
<dc:creator>Geoffrey Wiseman</dc:creator>
<guid>http://torontotechjobs.es.wordpress.com/2008/09/21/domainer-softwareweb-developers/</guid>
<description><![CDATA[Domainer is looking for more than one Software / Web Developer:
Domainer is currently looking for th]]></description>
<content:encoded><![CDATA[<p>Domainer is looking for more than one <a href="http://domainer.standoutjobs.com/jobs/2101-software-web-developers-wanted">Software / Web Developer</a>:</p>
<blockquote><p>Domainer is currently looking for the best developers in Toronto. What do we mean by the best developers? Well, you should know know your stuff in a profound way. What stuff do you need to know? At a minimum you should know the *nix command line and a how to configure a secure web server. You should also possess a mighty knowledge of mysql and its various quirks. Next you need to know a server side web friendly programming language such as Java, Groovy, PHP, Python or Ruby. Front end language development expertise is also appreciated.</p>
<p>We are doing cool things with new technologies. You will be exposed to an array of technologies such as Groovy, Grails, Java, PHP, jQuery, python, Gradle, Gant, Ant, Subversion, Eclipse, NetBeans, Ubuntu, plus a few that are for you to discover.</p></blockquote>
<p><strong>The Good</strong><br />
They claim good compensation, but is that just good compensation for those commonly called "web developers" in this city, who are chronically underpaid compared to the rest of the development crowd, or is Domainer really serious about hiring the best, which, IMO, means paying a lot more - probably over $90k in salary alone.  (There may be great people in this city who get paid less, of course, but most of the better people I've worked with make significantly more than this).</p>
<p>If this work were done well, it could be an interesting combination of interesting technology (RSS, mashups, social media, rapid-development web techniques), internal productization and good profit margins.  A lot like agency work, but with much more control - your clients simply want to make money, they don't care what you build their site in, or really, what it does, as long as the output in terms of cash is good.</p>
<p>The tech sounds reasonable for what they're doing, the process, as much as they talk about it, sounds reasonably agile.  The video helps you get an initial feel for what your employers/bosses might be like.</p>
<p><strong>The Bad</strong><br />
If this is done poorly, you're going to be doing the same things over and over to deliver bad content and advertising to the unsuspecting, never get to do a build-out the way you want to, no productization, cheapest-solution-always-wins.  Again, a lot like agency work can be, come to think of it.</p>
<p>There's some information gaps, although the video helps.  How big's the team?  How serious is Domainer about actually delivering value in these sites?  What are some examples of sites they're running?  How much is good compensation?  What're the specifics of their location?</p>
<p>That said, the amount of information in the posting is higher than many. </p>
<p><strong>YMMV</strong><br />
Your mileage may vary with respect to the 'ethics' of the kind of work that Domainer does.  There is often a kind of opportunistic/exploitative streak in this kind of "leverage a domain name" work, from what I've seen.  I can't speak for Domainer in particular, but these sites often seek to get money through advertising with the minimal required effort -- offering very little value, but profiting from search engine placement and so forth.   You'll have to decide how you feel about that and learn a little more about Domainer's approach.</p>
<p><strong>In Summary</strong><br />
If you want the opportunity to flex your web skills at building sites quickly and cost-effectively in relatively new rapid-development technologies, this might be your thing.  I'd suggest coming to terms on compensation.</p>
]]></content:encoded>
</item>

</channel>
</rss>
