<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Rishi's Technology Blog</title>
	<atom:link href="http://rishikhare.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://rishikhare.wordpress.com</link>
	<description>about Java and Java Universe..</description>
	<lastBuildDate>Tue, 10 Nov 2009 08:20:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='rishikhare.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Rishi's Technology Blog</title>
		<link>http://rishikhare.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://rishikhare.wordpress.com/osd.xml" title="Rishi&#039;s Technology Blog" />
	<atom:link rel='hub' href='http://rishikhare.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Writing Add Ons for Spring Roo Framework &#8211; 1- Hello World</title>
		<link>http://rishikhare.wordpress.com/2009/11/10/writing-add-ons-for-spring-roo-framework-1-hello-world/</link>
		<comments>http://rishikhare.wordpress.com/2009/11/10/writing-add-ons-for-spring-roo-framework-1-hello-world/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 08:08:54 +0000</pubDate>
		<dc:creator>rishikhare</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rishikhare.wordpress.com/?p=20</guid>
		<description><![CDATA[Roo is a code generation framework by springsource . It lets you build java enterprise quality code with productivity of rails (sometimes even more through scripts) .  you can learn more about roo here. while spring roo is still in RC3,  it has generated so much buzz and developer community is looking a way to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rishikhare.wordpress.com&amp;blog=5252450&amp;post=20&amp;subd=rishikhare&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Roo is a code generation framework by springsource . It lets you build java enterprise quality code with productivity of rails (sometimes even more through scripts) .  you can learn more about roo <a title="Spring roo" href="http://www.springsource.org/roo" target="_blank">here</a>.</p>
<p>while spring roo is still in RC3,  it has generated so much buzz and developer community is looking a way to write addons.</p>
<p>in this series I am going to present how to write a add on for spring roo framework.</p>
<p>Please note that this is my learning from the roo source code and cloud foundry plugin for roo by springsource (thanks to <a title="Ben " href="http://twitter.com/benalexau" target="_blank">ben </a>for all the help),  and by no means it is complete. there would be more documentation from roo team for this, but till then this can be a starting point.</p>
<p><strong>1. Setting up the Dev Environment</strong></p>
<p>1. Download the roo source code through svn from springsource repository. here is the link , please use the trunk because addons are supported only from 1.0.0.RC3 onwards only, which you will find only in trunk.</p>
<p>https://anonsvn.springframework.org/svn/spring-roo/trunk</p>
<p>best is to use eclipse with SVN addon.</p>
<p>(this is only till RC3 is release, once this or higher are released, you can just include the all the jars in the dist folders of ROO in your classpath while building your addon).</p>
<p>2. lets say you donwload them to c:\spring-roo directory.</p>
<p>3. setup maven from command line, or from eclipse via plugin. (this is needed for building the ROO from source, not for plugin as of now)</p>
<p>4.run the following maven command from you spring-roo directory.</p>
<p>mvn clean eclipse:clean eclipse:eclipse compile</p>
<p>It will take sometime, download some stuff from net and build the project. This sets up your project for eclipse.</p>
<p>Import this in your eclipse via new Project-&gt;General-&gt; route. (only if you have checked out from command line svn)</p>
<p>in eclipse, right click on the project and allow maven to manage dependencies and also enable nested modules for this project.</p>
<p>5.  go to spring-roo/bootstrap/target directory.</p>
<p>there is a file named roo_classpath.txt (in windows it would be looking like this ${env.ROO_CLASSPATH_FILE} , just rename it to roo_classpath.txt).</p>
<p>at the runtime roo-dev (dev version of roo) needs to know the classpath, it reads from this file.</p>
<p>6.write a small bat or sh file with this command. lets call it roo-dev-env.bat</p>
<p>set ROO_CLASSPATH_FILE=c:\spring-roo\bootstrap\roo_classpath.txt<br />
set PATH=%PATH%;c:\spring-roo\bootstrap\;</p>
<p><strong>2. Writing the Addon</strong></p>
<p>our target is to write just a hello world plugin, we give a hello command to roo, and it prints hello world to us. <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>1. create a new java project in eclipse.  call it addon-hello.</p>
<p>2. add the spring-roo project (created above from trunk of roo), as a referenced project. (via eclipse : right click on project -&gt; properties-&gt;projects), this will make all the source and classes of Roo available for us in our addon.</p>
<p>3. in src folder create a new package lets say</p>
<p>com.rishi.roo.helloaddon</p>
<p>(the packages should be of the format &#8220;com.**.roo.,org.**.roo.,net.**.roo.&#8221; ) this is because roo scans packages for annotation processing for this pattern only.</p>
<p>now create a simple class called HelloCommands, it looks like this.</p>
<p><span style="color:#800080;"><strong>package</strong> </span>com.rishi.roo.helloaddon;</p>
<p><span style="color:#800080;"><strong>import</strong> </span>org.springframework.roo.shell.CliCommand;</p>
<p><span style="color:#800080;"><strong>import</strong> </span>org.springframework.roo.shell.CommandMarker;</p>
<p><span style="color:#800080;"><strong>import</strong> </span>org.springframework.roo.support.lifecycle.ScopeDevelopmentShell;</p>
<p>@ScopeDevelopmentShell</p>
<p><span style="color:#800080;"><strong>public</strong> <strong>class</strong></span> HelloCommands <span style="color:#800080;"><strong>implements</strong></span> CommandMarker{</p>
<p>@CliCommand(help=&#8221;<span style="color:#3366ff;">prints a hello world message</span>&#8220;, value=&#8221;<span style="color:#3366ff;">hello world</span>&#8220;)</p>
<p><span style="color:#800080;"><strong>public</strong></span> String helloGwt(){</p>
<p><strong> <span style="color:#800080;"> return</span></strong> &#8220;<span style="color:#3366ff;">Hello World from hello addon for spring roo</span>&#8220;;</p>
<p>}</p>
<p>}</p>
<p>lets understand the code,</p>
<pre>@ScopeDevelopmentShell</pre>
<p>This annotations Indicates a class that should be instantiated when the ROO development Shell  is used.</p>
<pre>
<pre>
<pre>CommandMarker</pre>
</pre>
</pre>
<p>this is a marker interface for roo, letting it know which all classes contain commands for Roo.</p>
<pre>
<pre>
<pre>@CliCommand</pre>
</pre>
</pre>
<p>This annotation is used for specifying a command, and invokes the method on which it is decorated,</p>
<p>when the command is executed.</p>
<p>value options specifies the command, while the help specifies the help message for it.</p>
<p>value is a String[], which means more then one command can invoke the same method.</p>
<p>if you want to pass an argument to the command you can use @CliOption annotation in the argument of method).</p>
<p>more on this later</p>
<p>rest is a simple method, where we return a message on invocation.</p>
<p>5.  now open spring-roo\bootstrap\roo_classpath.txt file and edit to add the output folder of addon-hello (usually it would be addon-hello/bin) at the end to the file.</p>
<p>6. go to spring-roo folder and execute the bat file which we created above (roo-dev-env.bat).</p>
<p>7. execute command roo-dev</p>
<p>roo-dev should happily load like this :</p>
<pre>C:\work\roo\spring-roo&gt;roo-dev
 ____  ____  ____
 / __ \/ __ \/ __ \
 / /_/ / / / / / / /
 / _, _/ /_/ / /_/ /
/_/ |_|\____/\____/    ENGINEERING BUILD [rev 406M]

Welcome to Spring Roo. For assistance press TAB or type "hint" then hit ENTER.
roo&gt;</pre>
<p>8. now type only hello in roo shell and hit the tab , it would automatically complete it to &#8220;hello world&#8221;, hit enter</p>
<pre>roo&gt; hello world
Hello World from hello addon for spring roo
roo&gt;</pre>
<p>Yay, your hello world addon for roo is working now.:)</p>
<p>this is just the starting, I would be adding more details about how to write a meaningful addon. use different services of Roo like MetaDataService etc.</p>
<p>thanks springsource for creating roo <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rishikhare.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rishikhare.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rishikhare.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rishikhare.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rishikhare.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rishikhare.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rishikhare.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rishikhare.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rishikhare.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rishikhare.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rishikhare.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rishikhare.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rishikhare.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rishikhare.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rishikhare.wordpress.com&amp;blog=5252450&amp;post=20&amp;subd=rishikhare&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rishikhare.wordpress.com/2009/11/10/writing-add-ons-for-spring-roo-framework-1-hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2b53650d684d480014f84eea344276b5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rishikhare</media:title>
		</media:content>
	</item>
	</channel>
</rss>
