<?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>Kevin&#039;s Blog &#187; Spring Framework</title>
	<atom:link href="http://blog.lckymn.com/category/it/software-development/java-software-development-it/spring-framework/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.lckymn.com</link>
	<description>IT, Java, Ubuntu, Linux</description>
	<lastBuildDate>Thu, 12 Jan 2012 05:48:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Catch-Up 01 May, 2010</title>
		<link>http://blog.lckymn.com/2010/05/01/catch-up-2010-05-01/</link>
		<comments>http://blog.lckymn.com/2010/05/01/catch-up-2010-05-01/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 19:04:16 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Fundamental]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Web Application Development]]></category>
		<category><![CDATA[Mine]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Spring Framework]]></category>
		<category><![CDATA[Ubuntu Linux]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[equals]]></category>
		<category><![CDATA[hashCode]]></category>
		<category><![CDATA[Hudson]]></category>
		<category><![CDATA[Issue Tracking System]]></category>
		<category><![CDATA[Java Reflection]]></category>
		<category><![CDATA[javac]]></category>
		<category><![CDATA[JDK7]]></category>
		<category><![CDATA[Kevin]]></category>
		<category><![CDATA[M2Eclipse]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Maven2]]></category>
		<category><![CDATA[Objects]]></category>
		<category><![CDATA[Reflection]]></category>
		<category><![CDATA[Sonatype]]></category>
		<category><![CDATA[Spring MVC]]></category>

		<guid isPermaLink="false">http://blog.lckymn.com/?p=496</guid>
		<description><![CDATA[<div class="txc-textbox" style="border: 3px solid rgb(243, 197, 52); padding: 10px; background-color: rgb(254, 254, 184);"> Some part of <a href="#3. Shadowing Declarations?">3. Bug in Java compiler?Shadowing Declarations?</a> is <a href="#update1-2010-05-10">updated</a> <a href="#update2-2010-05-10">twice</a> on the 10th of May in 2010. </div> <p>I have been very busy and am still busy so haven&#8217;t written anything for quite a while on my blog except for those entries with only one or two sentences. So I&#8217;m quickly writing what I do these days and some <p style="border: 3px solid rgb(243, 197, 52); padding: 5px; background-color: rgb(254, 254, 184); width: 600px; text-align: center;">[...Continue reading <a href="http://blog.lckymn.com/2010/05/01/catch-up-2010-05-01/">Catch-Up 01 May, 2010</a>...]</p>]]></description>
			<content:encoded><![CDATA[<div class="txc-textbox" style="border: 3px solid rgb(243, 197, 52); padding: 10px; background-color: rgb(254, 254, 184);">
Some part of <a href="#3. Shadowing Declarations?">3. <span style="text-decoration: line-through;"> Bug in Java compiler?</span>Shadowing Declarations?</a> is <a href="#update1-2010-05-10">updated</a> <a href="#update2-2010-05-10">twice</a> on the 10th of May in 2010.
</div>
<p>I have been very busy and am still busy so haven&#8217;t written anything for quite a while on my blog except for those entries with only one or two sentences. So I&#8217;m quickly writing what I do these days and some issues I have dealt with.</p>
<h3><a name="1. Issue with the new m2eclipse (version: 0.10.0.20100209-0800)">1. Issue with the new m2eclipse (version: 0.10.0.20100209-0800)</a></h3>
<p><a href="http://www.sonatype.com/">Sonatype</a> released the new version of <a href="http://m2eclipse.sonatype.org/">m2eclipse</a> in February 2010. Since I updated with it, I had got some problem with maven build through <a href="http://hudson-ci.org/">Hudson</a>.</p>
<p>The new version of m2eclipse comes with maven3 embedded yet my server uses maven2 so does my Linux on my Desktop PC.  So it was only m2eclipse which uses maven3 (SNAPSHOT version) and I deployed some of my libraries used in one web application development project. Problem was that I deployed the dependency libraries several times with the same version number. With maven2, it&#8217;s OK as it uses time-stamp to distinguish one version from another within the same version, yet with maven3, having the same version is not allowed. Well, I am not 100% sure about this as once I solved the problem I didn&#8217;t really check the details as I didn&#8217;t have enough time. Anyway, so as shown in the following image, the project status icon once became dark rain clouds which mean really bad.<br />
<div id="attachment_501" class="wp-caption alignnone" style="width: 530px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/00_build_failure01.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/00_build_failure01.jpg" alt="Build Failure: Project status icon became dark rain clouds" title="00 build failure01" width="520" height="294" class="size-full wp-image-501" /></a><p class="wp-caption-text">Build Failure: Project status icon became dark rain clouds</p></div></p>
<p>My project build failed seven times due to the difference between maven2 and maven3 I described above, or it can be something else yet it is caused by some difference between those two versions.<br />
<div id="attachment_502" class="wp-caption alignnone" style="width: 336px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/00_build_failure02.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/00_build_failure02.jpg" alt="Build Failure: It failed seven times due to the difference between maven2 and maven3" title="00 build failure02" width="326" height="446" class="size-full wp-image-502" /></a><p class="wp-caption-text">Build Failure: It failed seven times due to the difference between maven2 and maven3</p></div><br />
(It happened in February. The build number in the image is 108 but it is now 305).</p>
<p>So why did I not just keep the old version of m2eclipse with maven2 embedded? Well, the old one comes with some old version of maven2 which does not support <a href="http://maven.apache.org/guides/mini/guide-encryption.html">password encryption</a> while the maven2 on both my PC and my server does support it as it is a newer version. Thus I updated with the new m2eclipse as soon as it was available yet didn&#8217;t really expect that it comes with maven3. Anyway, It&#8217;s solved by using maven2 installed on my PC when deploying project packages. The other times such as solving dependencies and building package without deployment, I can still use the embedded maven3 in the new m2eclipse without any problems.</p>
<h3><a name="2. I have been working on...">2. I have been working on&#8230;</a></h3>
<p>I founded a start-up company with my friend a few months ago, and we are currently working on a web application development for our own start-up, but it is probably too premature to announce what it is as it&#8217;s still an early stage of development.<br />
The issues listed in the following image is a part of the issues I and my colleague have solved and been working on.<br />
<div id="attachment_503" class="wp-caption alignnone" style="width: 650px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_00.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_00.jpg" alt="I&#039;m currently working on this project." title="01 Issue Tracking 00" width="640" height="477" class="size-full wp-image-503" /></a><p class="wp-caption-text">I'm currently working on this project.</p></div></p>
<p>In addition, I have been developing my own Java libraries which can be commonly used in many other projects (and my friend has also been developing reusable JavaScript libraries). However, I did not record all the issues belong to these reusable components and recently felt that I should do it before I go any further. Otherwise, I may later forget what problems I solved and how I did as well as all the issues covered previously. So I wrote all the tickets for those libraries.<br />
<div id="attachment_504" class="wp-caption alignnone" style="width: 650px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_01.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_01.jpg" alt="Issues of commonly used libraries built by myself" title="01 Issue Tracking 01" width="640" height="335" class="size-full wp-image-504" /></a><p class="wp-caption-text">Issues of commonly used libraries built by myself</p></div></p>
<p>I&#8217;ve also been developing &#8216;Java object to JSON&#8217; library and did the same as what I just explained (that is creating issue tickets).  There are already a number of the libraries which convert Java object into <a href="http://json.org/">JSON</a> so why would I make another?  Well, there can be several reasons but major ones are</p>
<ol>
<li>I need it to convert any <a href="http://en.wikipedia.org/wiki/POJO">POJO</a> with only <a href="http://en.wikipedia.org/wiki/Java_annotation">annotations</a> into <a href="http://json.org/">JSON</a>.</li>
<li>It has to be simple as I do not want to have any complex functions or heavy library for a simple conversion (some libraries are too heavy for such a simple task).</li>
<li>When customisation is required or bug is found in the library, I want to be able to change and fix it however I want so that I do not have to waste my time on waiting for others to solve it.</li>
<li>I want it to work in some environments where using bytecode manipulation is not an option. So if I programme one with bytecode manipulation then it works faster when it&#8217;s available whereas the other one is without it so that it can be used in those enviornments (I currently have only the latter one and will do the former one when I have time later).</li>
</ol>
<p>The following issues are what I have solved for the Java to JSON library.<br />
<div id="attachment_505" class="wp-caption alignnone" style="width: 650px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_02.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_02.jpg" alt="Issues of my Java object to JSON library" title="01 Issue Tracking 02" width="640" height="451" class="size-full wp-image-505" /></a><p class="wp-caption-text">Issues of my Java object to JSON library</p></div></p>
<p>Finally, I have another project to help Ajax enabled web application development. From my experience, I found that it is sharing the information about the available server-side functions with the client-side developers that causes the most waste of time between the front-end development and the back-end development.  The first time one function is made or whenever the existing ones are changed, I have to write or rewrite the document explaining it and the client-side developer has to find the changed parts in the document.  It is annoying and a non-productive moment in the development so I and my colleague discussed about this issue and came up with the idea of having a library which exposes all the available server-side functions to the front-end (It can understand Spring <code>@MVC</code> controllers).  For now, it has only this, yet I will add more features to help Ajax web application development.<br />
<div id="attachment_506" class="wp-caption alignnone" style="width: 650px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_03.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_03.jpg" alt="Issues of my web method library" title="01 IssueTracking 03" width="640" height="146" class="size-full wp-image-506" /></a><p class="wp-caption-text">Issues of my web method library</p></div></p>
<p>* As I used more and more reflection to develop those libraries, I realised that Java Reflection has no method to get the names of method parameters. Well, there can be some ways for instance, using -g (generating debugging info) option when compiling or using some libraries such as <a href="http://asm.ow2.org/">ASM</a> or use <a href="http://paranamer.codehaus.org/">ParaNamer</a> (It requires an additional step when compiling to add the constants having the parameter names in the class) but not by just Java reflection.  Anyway, none of these is the solution I want, and unfortunately if I heard right, this problem will remain in JDK 7. <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<h3><a name ="3. Shadowing Declarations?">3. <span style="text-decoration: line-through;">Bug in Java compiler?</span> Shadowing Declarations?</a></h3>
<p>I created the Objects utility class based on <a href="http://download.java.net/jdk7/docs/api/java/util/Objects.html">http://download.java.net/jdk7/docs/api/java/util/Objects.html</a>. This will be available in JDK 7 yet I wanted to use it before JDK 7 is released so I made my own one. I can use it now, and it can easily be replaced by the one in JDK when it&#8217;s available.  <span style="text-decoration: line-through;">After I made it, I found some weird bug, I believe, in Java compiler.</span> After I used it, I had some problem and though it could be a bug in Java compiler yet <a href="#update2-2010-05-10">it looks like &#8216;shadowing declarations&#8217;.</a></p>
<p>This is the part of Objects class I coded.</p>
<pre class="brush: java; title: ; notranslate">
package com.lckymn.kevin.common.util;

/**
 * @author Lee, SeongHyun (Kevin)
 * @version 0.0.1 (2010-04-30)
 */
public final class Objects
{
    private Objects()
    {
        throw new IllegalStateException(getClass().getName() + &quot; cannot be instantiated.&quot;);
    }

    // other code omitted ...

    /**
     * Returns the hash code of a non-{@code null} argument and 0 for a {@code null} argument.
     *
     * @param o
     *            an object
     * @return the hash code of a non-{@code null} argument and 0 for a {@code null} argument
     * @see {@link Object#hashCode()}
     */
    public static int hashCode(final Object o)
    {
        return (null == o ? 0 : o.hashCode());
    }

    // other code omitted ...
}
</pre>
<p>The following code is a POJO in which I want to use the Objects.hashCode(Object) method.</p>
<pre class="brush: java; title: ; notranslate">
package com.lckymn.kevin.test.bean;

/**
 * @author Lee, SeongHyun (Kevin)
 * @version 0.0.1 (2010-04-30)
 */
public class SomePojo
{
    private final int number;
    private final String name;

    public SomePojo(int number, String name)
    {
        this.number = number;
        this.name = name;
    }

    public int getNumber()
    {
        return number;
    }

    public String getName()
    {
        return name;
    }

    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + number;
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj)
    {
        if (this == obj)
        {
            return true;
        }
        if (!(obj instanceof SomePojo))
        {
            return false;
        }
        final SomePojo that = (SomePojo) obj;
        return (this.number == that.getNumber())
                &amp;&amp; (this.name == that.getName() ||
                        (null != this.name &amp;&amp; this.name.equals(that.getName())));
    }
}
</pre>
<p>So I changed this code snippet</p>
<pre class="brush: java; gutter: false; highlight: [7]; title: ; notranslate">
@Override
public int hashCode()
{
    final int prime = 31;
    int result = 1;
    result = prime * result + number;
    result = prime * result + ((name == null) ? 0 : name.hashCode());
    return result;
}
</pre>
<p>to this.</p>
<pre class="brush: java; gutter: false; highlight: [3,15]; title: ; notranslate">
package com.lckymn.kevin.test.bean;

import static com.lckymn.kevin.common.util.Objects.*;

public class SomePojo
{
    // ...

    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + number;
        result = prime * result + hashCode(name);
        return result;
    }
}
</pre>
<p>I used static import and hashCode(Object) method in the Objects class. Although, nothing&#8217;s wrong in the code, my Eclipse complains that there is a compile-time error. The following image shows that.<br />
<div id="attachment_511" class="wp-caption alignnone" style="width: 929px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/02_objects_hashcode_01.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/02_objects_hashcode_01.jpg" alt="Objects.hashCode(Object) with static import does not work." title="02 Objects.hashCode 01" width="919" height="837" class="size-full wp-image-511" /></a><p class="wp-caption-text">Objects.hashCode(Object) with static import does not work.</p></div></p>
<p>Yet the same code with no-static import but using class name as the qualifier to use <code>hashCode(Object)</code> method works perfectly. The following code has <code>Objects.hashCode(name)</code> and no compile-time error.</p>
<pre class="brush: java; highlight: [36]; title: ; notranslate">
package com.lckymn.kevin.test.bean;

import com.lckymn.kevin.common.util.Objects;

/**
 * @author Lee, SeongHyun (Kevin)
 * @version 0.0.1 (2010-04-30)
 */
public class SomePojo
{
    private final int number;
    private final String name;

    public SomePojo(int number, String name)
    {
        this.number = number;
        this.name = name;
    }

    public int getNumber()
    {
        return number;
    }

    public String getName()
    {
        return name;
    }

    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + number;
        result = prime * result + Objects.hashCode(name);
        return result;
    }

    @Override
    public boolean equals(Object obj)
    {
        if (this == obj)
        {
            return true;
        }
        if (null == obj)
        {
            return false;
        }
        if (!(obj instanceof SomePojo))
        {
            return false;
        }
        final SomePojo that = (SomePojo) obj;
        return (this.number == that.getNumber())
                &amp;&amp; (this.name == that.getName() || (null != this.name &amp;&amp; this.name.equals(that.getName())));
    }
}
</pre>
<p>The following image shows it has no error in the part where <code>Objects.hashCode(Object)</code> is used..<br />
<div id="attachment_508" class="wp-caption alignnone" style="width: 515px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/02_objects_hashcode_02.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/02_objects_hashcode_02.jpg" alt="Using Class as qualifier to use hashCode works." title="02 Objects.hashCode 02" width="505" height="622" class="size-full wp-image-508" /></a><p class="wp-caption-text">Using Class as qualifier to use hashCode works.</p></div></p>
<p>I wondered if it&#8217;s a bug in the Eclipse or a bug in the Java compiler. So I opened the terminal and tested it.</p>
<pre class="brush: bash; gutter: false; title: ; notranslate">
$ javac -version
javac 1.6.0_15

$ javac com/lckymn/kevin/test/bean/SomePojo.java
com/lckymn/kevin/test/bean/SomePojo.java:39: cannot find symbol
symbol  : method hashCode(java.lang.String)
location: class com.lckymn.kevin.test.bean.SomePojo
        result = prime * result + hashCode(name);
                                  ^
com/lckymn/kevin/test/bean/SomePojo.java:39: operator + cannot be applied to int,hashCode
        result = prime * result + hashCode(name);
                       ^
com/lckymn/kevin/test/bean/SomePojo.java:39: incompatible types
found   : &lt;nulltype&gt;
required: int
        result = prime * result + hashCode(name);
                                ^
3 errors
</pre>
<p>As it shows, the compiler does totally not understand that the hashCode(Object) method from the Objects class is available and valid.</p>
<p>Is a bug only in the SUN JDK in the Ubuntu Linux repository? So I tried with OpenJDK 6 as well.</p>
<pre class="brush: bash; gutter: false; title: ; notranslate">
$ /usr/lib/jvm/java-6-openjdk/bin/javac -version
javac 1.6.0_0

$ /usr/lib/jvm/java-6-openjdk/bin/javac com/lckymn/kevin/test/bean/SomePojo.java
com/lckymn/kevin/test/bean/SomePojo.java:39: cannot find symbol
symbol  : method hashCode(java.lang.String)
location: class com.lckymn.kevin.test.bean.SomePojo
        result = prime * result + hashCode(name);
                                  ^
com/lckymn/kevin/test/bean/SomePojo.java:39: operator + cannot be applied to int,hashCode
        result = prime * result + hashCode(name);
                       ^
com/lckymn/kevin/test/bean/SomePojo.java:39: incompatible types
found   : &lt;nulltype&gt;
required: int
        result = prime * result + hashCode(name);
                                ^
3 errors
</pre>
<p>The same result&#8230;</p>
<p>OK, it might be a bug in that particular version. Fortunately, the most recent version of SUN JDK 6 was released yesterday. It was officially released before (the 15th of April, 2010) yet the version managed by Ubuntu was not available before yesterday. So I installed it and tested it again with the Java compiler in the new JDK6.<br />
<div id="attachment_509" class="wp-caption alignnone" style="width: 622px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/03_update_jdk.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/03_update_jdk.jpg" alt="New version of SUN JDK6 is available in the Ubuntu repository" title="03 Update JDK" width="612" height="640" class="size-full wp-image-509" /></a><p class="wp-caption-text">New version of SUN JDK6 is available in the Ubuntu repository</p></div></p>
<p>It still has the same problem.</p>
<pre class="brush: bash; gutter: false; title: ; notranslate">
$ javac -version
javac 1.6.0_20

$ javac com/lckymn/kevin/test/bean/SomePojo.java
com/lckymn/kevin/test/bean/SomePojo.java:39: cannot find symbol
symbol  : method hashCode(java.lang.String)
location: class com.lckymn.kevin.test.bean.SomePojo
        result = prime * result + hashCode(name);
                                  ^
com/lckymn/kevin/test/bean/SomePojo.java:39: operator + cannot be applied to int,hashCode
        result = prime * result + hashCode(name);
                       ^
com/lckymn/kevin/test/bean/SomePojo.java:39: incompatible types
found   : &lt;nulltype&gt;
required: int
        result = prime * result + hashCode(name);
                                ^
3 errors
</pre>
<p>I probably need to test with the Java compiler in the JDK6 for Windows but I have no stomach for that now nor do I have time to do that.</p>
<div class="txc-textbox" style="border: 3px solid rgb(243, 197, 52); padding: 10px; background-color: rgb(254, 254, 184);">
<a name="update1-2010-05-10">* Update1 (2010-05-10)</a><br />
I also tested it with the Java compiler in the JDK 6 (1.6.0_16) for Windows and got the same result. <span style="text-decoration: line-through">It seem like static import cannot handle method overloading. I didn&#8217;t have time to research to find the details but based on my testing, method overloading cannot be used with static import.<br />
If so then there should be a good reason for that, and the only one I can think of right now is that it might have something to do with varargs.</span><br />
Take a look at the following code.</p>
<pre class="brush: java; title: ; notranslate">
package com.lckymn.kevin.common.util;

public final class SomeHelper
{
    private SomeHelper()
    {
        throw new IllegalStateException(getClass().getName() + &quot; cannot be instantiated.&quot;);
    }

    public static void test(Object... object)
    {
        System.out.println(&quot;SomeHelper.test()&quot;);
    }
}
</pre>
<pre class="brush: java; highlight: [3,14,17]; title: ; notranslate">
package com.lckymn.kevin.test;

import static com.lckymn.kevin.common.util.SomeHelper.test;

public class Test
{
    public void test()
    {
        System.out.println(&quot;Test.test()&quot;);
    }

    public void callTest()
    {
        test();            // no error here.

        Object object = new Object();
        test(object);    // compile-time error
    }
}
</pre>
<p><span style="text-decoration: line-through">Since a method with varargs can take no argument when it&#8217;s called, Test.test() and SomeHelper.test(Object&#8230; object) can be indistinguishable with static import. This is, I think, probably one of the reasons why method overloading is not allowed with static import. Nevertheless, it is still very weird as calling test() does not cause any compile-time error while test(object) does.</span><br />
So the following code has no compile-time error and displays <code>Test.test()</code>.</p>
<pre class="brush: java; highlight: [3]; title: ; notranslate">
package com.lckymn.kevin.test;

import static com.lckymn.kevin.common.util.SomeHelper.test;

public class Test
{
    public void test()
    {
        System.out.println(&quot;Test.test()&quot;);
    }

    public void callTest()
    {
        test();    // static import of SomeHelper.test has no effect here.
    }

    public static void main(String[] args)
    {
        new Test().callTest();
        System.exit(0);
    }
}
</pre>
<p>It displays <code>Test.test()</code>.</p>
<p>What if the helper class has test() method with no arguments and the Test class has test() method with varargs then call <code>test()</code>? The same result! It still calls Test&#8217;s test() method with varargs (<code>Test.test(Object... object)</code>).</p>
<pre class="brush: java; highlight: [10]; title: ; notranslate">
package com.lckymn.kevin.common.util;

public final class SomeHelper
{
    private SomeHelper()
    {
        throw new IllegalStateException(getClass().getName() + &quot; cannot be instantiated.&quot;);
    }

    public static void test()
    {
        System.out.println(&quot;SomeHelper.test()&quot;);
    }
}
</pre>
<pre class="brush: java; highlight: [3,7]; title: ; notranslate">
package com.lckymn.kevin.test;

import static com.lckymn.kevin.common.util.SomeHelper.test;

public class Test
{
    public void test(Object... object)
    {
        System.out.println(&quot;Test.test(Object...object)&quot;);
    }

    public void callTest()
    {
        test(); // it calls the Test.test(Object... object) method NOT SomeHelper.test().
    }

    public static void main(String[] args)
    {
        new Test().callTest();
        System.exit(0);
    }
}
</pre>
<p>It displays <code>Test.test(Object...object)</code>
</div>
<div class="txc-textbox" style="border: 3px solid rgb(243, 197, 52); padding: 10px; background-color: rgb(254, 254, 184);">
<a name="update2-2010-05-10">Update2 (2010-05-10)</a><br />
It is more likely to be <a href="http://java.sun.com/docs/books/jls/third_edition/html/names.html#34133">&#8216;Shadowing Declarations&#8217;</a>. Although, I couldn&#8217;t find the exactly matching case from the <a href="http://java.sun.com/docs/books/jls/">JLS</a> yet, it makes more sense if the method imported by static-import is shadowed.
</div>
<h3><a name="4. Using Objects">4. Using Objects</a></h3>
<p>By the way, the Objects class is simple but very useful.<br />
with it, the highlighted parts of the following code can</p>
<pre class="brush: java; highlight: [53,54,55,56,57,72,73,74,75]; title: ; notranslate">
package com.lckymn.kevin.test.bean;

public class Bank
{
    private Long id;
    private String bankName;
    private String bsbNumber;
    private String address;

    public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public String getBankName()
    {
        return bankName;
    }

    public void setBankName(String bankName)
    {
        this.bankName = bankName;
    }

    public String getBsbNumber()
    {
        return bsbNumber;
    }

    public void setBsbNumber(String bsbNumber)
    {
        this.bsbNumber = bsbNumber;
    }

    public String getAddress()
    {
        return address;
    }

    public void setAddress(String address)
    {
        this.address = address;
    }

    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((bankName == null) ? 0 : bankName.hashCode());
        result = prime * result + ((bsbNumber == null) ? 0 : bsbNumber.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object bank)
    {
        if (this == bank)
        {
            return true;
        }
        if (!(bank instanceof Bank))
        {
            return false;
        }
        final Bank that = (Bank) bank;
        return (this.bankName == that.getBankName() ||
               (null != this.bankName &amp;&amp; this.bankName.equals(that.getBankName())))
                &amp;&amp; (this.bsbNumber == that.getBsbNumber() ||
                   (null != this.bsbNumber &amp;&amp; this.bsbNumber.equals(that.getBsbNumber())));
    }
}
</pre>
<p>become like this</p>
<pre class="brush: java; highlight: [55,70,71]; title: ; notranslate">
package com.lckymn.kevin.test.bean;

import com.lckymn.kevin.common.util.Objects;

public class Bank
{
    private Long id;
    private String bankName;
    private String bsbNumber;
    private String address;

    public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public String getBankName()
    {
        return bankName;
    }

    public void setBankName(String bankName)
    {
        this.bankName = bankName;
    }

    public String getBsbNumber()
    {
        return bsbNumber;
    }

    public void setBsbNumber(String bsbNumber)
    {
        this.bsbNumber = bsbNumber;
    }

    public String getAddress()
    {
        return address;
    }

    public void setAddress(String address)
    {
        this.address = address;
    }

    @Override
    public int hashCode()
    {
        return Objects.hash(bankName, bankName);
    }

    @Override
    public boolean equals(Object bank)
    {
        if (this == bank)
        {
            return true;
        }
        if (!(bank instanceof Bank))
        {
            return false;
        }
        final Bank that = (Bank) bank;
        return Objects.equals(this.bankName, that.getBankName())
               &amp;&amp; Objects.equals(this.bsbNumber, that.getBsbNumber());
    }
}
</pre>
<p>So these five lines in the hashCode method</p>
<pre class="brush: java; gutter: false; title: ; notranslate">
final int prime = 31;
int result = 1;
result = prime * result + ((bankName == null) ? 0 : bankName.hashCode());
result = prime * result + ((bsbNumber == null) ? 0 : bsbNumber.hashCode());
return result;
</pre>
<p>become</p>
<pre class="brush: java; gutter: false; title: ; notranslate">
return Objects.hash(bankName, bankName);
</pre>
<p>and these four lines in the equals method</p>
<pre class="brush: java; gutter: false; title: ; notranslate">
return (this.bankName == that.getBankName() ||
       (null != this.bankName &amp;&amp; this.bankName.equals(that.getBankName())))
        &amp;&amp; (this.bsbNumber == that.getBsbNumber() ||
           (null != this.bsbNumber &amp;&amp; this.bsbNumber.equals(that.getBsbNumber())));
</pre>
<p>become</p>
<pre class="brush: java; gutter: false; title: ; notranslate">
return Objects.equals(this.bankName, that.getBankName())
       &amp;&amp; Objects.equals(this.bsbNumber, that.getBsbNumber());
</pre>
<p>Although one might say that I can use <a href="http://projectlombok.org/">Lombok</a> instead, I prefer to see what is going on in my code. Those hashCode and equals methods are not additional info of the class. It tells what makes instances of the class equal thus I prefer to have it in there to see and want to freely change it whenever and however I want. Well, in other words, just a matter of personal preference. <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
That&#8217;s it.<br />
I perhaps have more to say yet am getting tired (4:55 AM :O). So I&#8217;m calling it a night. <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lckymn.com/2010/05/01/catch-up-2010-05-01/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VMware and SpringSource</title>
		<link>http://blog.lckymn.com/2009/08/11/vmware-and-springsource/</link>
		<comments>http://blog.lckymn.com/2009/08/11/vmware-and-springsource/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 08:10:49 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Spring Framework]]></category>
		<category><![CDATA[Acquire]]></category>
		<category><![CDATA[SpringSource]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[VMware and SpringSource]]></category>

		<guid isPermaLink="false">http://blog.lckymn.com/?p=372</guid>
		<description><![CDATA[<p>I heard very surprising news today morning which is <a href="http://www.springsource.com" target="_blank">SpringSource</a> has agreed to be acquired by <a href="http://www.vmware.com" target="_blank">VMware</a>.</p> <p><a href="http://blog.springsource.com/2009/08/10/springsource-chapter-two/" target="_blank">http://blog.springsource.com/2009/08/10/springsource-chapter-two/</a> <a href="http://www.vmware.com/company/news/releases/springsource.html" target="_blank">http://www.vmware.com/company/news/releases/springsource.html</a> <a href="http://blogs.vmware.com/console/2009/08/vmware-acquires-springsource.html" target="_blank">http://blogs.vmware.com/console/2009/08/vmware-acquires-springsource.html</a> <a href="http://www.earthtimes.org/articles/show/vmware-to-acquire-springsource,921934.shtml" target="_blank">http://www.earthtimes.org/articles/show/vmware-to-acquire-springsource,921934.shtml</a></p> <p>Looks like a good deal for both companies. <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p> <p>VMware recently hired <a href="http://www.techcrunch.com/2009/07/13/google-loses-engineering-director-who-once-caused-steve-ballmer-to-melt-down/" target="_blank">Mark Lucovsky</a> from Google and now has SpringSource. I guess VMware is really doing well. <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p> ]]></description>
			<content:encoded><![CDATA[<p>I heard very surprising news today morning which is <a href="http://www.springsource.com" target="_blank">SpringSource</a> has agreed to be acquired by <a href="http://www.vmware.com" target="_blank">VMware</a>.</p>
<p><a href="http://blog.springsource.com/2009/08/10/springsource-chapter-two/" target="_blank">http://blog.springsource.com/2009/08/10/springsource-chapter-two/</a><br />
<a href="http://www.vmware.com/company/news/releases/springsource.html" target="_blank">http://www.vmware.com/company/news/releases/springsource.html</a><br />
<a href="http://blogs.vmware.com/console/2009/08/vmware-acquires-springsource.html" target="_blank">http://blogs.vmware.com/console/2009/08/vmware-acquires-springsource.html</a><br />
<a href="http://www.earthtimes.org/articles/show/vmware-to-acquire-springsource,921934.shtml" target="_blank">http://www.earthtimes.org/articles/show/vmware-to-acquire-springsource,921934.shtml</a></p>
<p>Looks like a good deal for both companies. <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>VMware recently hired <a href="http://www.techcrunch.com/2009/07/13/google-loses-engineering-director-who-once-caused-steve-ballmer-to-melt-down/" target="_blank">Mark Lucovsky</a> from Google and now has SpringSource. I guess VMware is really doing well. <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lckymn.com/2009/08/11/vmware-and-springsource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring ROO M1 Coming Soon</title>
		<link>http://blog.lckymn.com/2009/05/21/spring-roo-m1-coming-soon/</link>
		<comments>http://blog.lckymn.com/2009/05/21/spring-roo-m1-coming-soon/#comments</comments>
		<pubDate>Thu, 21 May 2009 13:02:32 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Spring Framework]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring ROO]]></category>
		<category><![CDATA[Spring ROO M1]]></category>
		<category><![CDATA[SpringSource]]></category>

		<guid isPermaLink="false">http://blog.lckymn.com/?p=319</guid>
		<description><![CDATA[<p>Today, I met and talked with a few people from SpringSource at a pub in North Sydney including Ben and Stefan (sorry Stefan. It&#8217;s just in alphabetical order <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ) who are developing Spring ROO.</p> <p>Anyone who are interested in Spring ROO had better keep an eye on this thread as they are going to release ROO M1 soon. <a href="http://forum.springsource.org/showthread.php?t=71985" target="_blank">http://forum.springsource.org/showthread.php?t=71985</a></p> <p>I heard that a lot of cool plug-ins for ROO will also be available <p style="border: 3px solid rgb(243, 197, 52); padding: 5px; background-color: rgb(254, 254, 184); width: 600px; text-align: center;">[...Continue reading <a href="http://blog.lckymn.com/2009/05/21/spring-roo-m1-coming-soon/">Spring ROO M1 Coming Soon</a>...]</p>]]></description>
			<content:encoded><![CDATA[<p>Today, I met and talked with a few people from SpringSource at a pub in North Sydney including Ben and Stefan (sorry Stefan. It&#8217;s just in alphabetical order <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) who are developing Spring ROO.</p>
<p>Anyone who are interested in Spring ROO had better keep an eye on this thread as they are going to release ROO M1 soon.<br />
<a href="http://forum.springsource.org/showthread.php?t=71985" target="_blank">http://forum.springsource.org/showthread.php?t=71985</a></p>
<p>I heard that a lot of cool plug-ins for ROO will also be available and am really looking forward to it.</p>
<div class="txc-textbox" style="border: 3px solid rgb(243, 197, 52); padding: 10px; background-color: rgb(254, 254, 184);">
Spring ROO M1 was released on the 27th of May 2009.
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.lckymn.com/2009/05/21/spring-roo-m1-coming-soon/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ROO So Cool!!! -04-</title>
		<link>http://blog.lckymn.com/2009/05/17/roo-so-cool-04/</link>
		<comments>http://blog.lckymn.com/2009/05/17/roo-so-cool-04/#comments</comments>
		<pubDate>Sun, 17 May 2009 01:03:43 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Spring Framework]]></category>
		<category><![CDATA[AJDT]]></category>
		<category><![CDATA[AspectJ]]></category>
		<category><![CDATA[AspectJ Development Tools]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Eclipse JEE]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Inter-type declarations]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaBean]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[M2Eclipse]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Maven Integration for Eclipse]]></category>
		<category><![CDATA[Maven2]]></category>
		<category><![CDATA[Mixin]]></category>
		<category><![CDATA[Multiple Inheritance]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring ROO]]></category>
		<category><![CDATA[SpringSource Tool Suite]]></category>
		<category><![CDATA[STS]]></category>

		<guid isPermaLink="false">http://blog.lckymn.com/?p=283</guid>
		<description><![CDATA[<p>Continued from <a href="http://blog.lckymn.com/2009/05/17/roo-so-cool-03/" target="_blank">http://blog.lckymn.com/2009/05/17/roo-so-cool-03/</a></p> <p>There are two other aspects which are <code>Choice_Roo_Plural</code> and <code>Choice_Roo_ToString</code>.</p> <p><div id="attachment_243" class="wp-caption alignnone" style="width: 913px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-22.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-22.jpg" alt="&#34;Choice&#34; in Plural Form, &#34;Choices&#34;" title="&#34;Choice&#34; in Plural Form, &#34;Choices&#34;" width="903" height="417" class="size-full wp-image-243" /></a><p class="wp-caption-text">&#34;Choice&#34; in Plural Form, &#34;Choices&#34;</p></div> <code>Choice_Roo_Plural</code> declares that the <code>Choice</code> has a method named <code>getPluralName()</code> which returns a String type value, &#8220;Choices&#8221; which is the plural form of &#8220;Choice&#8221;. I don&#8217;t really get why it is necessary though. I first thought it <p style="border: 3px solid rgb(243, 197, 52); padding: 5px; background-color: rgb(254, 254, 184); width: 600px; text-align: center;">[...Continue reading <a href="http://blog.lckymn.com/2009/05/17/roo-so-cool-04/">ROO So Cool!!! -04-</a>...]</p>]]></description>
			<content:encoded><![CDATA[<p>Continued from<br />
<a href="http://blog.lckymn.com/2009/05/17/roo-so-cool-03/" target="_blank">http://blog.lckymn.com/2009/05/17/roo-so-cool-03/</a></p>
<p>There are two other aspects which are <code>Choice_Roo_Plural</code> and <code>Choice_Roo_ToString</code>.</p>
<p><div id="attachment_243" class="wp-caption alignnone" style="width: 913px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-22.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-22.jpg" alt="&quot;Choice&quot; in Plural Form, &quot;Choices&quot;" title="&quot;Choice&quot; in Plural Form, &quot;Choices&quot;" width="903" height="417" class="size-full wp-image-243" /></a><p class="wp-caption-text">&quot;Choice&quot; in Plural Form, &quot;Choices&quot;</p></div><br />
<code>Choice_Roo_Plural</code> declares that the <code>Choice</code> has a method named <code>getPluralName()</code> which returns a String type value, &#8220;Choices&#8221; which is the plural form of &#8220;Choice&#8221;. I don&#8217;t really get why it is necessary though.  I first thought it might be the name of the table with which the <code>Choice_Roo_Entity</code> matches, yet the table name is <code>choice</code>.</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
Bind entity com.springsource.vote.domain.Choice on table choice
</pre>
<p>It is probably for the future use as a name of domain object in plural form may be frequently required when displaying the list of it.</p>
<p>Now, let&#8217;s look at the last aspect.<br />
<div id="attachment_244" class="wp-caption alignnone" style="width: 919px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-23.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-23.jpg" alt="toString() method for Choice" title="toString() method for Choice" width="909" height="417" class="size-full wp-image-244" /></a><p class="wp-caption-text">toString() method for Choice</p></div><br />
The last one is <code>Choice_Roo_ToString</code> which declare that Choice has <code>toString()</code> method.</p>
<pre class="brush: java; title: ; notranslate">
privileged aspect Choice_Roo_ToString {

    public java.lang.String Choice.toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(&quot;id: &quot;).append(getId()).append(&quot;, &quot;);
        sb.append(&quot;version: &quot;).append(getVersion()).append(&quot;, &quot;);
        sb.append(&quot;namingChoice: &quot;).append(getNamingChoice()).append(&quot;, &quot;);
        sb.append(&quot;description: &quot;).append(getDescription()).append(&quot;, &quot;);
        return sb.toString();
    }    

}
</pre>
<p>It returns String containing the information about <code>Choice</code> which includes all the values of the variables from the aspects as well. This String is used to display the information about Choice object in the view, <code>WEB-INF/jsp/vote/create.jsp</code>.</p>
<p>All these mixins can be good Separation of Concerns (SoC).  Each aspect has what should be a concern in a particular mixin only. For example, id and version of Choice are not really a concern of <code>Choice</code> itself as it does not have any meaning for Choice, yet it is very important for OR mapping. Thus it is separated from <code>Choice</code> and only occurs in <code>Choice_Roo_Entity</code> which plays the role of a persistent object.</p>
<p>It is not a completely new ways to write mixin using inter-type declarations in AspectJ (<a href="http://today.java.net/pub/a/today/2005/12/15/writing-mixins-with-aop.html" target="_blank">http://today.java.net/pub/a/today/2005/12/15/writing-mixins-with-aop.html</a>). Nevertheless, Spring ROO is still so cool as I have never seen any automatically generated code by Java frameworks uses mixins written using inter-type declarations as a nice way of SoC. I may need to call ROO RSoC (Real Separation of Concerns). <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>OK, I am now running out of time so had better finish this post quickly.  </p>
<p>I would just finally like to point out some minor issues I found.</p>
<p>1. An error in dojo JS toolkit.<br />
<div id="attachment_165" class="wp-caption alignnone" style="width: 851px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-15.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-15.jpg" alt="dojo JS Toolkit Error" title="dojo JS Toolkit Error" width="841" height="588" class="size-full wp-image-165" /></a><p class="wp-caption-text">dojo JS Toolkit Error</p></div></p>
<p>2. An error in roo.css file.<br />
<div id="attachment_245" class="wp-caption alignnone" style="width: 946px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-24.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-24.jpg" alt="CSS Error" title="CSS Error" width="936" height="408" class="size-full wp-image-245" /></a><p class="wp-caption-text">CSS Error</p></div></p>
<pre class="brush: css; first-line: 38; highlight: [41]; title: ; notranslate">
#wrap {
	margin:0 auto;
  	position:relative;
  	float:center;
  	top: 0px;
  	left:0px;
  	width:800px;
  	text-align:left;  	

}
</pre>
<p><code>center</code> is not a float value.</p>
<p>3. Using a String&#8217;s equals() method to test for an empty String. This might be OK for a small application like the ROO example but it can bring about some performance issue for a big application with numerous simultaneous user requests.<br />
<div id="attachment_246" class="wp-caption alignnone" style="width: 913px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-25.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-25.jpg" alt="Performance Issue - Test for Empty String" title="Performance Issue - Test for Empty String" width="903" height="405" class="size-full wp-image-246" /></a><p class="wp-caption-text">Performance Issue - Test for Empty String</p></div><br />
So the following code from <code>ChoiceEditor_Roo_Editor</code></p>
<pre class="brush: java; title: ; notranslate">
if (text == null || &quot;&quot;.equals(text))
</pre>
<p>had better be</p>
<pre class="brush: java; title: ; notranslate">
if (text == null || 0 == text.length())
</pre>
<p>I wrote more details about it here with performance tests.<br />
<a href="http://blog.lckymn.com/2009/05/17/test-for-empty-string/" target="_blank" style="color: blue; font-weight: bolder;">http://blog.lckymn.com/2009/05/17/test-for-empty-string/</a></p>
<p>Finally, it&#8217;s my wish. I found that aspect code is not really supported by the Eclipse functions for Java such as <code>Call Hierarchy</code> and <code>Open Declaration</code>. It would be much better if aspects are fully supported by the Eclipse functions for Java. However, it may have something to do with AJDT not Spring ROO integration.</p>
<p>Phew, I have eventually written this. <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  Even though I tried ROO approximately two weeks ago, I did not have time to write about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lckymn.com/2009/05/17/roo-so-cool-04/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ROO So Cool!!! -03-</title>
		<link>http://blog.lckymn.com/2009/05/17/roo-so-cool-03/</link>
		<comments>http://blog.lckymn.com/2009/05/17/roo-so-cool-03/#comments</comments>
		<pubDate>Sun, 17 May 2009 01:02:34 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Spring Framework]]></category>
		<category><![CDATA[AJDT]]></category>
		<category><![CDATA[AspectJ]]></category>
		<category><![CDATA[AspectJ Development Tools]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Eclipse JEE]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Inter-type declarations]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaBean]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[M2Eclipse]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Maven Integration for Eclipse]]></category>
		<category><![CDATA[Maven2]]></category>
		<category><![CDATA[Mixin]]></category>
		<category><![CDATA[Multiple Inheritance]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring ROO]]></category>
		<category><![CDATA[SpringSource Tool Suite]]></category>
		<category><![CDATA[STS]]></category>

		<guid isPermaLink="false">http://blog.lckymn.com/?p=275</guid>
		<description><![CDATA[<p>Continued from <a href="http://blog.lckymn.com/2009/05/17/roo-so-cool-02/" target="_blank">http://blog.lckymn.com/2009/05/17/roo-so-cool-02/</a></p> <p>Now, let&#8217;s look at more interesting one that is the ROO generated source code!</p> <p>As you can see, there are many AspectJ aspects in the <code>com.springsource.vote.domain</code> package. So I&#8217;ll firstly try to look at the <code>Choice</code> class which is not an aspect.</p> <p><div id="attachment_239" class="wp-caption alignnone" style="width: 989px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-18.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-18.jpg" alt="Domain object - Choice" title="Domain object - Choice" width="979" height="744" class="size-full wp-image-239" /></a><p class="wp-caption-text">Domain object - Choice</p></div> Wow! Is that it? Without the annotations, it <p style="border: 3px solid rgb(243, 197, 52); padding: 5px; background-color: rgb(254, 254, 184); width: 600px; text-align: center;">[...Continue reading <a href="http://blog.lckymn.com/2009/05/17/roo-so-cool-03/">ROO So Cool!!! -03-</a>...]</p>]]></description>
			<content:encoded><![CDATA[<p>Continued from<br />
<a href="http://blog.lckymn.com/2009/05/17/roo-so-cool-02/" target="_blank">http://blog.lckymn.com/2009/05/17/roo-so-cool-02/</a></p>
<p>Now, let&#8217;s look at more interesting one that is the ROO generated source code!</p>
<p>As you can see, there are many AspectJ aspects in the <code>com.springsource.vote.domain</code> package. So I&#8217;ll firstly try to look at the <code>Choice</code> class which is not an aspect.</p>
<p><div id="attachment_239" class="wp-caption alignnone" style="width: 989px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-18.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-18.jpg" alt="Domain object - Choice" title="Domain object - Choice" width="979" height="744" class="size-full wp-image-239" /></a><p class="wp-caption-text">Domain object - Choice</p></div><br />
Wow! Is that it? Without the annotations, it consists of only two lines of code in the class.  Just two variable declarations.</p>
<p>So where are the others?</p>
<p>Check out the <code>Choice_Roo_Entity</code> aspect.<br />
<div id="attachment_240" class="wp-caption alignnone" style="width: 919px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-19.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-19.jpg" alt="Persistent Object (Aspect)" title="Persistent Object (Aspect)" width="909" height="424" class="size-full wp-image-240" /></a><p class="wp-caption-text">Persistent Object (Aspect)</p></div><br />
It appears to be a persistent object class with a persistence manager which means it includes data access logic. This sounds like normal <a href="http://www.martinfowler.com/eaaCatalog/activeRecord.html" target="_blank">Active Record</a> yet if you closer look at the code, it uses AspectJ&#8217;s inter-type declaration to add more attributes and behaviours to the domain object <code>Choice</code>.</p>
<pre class="brush: java; title: ; notranslate">
    @javax.persistence.Id
    @javax.persistence.GeneratedValue(strategy = javax.persistence.GenerationType.AUTO)
    @javax.persistence.Column(name = &quot;id&quot;)
    private java.lang.Long Choice.id;
</pre>
<p>This code above is declaring long type id variable to the type Choice to use as an identifier for OR mapping.  Because it is declared as a private variable, it is impossible to access it inside the code of Choice but possible only inside this <code>Choice_Roo_Entity</code> aspect.</p>
<p>What about the <code>Choice_Roo_JavaBean</code>.<br />
<div id="attachment_241" class="wp-caption alignnone" style="width: 922px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-20.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-20.jpg" alt="JavaBean (Aspect)" title="JavaBean (Aspect)" width="912" height="424" class="size-full wp-image-241" /></a><p class="wp-caption-text">JavaBean (Aspect)</p></div><br />
It has all the getters and setters for the <code>Choice</code> class and again inter-type declaration is used for adding these accessor methods.  So an instance of Choice type cannot only behave as a persistent object but also as a JavaBean object.  If you look into the jsp file, you can see it is used just like the methods belong to <code>Choice</code> class.<br />
In order to access the variables inside <code>Choice</code> object, the <code>Choice_Roo_JavaBean</code> is defined as <code>privileged</code> aspect.</p>
<pre class="brush: java; highlight: [1,4,8,12,16]; title: ; notranslate">
privileged aspect Choice_Roo_JavaBean {

    public java.lang.String Choice.getNamingChoice() {
        return this.namingChoice;
    }    

    public void Choice.setNamingChoice(java.lang.String namingChoice) {
        this.namingChoice = namingChoice;
    }    

    public java.lang.String Choice.getDescription() {
        return this.description;
    }    

    public void Choice.setDescription(java.lang.String description) {
        this.description = description;
    }    

}
</pre>
<p>So as shown above, <code>Choice_Roo_JavaBean</code> is a privileged aspect and therefore it can access <code>namingChoice</code> and <code>description</code> variables which are declared in <code>Choice</code>.</p>
<p>So what is it? It is a mixin.  <a href="http://en.wikipedia.org/wiki/Mixin" target="_blank">Mixin</a> is a class which provides a functionality to a subclass yet mixin itself is not supposed to stand alone.  So a class can collect its functionality by inheriting from one or more mixins through multiple inheritance.  However, as we all know, Java does not support multiple inheritance. So to use mixins in Java world, inter-type declarations in AspectJ can be used.</p>
<pre class="brush: java; highlight: [8,13]; title: ; notranslate">
privileged aspect Choice_Roo_Entity {

	(...)

    @javax.persistence.Id
    @javax.persistence.GeneratedValue(strategy = javax.persistence.GenerationType.AUTO)
    @javax.persistence.Column(name = &quot;id&quot;)
    private java.lang.Long Choice.id;    

    (...)

    public java.lang.Long Choice.getId() {
        return this.id;
    }
}
</pre>
<p>As seen in the aspect code above, a long type variable is added to the type Choice and a getId() method which returns a long type value that is the value in the variable, id, just added by the aspect. So an instance of Choice type can have getId() method even though it does not exist in the Choice class. Therefore, as mentioned, Choice type can have characteristics of both persistent object and JavaBean.  </p>
<p>AspectJ is also used to declare Choice type as a configurable type.<br />
<div id="attachment_242" class="wp-caption alignnone" style="width: 802px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-21.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-21.jpg" alt="Make Choice @Configurable" title="Make Choice @Configurable" width="792" height="172" class="size-full wp-image-242" /></a><p class="wp-caption-text">Make Choice @Configurable</p></div><br />
This code reveals that <code>Choice</code> type has <code>@org.springframework.beans.factory.annotation.Configurable</code> annotation.</p>
<pre class="brush: java; title: ; notranslate">
privileged aspect Choice_Roo_Configurable {

    declare @type: Choice: @org.springframework.beans.factory.annotation.Configurable;    

}
</pre>
<p>Next:<br />
<a href="http://blog.lckymn.com/2009/05/17/roo-so-cool-04/" target="_blank">http://blog.lckymn.com/2009/05/17/roo-so-cool-04/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lckymn.com/2009/05/17/roo-so-cool-03/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ROO So Cool!!! -02-</title>
		<link>http://blog.lckymn.com/2009/05/17/roo-so-cool-02/</link>
		<comments>http://blog.lckymn.com/2009/05/17/roo-so-cool-02/#comments</comments>
		<pubDate>Sun, 17 May 2009 01:01:45 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Spring Framework]]></category>
		<category><![CDATA[AJDT]]></category>
		<category><![CDATA[AspectJ]]></category>
		<category><![CDATA[AspectJ Development Tools]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Eclipse JEE]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Inter-type declarations]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaBean]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[M2Eclipse]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Maven Integration for Eclipse]]></category>
		<category><![CDATA[Maven2]]></category>
		<category><![CDATA[Mixin]]></category>
		<category><![CDATA[Multiple Inheritance]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring ROO]]></category>
		<category><![CDATA[SpringSource Tool Suite]]></category>
		<category><![CDATA[STS]]></category>

		<guid isPermaLink="false">http://blog.lckymn.com/?p=273</guid>
		<description><![CDATA[<p>Continued from <a href="http://blog.lckymn.com/2009/05/17/roo-so-cool-01/" target="_blank">http://blog.lckymn.com/2009/05/17/roo-so-cool-01/</a></p> <p>Let&#8217;s run this project to see what it looks like.</p> <p><div id="attachment_159" class="wp-caption alignnone" style="width: 833px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-09.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-09.jpg" alt="Run ROO Generated Application on Server" title="Run ROO Generated Application on Server" width="823" height="570" class="size-full wp-image-159" /></a><p class="wp-caption-text">Run ROO Generated Application on Server</p></div> Right click on the project -> Select the <code>Run As</code> option on the menu -> Select the <code>Run on Server</code>.</p> <p><div id="attachment_160" class="wp-caption alignnone" style="width: 626px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-10.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-10.jpg" alt="Choose Server" title="Choose Server" width="616" height="709" <p style="border: 3px solid rgb(243, 197, 52); padding: 5px; background-color: rgb(254, 254, 184); width: 600px; text-align: center;">[...Continue reading <a href="http://blog.lckymn.com/2009/05/17/roo-so-cool-02/">ROO So Cool!!! -02-</a>...]</p>]]></description>
			<content:encoded><![CDATA[<p>Continued from<br />
<a href="http://blog.lckymn.com/2009/05/17/roo-so-cool-01/" target="_blank">http://blog.lckymn.com/2009/05/17/roo-so-cool-01/</a></p>
<p>Let&#8217;s run this project to see what it looks like.</p>
<p><div id="attachment_159" class="wp-caption alignnone" style="width: 833px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-09.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-09.jpg" alt="Run ROO Generated Application on Server" title="Run ROO Generated Application on Server" width="823" height="570" class="size-full wp-image-159" /></a><p class="wp-caption-text">Run ROO Generated Application on Server</p></div><br />
Right click on the project -> Select the <code>Run As</code> option on the menu -> Select the <code>Run on Server</code>.</p>
<p><div id="attachment_160" class="wp-caption alignnone" style="width: 626px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-10.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-10.jpg" alt="Choose Server" title="Choose Server" width="616" height="709" class="size-full wp-image-160" /></a><p class="wp-caption-text">Choose Server</p></div><br />
Select <code>Choose an existing server</code> -> Select any <code>Servlet Container</code> or <code>JEE Server</code> on which you would like ROO generated application to run (If you do not have any available ones, install set it up first). -> Click the <code>Next</code> button.</p>
<p><div id="attachment_161" class="wp-caption alignnone" style="width: 628px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-11.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-11.jpg" alt="Click Finish to Run" title="Click Finish to Run" width="618" height="705" class="size-full wp-image-161" /></a><p class="wp-caption-text">Click Finish to Run</p></div><br />
Make sure <code>vote</code> project appears on the right-hand side and Click the <code>Finish</code> button.</p>
<p><div id="attachment_162" class="wp-caption alignnone" style="width: 913px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-12.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-12.jpg" alt="ROO Generated Application is Running." title="ROO Generated Application is Running." width="903" height="695" class="size-full wp-image-162" /></a><p class="wp-caption-text">ROO Generated Application is Running.</p></div><br />
Now it&#8217;s running.</p>
<p>I opened Firefox 3 to test it instead of using the built-in browser of Eclipse.<br />
Let&#8217;s create a new choice.</p>
<p><div id="attachment_163" class="wp-caption alignnone" style="width: 849px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-13.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-13.jpg" alt="Create New Choice (Firefox3)" title="Create New Choice (Firefox3)" width="839" height="688" class="size-full wp-image-163" /></a><p class="wp-caption-text">Create New Choice (Firefox3)</p></div><br />
Click the <code>Create New Choice</code> menu.</p>
<p><div id="attachment_164" class="wp-caption alignnone" style="width: 849px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-14.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-14.jpg" alt="Create New Choice Form" title="Create New Choice Form" width="839" height="586" class="size-full wp-image-164" /></a><p class="wp-caption-text">Create New Choice Form</p></div><br />
It displays the <code>Create New Choice</code> form.</p>
<p>Wait a minute! Is that a JavaScript (JS) error that <a href="http://getfirebug.com/" target="_blank">Firebug</a> complains?<br />
<div id="attachment_165" class="wp-caption alignnone" style="width: 851px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-15.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-15.jpg" alt="dojo JS Toolkit Error" title="dojo JS Toolkit Error" width="841" height="588" class="size-full wp-image-165" /></a><p class="wp-caption-text">dojo JS Toolkit Error</p></div><br />
Yes, it is but it looks like an error in <a href="http://dojotoolkit.org/" target="_blank">dojo</a> JS toolkit which Spring JS uses. Anyway, despite the error, it works fine.</p>
<p><div id="attachment_166" class="wp-caption alignnone" style="width: 849px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-16.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-16.jpg" alt="Fill in the Form -&gt; Save" title="Fill in the Form -&gt; Save" width="839" height="582" class="size-full wp-image-166" /></a><p class="wp-caption-text">Fill in the Form -> Save</p></div><br />
Quickly fill in the form. -> Click the <code>Save</code> button.</p>
<p><div id="attachment_167" class="wp-caption alignnone" style="width: 850px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-17.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-17.jpg" alt="New Choice Created" title="New Choice Created" width="840" height="588" class="size-full wp-image-167" /></a><p class="wp-caption-text">New Choice Created</p></div><br />
The entered data are added and a new Choice is created.</p>
<p>Next:<br />
<a href="http://blog.lckymn.com/2009/05/17/roo-so-cool-03/" target="_blank">http://blog.lckymn.com/2009/05/17/roo-so-cool-03/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lckymn.com/2009/05/17/roo-so-cool-02/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ROO So Cool!!! -01-</title>
		<link>http://blog.lckymn.com/2009/05/17/roo-so-cool-01/</link>
		<comments>http://blog.lckymn.com/2009/05/17/roo-so-cool-01/#comments</comments>
		<pubDate>Sun, 17 May 2009 01:00:26 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Spring Framework]]></category>
		<category><![CDATA[AJDT]]></category>
		<category><![CDATA[AspectJ]]></category>
		<category><![CDATA[AspectJ Development Tools]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Eclipse JEE]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Inter-type declarations]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[JavaBean]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[M2Eclipse]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Maven Integration for Eclipse]]></category>
		<category><![CDATA[Maven2]]></category>
		<category><![CDATA[Mixin]]></category>
		<category><![CDATA[Multiple Inheritance]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring ROO]]></category>
		<category><![CDATA[SpringSource Tool Suite]]></category>
		<category><![CDATA[STS]]></category>

		<guid isPermaLink="false">http://blog.lckymn.com/?p=146</guid>
		<description><![CDATA[<p>The end of the last month Spring Source released Spring ROO in alpha stage. My friend, <a href="http://stsmedia.net/" target="_blank">Dr. Stefan Schmidt</a>, who in fact used to teach me J2EE technology at UTS when I was a UTS student, has been working for Spring Source and is now involved in ROO development. Although ROO sounds really like Australian, it signifies Real Object-Oriented (ROO). After the release of the alpha version, Dr. Schmidt posted <a href="http://stsmedia.net/introducing-spring-roo/" target="_blank">an introductory tutorial of ROO</a> on <p style="border: 3px solid rgb(243, 197, 52); padding: 5px; background-color: rgb(254, 254, 184); width: 600px; text-align: center;">[...Continue reading <a href="http://blog.lckymn.com/2009/05/17/roo-so-cool-01/">ROO So Cool!!! -01-</a>...]</p>]]></description>
			<content:encoded><![CDATA[<p>The end of the last month Spring Source released Spring ROO in alpha stage.  My friend, <a href="http://stsmedia.net/" target="_blank">Dr. Stefan Schmidt</a>, who in fact used to teach me J2EE technology at UTS when I was a UTS student, has been working for Spring Source and is now involved in ROO development. Although ROO sounds really like Australian, it signifies Real Object-Oriented (ROO).  After the release of the alpha version, Dr. Schmidt posted <a href="http://stsmedia.net/introducing-spring-roo/" target="_blank">an introductory tutorial of ROO</a> on his blog.  He explained well so I could easily try this new mind-blowing technology. <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Let&#8217;s start a journey!</p>
<p>-Check your maven and JVM versions.</p>
<pre class="brush: bash; gutter: false; title: ; notranslate">
$ mvn --version
Maven version: 2.0.9
Java version: 1.6.0_13
OS name: &quot;linux&quot; version: &quot;2.6.28-11-generic&quot; arch: &quot;amd64&quot; Family: &quot;unix&quot;
</pre>
<p>- I&#8217;m using Ubuntu Linux 9.04 Jaunty Jackalope desktop edition 64bit and installed Sun JDK &amp; Maven2 from its repository.</p>
<p>-Extract <code>spring-roo-1.0.0.A2.zip</code> file to <code>/somepath/roo-1.0.0.A2</code><br />
-Add the environment variable ROO_HOME with the path of Roo home in the <code>.bashrc</code> file.<br />
-Add $ROO_HOME/bin to PATH in the <code>.bashrc</code> file.<br />
e.g.)</p>
<pre class="brush: bash; gutter: false; title: ; notranslate">
export ROO_HOME=/opt/lib/spring/roo-1.0.0.A2
PATH=${PATH}:$ROO_HOME/bin

export PATH
</pre>
<p>For Eclipse,<br />
-Extract <code>sts-roo-integration-1.0.0.A2.zip</code> file to the <code>eclipse/dropins</code> folder to use Spring ROO integration.<br />
This copying to the dropins directory only works for Eclipse Ganymede.</p>
<p>-Install ROO packages in the maven repository.</p>
<pre class="brush: bash; gutter: false; title: ; notranslate">
mvn install:install-file -DgroupId=org.springframework.roo \
  -DartifactId=roo-annotations -Dversion=1.0.0.A2 -Dpackaging=jar \
  -Dfile=$ROO_HOME/dist/roo-annotations-1.0.0.A2.jar
</pre>
<p>-Result</p>
<pre class="brush: bash; gutter: false; title: ; notranslate">
$ mvn install:install-file -DgroupId=org.springframework.roo \
       -DartifactId=roo-annotations -Dversion=1.0.0.A2 -Dpackaging=jar \
       -Dfile=$ROO_HOME/dist/roo-annotations-1.0.0.A2.jar
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [install:install-file] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [install:install-file]
[INFO] Installing /opt/lib/spring/roo-1.0.0.A2/dist/roo-annotations-1.0.0.A2.jar to /home/blade2/.m2/repository/org/springframework/roo/roo-annotations/1.0.0.A2/roo-annotations-1.0.0.A2.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Tue May 05 22:09:23 EST 2009
[INFO] Final Memory: 7M/165M
[INFO] ------------------------------------------------------------------------
</pre>
<p>-Now starts ROO console!</p>
<pre class="brush: bash; gutter: false; title: ; notranslate">
$ mkdir roo_test
$ cd roo_test/
$ roo.sh
</pre>
<div id="attachment_149" class="wp-caption alignnone" style="width: 801px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-00.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-00.jpg" alt="ROO Console" title="ROO Console" width="791" height="583" class="size-full wp-image-149" /></a><p class="wp-caption-text">ROO Console</p></div>
<p>-Create a project directory for a ROO project.</p>
<pre>
roo&gt; script vote.roo
(... wait until ROO console does it's job...)
roo&gt; exit
</pre>
<p>Instead of following the script that Dr. Schmidt provided, I just used <code>vote.roo</code> which can be found in the <code>samples</code> directory. Well no special reasons, it just looks simpler. That&#8217;s it. <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   If you are seeking more interesting one, you&#8217;d better try the one on the blog of Dr. Schmidt and then try your own one. ^O^</p>
<p>-In order to import the ROO project, just created, to Eclipse (STS), run maven2&#8242;s eclipse plug-in.</p>
<pre class="brush: bash; gutter: false; title: ; notranslate">
$ mvn eclipse:eclipse
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'eclipse'.
[INFO] ------------------------------------------------------------------------
[INFO] Building vote
[INFO]    task-segment: [eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing eclipse:eclipse
Downloading:
... lots of dependencies including spring framework 3.0.0.M2 ...

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 minutes 26 seconds
[INFO] Finished at: Tue May 05 22:32:18 EST 2009
[INFO] Final Memory: 31M/353M
[INFO] ------------------------------------------------------------------------
</pre>
<p>Well, although it says</p>
<blockquote><p>
Sources for some artifacts are not available.<br />
Javadoc for some artifacts is not available.
</p></blockquote>
<p>it is not that important unless I really want to see the missing source code and Javadoc of the artifacts listed with the message.</p>
<p>If you want to get it, add <code>-DdownloadSources=true  -DdownloadJavadocs=true</code> options and run maven again.</p>
<pre class="brush: bash; gutter: false; title: ; notranslate">
$ mvn eclipse:eclipse -DdownloadSources=true  -DdownloadJavadocs=true
</pre>
<p><del datetime="2009-05-17T17:36:05+00:00">I&#8217;m not sure if the source is available though.</del> <del datetime="2009-05-21T13:38:58+00:00">The source code is not available at the moment though.</del> I was wrong. The source code is available. Check this out. <a href="http://forum.springsource.org/showthread.php?t=71985" target="_blank">http://forum.springsource.org/showthread.php?t=71985</a></p>
<p>-Now run Eclipse. Since ROO is a part of Spring Framework, I&#8217;m using SpringSource Tool Suite (STS) for this practice.</p>
<div id="attachment_150" class="wp-caption alignnone" style="width: 511px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-01.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-01.jpg" alt="SpringSource Tool Suite" title="SpringSource Tool Suite" width="501" height="341" class="size-full wp-image-150" /></a><p class="wp-caption-text">SpringSource Tool Suite</p></div>
<p>Well, before I go further, here are what I am using.<br />
*SpringSource Tool Suite (STS) 2.0.0</p>
<ul>
<li>Apart from all the Spring related plug-ins that STS comes with, it also comes with several good plug-ins such as AspectJ Development Tools (AJDT), <a href="http://pmd.sourceforge.net/integrations.html#eclipse" target="_blank">PMD for Eclipse</a> (Java source code analyser) and EclEmma (Code Coverage Tool) which are what I usually install when I use pure Eclipse JEE.</li>
</ul>
<p>*Eclipse Plug-ins</p>
<ul>
<li>Subclipse</li>
<li>Maven Integration for Eclipse (M2Eclipse)</li>
<li>Aptana</li>
<li>JDepend (Java source code analyser)</li>
<li>Copy Fully Qualified Class Name Plugin</li>
<li>Resource Bundle Editor</li>
<li>and of course Spring ROO Integration for Eclipse (I heard a new STS will include it).</li>
</ul>
<p>However, what are really required for this ROO practice are Eclipse JEE, Spring IDE, AJDT, M2Eclipse and Spring ROO Integration. Or you can simply use STS and install M2Eclipse and Spring ROO Integration.  If you use Eclipse JEE Ganymede and install Spring IDE, it will automatically install AJDT as a dependency of Spring IDE since Ganymede has a smart software &amp; add-ons update manager. <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>(Good News: A free version of STS is released. Check this out<br />
<a href="http://blog.springsource.com/2009/05/07/springsource-tool-suite-now-free/" target="_blank">SpringSource Tool Suite now free</a>).</p>
<p><div id="attachment_151" class="wp-caption alignnone" style="width: 916px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-02.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-02.jpg" alt="Import ROO project" title="Import ROO project" width="906" height="693" class="size-full wp-image-151" /></a><p class="wp-caption-text">Import ROO project</p></div><br />
Right click on the project explorer -> Select <code>Import</code></p>
<p><div id="attachment_152" class="wp-caption alignnone" style="width: 920px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-03.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-03.jpg" alt="Existing Projects into Workspace" title="Existing Projects into Workspace" width="910" height="699" class="size-full wp-image-152" /></a><p class="wp-caption-text">Existing Projects into Workspace</p></div><br />
Expand the <code>General</code> entry -> Select <code>Existing Projects into Workspace</code> -> Click the <code>Next</code> button.</p>
<p><div id="attachment_153" class="wp-caption alignnone" style="width: 919px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-04.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-04.jpg" alt="Select Project to Import" title="Select Project to Import" width="909" height="696" class="size-full wp-image-153" /></a><p class="wp-caption-text">Select Project to Import</p></div><br />
Browse the roo project directory created by roo. In my case it&#8217;s <code>roo_test</code> -> Click the <code>Finish</code> button.<br />
(NOTE: Because I created the roo project directory inside the workspace of Eclipse (STS), I don&#8217;t need to check <code>Copy projects into workspace</code> option.)</p>
<p><div id="attachment_154" class="wp-caption alignnone" style="width: 919px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-05.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-05.jpg" alt="Turn AJDT&#039;s Weaving Service on" title="Turn AJDT&#039;s Weaving Service on" width="909" height="696" class="size-full wp-image-154" /></a><p class="wp-caption-text">Turn AJDT's Weaving Service on</p></div><br />
If Eclipse asks to turn on weaving service function of AJDT, Click the <code>Yes</code> button.</p>
<p><div id="attachment_155" class="wp-caption alignnone" style="width: 919px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-06.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-06.jpg" alt="Restart STS (Eclipse)" title="Restart STS (Eclipse)" width="909" height="696" class="size-full wp-image-155" /></a><p class="wp-caption-text">Restart STS (Eclipse)</p></div><br />
Restart Eclipse.</p>
<p><div id="attachment_156" class="wp-caption alignnone" style="width: 477px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-07_01.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-07_01.jpg" alt="Dependency Problems" title="Dependency Problems" width="467" height="698" class="size-full wp-image-156" /></a><p class="wp-caption-text">Dependency Problems</p></div><br />
Eclipse is restarted and there are errors in the project as the require dependencies are not in the project directory.</p>
<p>So now, let M2Eclipse resolves this dependency problem. That&#8217;s why I&#8217;m using this plug-in. I want to focus on real problems in software development rather than focusing on providing dependency libraries for development.</p>
<p><div id="attachment_157" class="wp-caption alignnone" style="width: 804px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-07_02.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-07_02.jpg" alt="Let M2Eclipse Resolves Dependencies" title="Let M2Eclipse Resolves Dependencies" width="794" height="708" class="size-full wp-image-157" /></a><p class="wp-caption-text">Let M2Eclipse Resolves Dependencies</p></div><br />
Right click on the project -> Select the <code>Maven</code> option on the menu -> Select the <code>Enable Dependency Management</code>.<br />
Wait until it does its job.</p>
<p><div id="attachment_158" class="wp-caption alignnone" style="width: 475px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-08.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2009/05/roo-08.jpg" alt="Dependency Problems Solved" title="Dependency Problems Solved" width="465" height="699" class="size-full wp-image-158" /></a><p class="wp-caption-text">Dependency Problems Solved</p></div><br />
As shown here, Maven resolved it so all the required dependencies are there.</p>
<p>Next:<br />
<a href="http://blog.lckymn.com/2009/05/17/roo-so-cool-02/" target="_blank">http://blog.lckymn.com/2009/05/17/roo-so-cool-02/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lckymn.com/2009/05/17/roo-so-cool-01/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

