<?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>Armbruster IT Blog &#187; grails</title>
	<atom:link href="http://blog.armbruster-it.de/tag/grails/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.armbruster-it.de</link>
	<description>Real world fun with Java, Grails, Groovy, Zope, Plone, Linux and much others.</description>
	<lastBuildDate>Fri, 30 Jul 2010 17:09:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Grails Neo4j plugin 0.3 released</title>
		<link>http://blog.armbruster-it.de/2010/07/grails-neo4j-plugin-0-3-released/</link>
		<comments>http://blog.armbruster-it.de/2010/07/grails-neo4j-plugin-0-3-released/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 17:09:46 +0000</pubDate>
		<dc:creator>Stefan Armbruster</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[neo4j]]></category>

		<guid isPermaLink="false">http://blog.armbruster-it.de/?p=159</guid>
		<description><![CDATA[Today I released an update of the Grails Neo4j plugin (http://www.grails.org/plugin/neo4j). The main changes are:

compatibility with Grails 1.3.x. Be aware, Grails 1.3 &#8211; 1.3.3 are suffering from http://jira.codehaus.org/browse/GRAILS-6427, so either use Grails 1.2.x, or be brave and use a recent git build of Grails 1.3.4.SNAPSHOT.
usage of Neo4j 1.1 (released today just a few hours ago, [...]]]></description>
			<content:encoded><![CDATA[<p>Today I released an update of the Grails Neo4j plugin (<a href="http://www.grails.org/plugin/neo4j">http://www.grails.org/plugin/neo4j</a>). The main changes are:</p>
<ul>
<li>compatibility with Grails 1.3.x. Be aware, Grails 1.3 &#8211; 1.3.3 are suffering from <a href="http://jira.codehaus.org/browse/GRAILS-6427">http://jira.codehaus.org/browse/GRAILS-6427</a>, so either use Grails 1.2.x, or be brave and use a recent git build of Grails 1.3.4.SNAPSHOT.</li>
<li>usage of Neo4j 1.1 (released today just a few hours ago, so get it while it&#8217;s hot).</li>
</ul>
<p>All changes:</p>
<ul>
<li>[GRAILSPLUGINS-2302] &#8211; &#8220;home&#8221; link broken in the org.codehaus.groovy.grails.plugins.neo4j.Neo4jController views</li>
<li>[GRAILSPLUGINS-2303] &#8211; Problems with annotation Neo4jEntity</li>
<li>[GRAILSPLUGINS-2345] &#8211; upgrade to Neo4j 1.1</li>
<li>[GRAILSPLUGINS-2346] &#8211; &lt;domainclass&gt;.get() throws exception if id is not invalid</li>
<li>[GRAILSPLUGINS-2347] &#8211; &lt;domainClass&gt;.findAllBy&lt;Field&gt;(value) fails</li>
<li>[GRAILSPLUGINS-2349] &#8211; provide compatibility for Grails 1.3.x</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.armbruster-it.de/2010/07/grails-neo4j-plugin-0-3-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>getting a list of all i18n properties used in a Grails application</title>
		<link>http://blog.armbruster-it.de/2010/07/getting-a-list-of-all-i18n-properties-used-in-a-grails-application/</link>
		<comments>http://blog.armbruster-it.de/2010/07/getting-a-list-of-all-i18n-properties-used-in-a-grails-application/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 19:43:45 +0000</pubDate>
		<dc:creator>Stefan Armbruster</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[i18n]]></category>

		<guid isPermaLink="false">http://blog.armbruster-it.de/?p=152</guid>
		<description><![CDATA[You might know this situation: in a project you start by hacking code that uses i18n properties instead of fixed strings in order to support multiple languages. The normal process in Grails is to use the g:message tag in controllers or gsp templates. Side by side you append the new introduced i18n property with some [...]]]></description>
			<content:encoded><![CDATA[<p>You might know this situation: in a project you start by hacking code that uses i18n properties instead of fixed strings in order to support multiple languages. The normal process in Grails is to use the <a href="http://grails.org/doc/latest/ref/Tags/message.html">g:message</a> tag in controllers or gsp templates. Side by side you append the new introduced i18n property with some value in your messsages.properties file.</p>
<p>When support for a new language is requested, all you have to do is translating messages.properties. So far so good &#8211; this make i18n really easy.</p>
<p>But: when the project evolves, there&#8217;s a good chance that some of your i18n properties in messages.properties gets orphaned. Assume you remove a block of code from a gsp. It happens often that the i18n properties used in this block are not removed from messages*.properties because at some point you are not sure if it is referenced elsewhere. So what would be really useful here would be a list of all referenced i18n properties from your *.groovy/*.gsp files.</p>
<p>Doing so is pretty easy, just add a new <a href="http://grails.org/doc/latest/guide/4.%20The%20Command%20Line.html">gant script</a> to your Grails application&#8217;s script folder, let&#8217;s name it i18nList.groovy. This script basically contains:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">includeTargets <span style="color: #66cc66;">&lt;&lt;</span> grailsScript<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Init&quot;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
target<span style="color: #66cc66;">&#40;</span>main: <span style="color: #ff0000;">&quot;create a list of all i18n properties used in groovy code and gsp templates&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">def</span> properties <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">File</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #FFCC33;">eachFileRecurse</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">file</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">switch</span> <span style="color: #66cc66;">&#40;</span>it<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #b1b100;">case</span> ~/.<span style="color: #66cc66;">*</span>\.<span style="color: #006600;">groovy</span>/:
                    <span style="color: #000000; font-weight: bold;">def</span> matcher <span style="color: #66cc66;">=</span> it.<span style="color: #006600;">text</span> <span style="color: #66cc66;">=</span>~ /code:\s<span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;'](.*?)[&quot;</span><span style="color: #ff0000;">']/
                    matcher.each { properties &lt;&lt; it[1] }
                    break
                case ~/.*<span style="color: #000099; font-weight: bold;">\.</span>gsp/:
                    def matcher = it.text =~ /code=[&quot;'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;']/
                    matcher.each { properties &lt;&lt; it[1] }
                    break
            }
        }
    }
    println properties.sort().unique().join(&quot;</span>\n<span style="color: #ff0000;">&quot;)
&nbsp;
}
&nbsp;
setDefaultTarget(main)</span></pre></div></div>

<p>(sorry the color coding seems to fail for some Groovy regexes) The script recursivly iterates over all *.groovy and *.gsp files in your project and extract the part after the &#8216;code&#8217; attribute of the message tag using a regex. The regex result are collected into an array. This array is sorted, unique&#8217;d and printed to the console. That&#8217;s it.</p>
<p>One word of caution: this gant script &#8216;works for me&#8217;. So depending on your code, you might notice that the used regex are not sufficient or even fail. Feel free to modify them for your needs, even better send back your modifications.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.armbruster-it.de/2010/07/getting-a-list-of-all-i18n-properties-used-in-a-grails-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grails Webdav Plugin 0.3 released</title>
		<link>http://blog.armbruster-it.de/2010/05/grails-webdav-plugin-0-3-released/</link>
		<comments>http://blog.armbruster-it.de/2010/05/grails-webdav-plugin-0-3-released/#comments</comments>
		<pubDate>Sun, 30 May 2010 21:30:05 +0000</pubDate>
		<dc:creator>Stefan Armbruster</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[webdav]]></category>

		<guid isPermaLink="false">http://blog.armbruster-it.de/?p=148</guid>
		<description><![CDATA[Today I&#8217;ve released a minor update to the Grails Webdav plugin. Compared with the previous version a few bugs have been fixed.
]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;ve released a minor update to the <a href="http://www.grails.org/plugin/webdav">Grails Webdav plugin</a>. Compared with the previous version <a href="http://jira.codehaus.org/secure/ReleaseNote.jspa?projectId=11450&amp;version=15610">a few bugs have been fixed</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.armbruster-it.de/2010/05/grails-webdav-plugin-0-3-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>new Grails plugin released: modproxybalancer</title>
		<link>http://blog.armbruster-it.de/2010/05/new-grails-plugin-released-modproxybalancer/</link>
		<comments>http://blog.armbruster-it.de/2010/05/new-grails-plugin-released-modproxybalancer/#comments</comments>
		<pubDate>Tue, 25 May 2010 12:18:31 +0000</pubDate>
		<dc:creator>Stefan Armbruster</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[loadbalancing]]></category>

		<guid isPermaLink="false">http://blog.armbruster-it.de/?p=143</guid>
		<description><![CDATA[Last week I attended the gr8conf, a really great conference. One of my favorite event was the Hackergarden. In the evening after the regular talks ~30+ people came together (should I call them nerds?), split up into small groups and did some hacking on Groovy &#38; Grails related topics. I found myself together with Davide [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I attended the <a href="http://eu.gr8conf.org">gr8conf</a>, a really great conference. One of my favorite event was the Hackergarden. In the evening after the regular talks ~30+ people came together (should I call them nerds?), split up into small groups and did some hacking on Groovy &amp; Grails related topics. I found myself together with Davide Rossi to do some coding on deploying a Grails application to multiple tomcat nodes and manage a loadbalancer in front of them. The original goal was to finish the task at end of evening. Unfortunately we set our goal too high, and did not manage to release some code at that evening. During the last weekend I took some time to finish this and did a <a href="http://grails.org/plugin/modproxybalancer">release today</a>.</p>
<p><a href="http://grails.org/plugin/modproxybalancer">This plugin</a>&#8217;s goal is to simplify the deployment of a grails application  to a cluster consisting of multiple tomcat instances and an Apache httpd mod_proxy_balancer.</p>
<p>It assumes  you have an <a href="http://httpd.apache.org/docs/2.1/mod/mod_proxy_balancer.html" target="blank">Apache mod_proxy_balancer</a> running in front of  multiple tomcat instances in order to provide a) high-availability and b) load-balancing to your Grails  application. In such a scenario, upgrading the running application to a newer release is painful and error-prone when done manually. This plugin&#8217;s goal is to  simplify that procedure by performing a &#8220;rolling upgrade&#8221;. Calling &#8216;grails tomcat redeploy&#8217; performs these  actions:</p>
<ol>
<li>take first node offline in loadbalancer</li>
<li>undeploy app on first tomcat node</li>
<li>deploy app on first tomcat node</li>
<li>check if app responds on first tomcat node</li>
<li>take first node online in loadbalancer</li>
<li>proceed the same procedure with next node</li>
</ol>
<p>To solve this, we&#8217;ve forked the 1.3.1 release of the tomcat plugin an added the following capabilities:</p>
<ol>
<li>deploying to multiple hosts and</li>
<li>emitting lifecycle events: PreDeploy, PostDeploy, PreUndeploy,  PostUndeploy</li>
<li>provide support for &#8216;grails tomcat redeploy&#8217;</li>
</ol>
<p>These changes have been included in a pull request to the upstream plugin, so I&#8217;m hoping they will find their way into Grails 1.3.2.</p>
<p>The rest of the work has been put into the modproxybalancer plugin, taking care of remote controlling the loadbalancer  by catching up these events. mod_proxy_balancer comes  with a simple management frontend called balancer-manager. This consists of  some simple HTML forms that can be easily triggered using htmlunit. When the forked tomcat plugin emits a &#8220;PreUndeploy&#8221; event, the loadbalancer disables the respective tomcat node, then a normal undeploy und deploy happens. After this, the freshly deployed tomcat is checked for availablity and taken back online in the loadbalancer.</p>
<p>The  plugin is licensend under the <a href="http://sam.zoy.org/wtfpl/" target="blank">WTFPL.</a></p>
<p>Side note: this is my first Grails plugin with it&#8217;s <a href="http://github.com/sarmbruster/grails-modproxybalancer-plugin">sources</a> residing on github.com. Thanks to <a href="http://www.cacoethes.co.uk/blog/groovyandgrails/github-pages-publish-your-grails-plugin-docs">Peter Ledbrook&#8217;s excellent blog post</a>, I was able to use GitHub pages for the documentation.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.armbruster-it.de/2010/05/new-grails-plugin-released-modproxybalancer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>restrict a Grails controller to localhost access only</title>
		<link>http://blog.armbruster-it.de/2010/04/restrict-a-grails-controller-to-localhost-access-only/</link>
		<comments>http://blog.armbruster-it.de/2010/04/restrict-a-grails-controller-to-localhost-access-only/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 13:47:38 +0000</pubDate>
		<dc:creator>Stefan Armbruster</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://blog.armbruster-it.de/?p=137</guid>
		<description><![CDATA[A common requirement for many web applications is that some parts (aka controllers) should only be accessible from specifc ip addresses. Typically controllers doing some administrative or maintenance work must be protected from non-authroized access. The most complete solution for this is using a full blown security framework like the Grails Acegi plugin. But there&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>A common requirement for many web applications is that some parts (aka controllers) should only be accessible from specifc ip addresses. Typically controllers doing some administrative or maintenance work must be protected from non-authroized access. The most complete solution for this is using a full blown security framework like the <a href="http://www.grails.org/plugin/acegi">Grails Acegi plugin</a>. But there&#8217;s also a lean and quick solution for this in Grails: use a <a href="http://www.grails.org/doc/latest/guide/6.%20The%20Web%20Layer.html#6.1.5%20Controller%20Interceptors">controller interceptor</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> beforeInterceptor <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;127.0.0.1&quot;</span>, <span style="color: #ff0000;">&quot;0:0:0:0:0:0:0:1&quot;</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #CC0099;">contains</span><span style="color: #66cc66;">&#40;</span>request.<span style="color: #006600;">remoteAddr</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      render<span style="color: #66cc66;">&#40;</span>status: <span style="color: #cc66cc;">401</span>, text: <span style="color: #ff0000;">'Access limited to localhost'</span><span style="color: #66cc66;">&#41;</span>
      <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">false</span>
   <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Grails calls the beforeIntereceptor closure prior every action in a controller. Only if it returns true, the action is executed. In the code above if the client has a non-local IP address, a 401 error is returned with an error message. Note that localhost in IPv6 is 0:0:0:0:0:0:0:1, so it work both in IPv4 and IPv6 networks.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.armbruster-it.de/2010/04/restrict-a-grails-controller-to-localhost-access-only/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Grails Neo4j plugin 0.2.1 released</title>
		<link>http://blog.armbruster-it.de/2010/04/grails-neo4j-plugin-0-2-1-released/</link>
		<comments>http://blog.armbruster-it.de/2010/04/grails-neo4j-plugin-0-2-1-released/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 10:08:11 +0000</pubDate>
		<dc:creator>Stefan Armbruster</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[neo4j]]></category>

		<guid isPermaLink="false">http://blog.armbruster-it.de/?p=130</guid>
		<description><![CDATA[Today I released a minor update of the Grails Neo4j plugin. The changes are:

performance improvement by no longer calling map constructor in createInstanceForNode
fixed transaction handling by replacing interceptor with a &#8220;real&#8221; servlet filter
support for primitve arrays as properties in domain classes
bugfix: handling of bidirectional many-to-many relationships
bugfix: setProperties does no longer null out properties that have [...]]]></description>
			<content:encoded><![CDATA[<p>Today I released a minor update of the <a href="http://www.grails.org/plugin/neo4j">Grails Neo4j plugin</a>. The changes are:</p>
<ul>
<li>performance improvement by no longer calling map constructor in createInstanceForNode</li>
<li>fixed transaction handling by replacing interceptor with a &#8220;real&#8221; servlet filter</li>
<li>support for primitve arrays as properties in domain classes</li>
<li>bugfix: handling of bidirectional many-to-many relationships</li>
<li>bugfix: setProperties does no longer null out properties that have not been set</li>
<li>support for encodeAsXXXX methods from CodecsGrailsPlugin. In previous versions encoding did not work, since the &#8216;node&#8217;<br />
property of the domain classes could not be encoded (it&#8217;s a neo4j internal class!). Workaround: add getNode()==null method<br />
in AST transformation.</li>
</ul>
<p>Everyone using the 0.2 release is recommended to upgrade.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.armbruster-it.de/2010/04/grails-neo4j-plugin-0-2-1-released/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Grails Neo4j plugin 0.2 released</title>
		<link>http://blog.armbruster-it.de/2010/03/grails-neo4j-plugin-0-2-released/</link>
		<comments>http://blog.armbruster-it.de/2010/03/grails-neo4j-plugin-0-2-released/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 16:15:22 +0000</pubDate>
		<dc:creator>Stefan Armbruster</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[neo4j]]></category>

		<guid isPermaLink="false">http://blog.armbruster-it.de/?p=87</guid>
		<description><![CDATA[Today an important update of the Grails Neo4j plugin has been released. Neo4j is a graph database, it&#8217;s main concepts are described in brevity in a previous post.  The plugin provides a convenient way to use Neo4j as a persistence layer for Grails domain classes.
The key features / changes of this release are:

domain classes managed [...]]]></description>
			<content:encoded><![CDATA[<p>Today an important update of the <a href="http://www.grails.org/plugin/neo4j">Grails Neo4j plugin</a> has been released. <a href="http://www.neo4j.org">Neo4j</a> is a graph database, it&#8217;s main concepts are described in brevity in a <a href="http://blog.armbruster-it.de/2009/10/neo4j-grails-plugin/">previous post</a>.  The plugin provides a convenient way to use Neo4j as a persistence layer for Grails domain classes.</p>
<p>The key features / changes of this release are:</p>
<ul>
<li>domain classes managed by Neo4j can now co-existing with traditional domain classes (aka mapped by Hibernate)</li>
<li>Upgrade to Neo4j 1.0</li>
<li>usage of Grails dependency resolution instead of embedding the jars in /lib directory</li>
<li>added a seperate controller to inspect the Neo4j node space</li>
<li>major refactoring using AST transformation, just like in the couchdb plugin</li>
<li>support for the <a href="http://components.neo4j.org/index-util/">Neo4j indexer</a></li>
<li>support for non-declared properties</li>
<li>support for traversers</li>
</ul>
<p><span id="more-87"></span>In more detail:</p>
<h2>Co-existence with other domain implementations</h2>
<p>In the initial 0.1 release there was no possibility to have hibernate-based domain classes and neo4j-bases domain classes within the same application. By massively learning from the implementation of the <a href="http://www.grails.org/plugin/gorm-couchdb">CouchDB plugin</a>, the neo4j plugin shares now the same principles:</p>
<ul>
<li>each domain class annotated with &#8220;@Neo4jEntity&#8221; is managed by Neo4j</li>
<li>the @Neo4jEntity  annotation triggers a <a href="http://groovy.codehaus.org/Local+AST+Transformations">Groovy AST transformation</a> at compile time. This transformation e.g. injects a reference to the Neo4j node instance in each domain class.</li>
<li>the plugin class delegates most of its work to a singleton-style plugin support class</li>
<li>the plugin support class uses Groovy MOP to inject (most of) the GORM methods into the domain classes</li>
</ul>
<h2>Upgrade to Neo4j 1.0</h2>
<p>About two weeks ago, the Neo4j team released their 1.0 version. In order to keep pace, the 0.2 version of the plugin upgrades to this version.</p>
<h2>Using dependency resolution</h2>
<p>In its recent versions Grails provides a powerful <a href="http://grails.org/doc/latest/guide/3.%20Configuration.html#3.7%20Dependency%20Resolution">dependency resolution DSL</a>. Using this feature, the Neo4j plugin does not contain the neo4j jars itself any longer. Instead they are automatically downloaded upon plugin installation from the Neo4j&#8217;s maven repository.</p>
<h2>Controller for visualizing the node space</h2>
<p>The plugin contains a Neo4jController that provides an easy way to inspect and walk through the nodespace. All the properties and relationships are visible and navigable, see the screenshot. <a href="http://blog.armbruster-it.de/wp-content/uploads/2010/03/Bildschirmfoto-explore-node-space-Mozilla-Firefox.png"><img class="alignnone size-full wp-image-90" title="Screenshot Neo4jController" src="http://blog.armbruster-it.de/wp-content/uploads/2010/03/Bildschirmfoto-explore-node-space-Mozilla-Firefox.png" alt="Screenshot Neo4jController" width="718" height="436" /></a></p>
<p>Aside from navigating through the nodespace, the Neo4jController also provides an action for viewing some statistics: counting nodes an relationship by type, and an inspector for viewing the Grails domain class structure. One word of warning: <strong>do not expose this controller to the public!</strong> Instead use e.g. the acegi plugin and protect it from public access.</p>
<h2>Support for Neo4j Indexer</h2>
<p>Since there is no easy way to ask the nodespace questions like &#8220;Give me all cars with more than 250 hp?&#8221;, Neo4j provides an <a href="http://components.neo4j.org/index-util/">addon</a> that indexes property values. The plugin supports this in two ways:</p>
<ul>
<li>Defining index properties in a domain class by annotating the properties to be indexed with @Neo4jIndexed</li>
<li>Using the indexer when the GORM methods &#8216;findBy&lt;prop&gt;&#8217; or &#8216;findAllBy&lt;prop&gt;&#8217; are called on an indexed property</li>
</ul>
<p>The following code example will make that clearer:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">grails.plugins.neo4j.*</span>
@Neo4jEntity
<span style="color: #000000; font-weight: bold;">class</span> Car <span style="color: #66cc66;">&#123;</span>
   <span style="color: #aaaadd; font-weight: bold;">String</span> licenseTag <span style="color: #808080; font-style: italic;">// normal, aka non-indexed property</span>
   @Neo4jIndex
   <span style="color: #aaaadd; font-weight: bold;">String</span> color  <span style="color: #808080; font-style: italic;">// indexed property</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<h2>Support for non-declared properties</h2>
<p>Since Neo4j is a schema-less database, there is no limitation on what properties are allowed for a certain node. A Grails domain model is much more strict on this. To fill this gap, the plugin supports non-declared properties:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> car <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Car<span style="color: #66cc66;">&#40;</span>licenseTag:<span style="color: #ff0000;">'ABC123'</span>, color:<span style="color: #ff0000;">'red'</span><span style="color: #66cc66;">&#41;</span>
car.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #000000; font-weight: bold;">assert</span> <span style="color: #ff0000;">'red'</span> <span style="color: #66cc66;">==</span> car.<span style="color: #006600;">color</span> <span style="color: #808080; font-style: italic;">// declared property</span>
<span style="color: #000000; font-weight: bold;">assert</span> <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">=</span> car.<span style="color: #006600;">numberOfSeats</span> <span style="color: #808080; font-style: italic;">// N.B: numberOfSeats is _not_ declared</span>
car.<span style="color: #006600;">numberOfSeats</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">5</span>
<span style="color: #000000; font-weight: bold;">assert</span> <span style="color: #ff0000;">'5'</span> <span style="color: #66cc66;">==</span> car.<span style="color: #006600;">numberOfSeats</span></pre></div></div>

<p>Using non-declared properties has one limitation: since there&#8217;s no type information available, they are stored as String. That&#8217;s why the last assert need &#8216;5&#8242; in quotes.</p>
<h2>Support for traversers</h2>
<p>A very powerful method to search and find nodes in the nodespace are <a href="http://wiki.neo4j.org/content/Design_Guide#Searching_using_traversing">traversers</a>. The plugin supports them on two levels:</p>
<ul>
<li>static:  DomainClass.traverse uses the reference node as starting point and</li>
<li>instance: &lt;domainClassInstance&gt;.traverse uses the domainClassInstance as starting point.</li>
</ul>
<p>Both variants come with some overloaded implementations:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">traverse<span style="color: #66cc66;">&#40;</span>StopEvaluator stopEvaluator, ReturnableEvaluator returnableEvaluator, <span style="color: #aaaadd; font-weight: bold;">Object</span>... <span style="color: #006600;">args</span><span style="color: #66cc66;">&#41;</span>
traverse<span style="color: #66cc66;">&#40;</span>Traverser.<span style="color: #006600;">Order</span> order, StopEvaluator stopEvaluator, ReturnableEvaluator returnableEvaluator, <span style="color: #aaaadd; font-weight: bold;">Object</span>... <span style="color: #006600;">args</span><span style="color: #66cc66;">&#41;</span>
traverse<span style="color: #66cc66;">&#40;</span>Closure stopEvaluator, Closure returnableEvaluator, <span style="color: #aaaadd; font-weight: bold;">Object</span>... <span style="color: #006600;">arg</span><span style="color: #66cc66;">&#41;</span>
traverse<span style="color: #66cc66;">&#40;</span>Traverser.<span style="color: #006600;">Order</span> order, Closure stopEvaluator, Closure returnableEvaluator, <span style="color: #aaaadd; font-weight: bold;">Object</span>... <span style="color: #006600;">args</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Note that StopEvaluators and ReturnableEvaluator might be coded in a <a href="http://groovy.codehaus.org/Groovy+way+to+implement+interfaces">&#8216;groovy&#8217; way as closures</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> traverser <span style="color: #66cc66;">=</span> car.<span style="color: #006600;">traverse</span><span style="color: #66cc66;">&#40;</span>
 <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#125;</span>,  <span style="color: #808080; font-style: italic;">// StopEvaluator</span>
 <span style="color: #66cc66;">&#123;</span> it.<span style="color: #006600;">currentNode</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;color&quot;</span>,<span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">==</span><span style="color: #ff0000;">&quot;red&quot;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;">// ReturnableEvaluator</span>
<span style="color: #66cc66;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.armbruster-it.de/2010/03/grails-neo4j-plugin-0-2-released/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Customizing Grails data binding with a &#8220;groovy&#8221; PropertyEditor</title>
		<link>http://blog.armbruster-it.de/2010/01/customizing-grails-data-binding-with-a-groovy-propertyeditor/</link>
		<comments>http://blog.armbruster-it.de/2010/01/customizing-grails-data-binding-with-a-groovy-propertyeditor/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 21:44:19 +0000</pubDate>
		<dc:creator>Stefan Armbruster</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://blog.armbruster-it.de/?p=61</guid>
		<description><![CDATA[When Grails binds data e.g. when the controller&#8217;s bindData method is called, it instantiates a GrailsDataBinder to take the action. GrailsDataBinder configures itself with  some basic ProperyEditors. The neat thing is you can extend that behaviour by adding an arbitrary named PropertyEditorRegistrar implementation to the application context. The PropertyEditorRegistrar registers one or multiple PropertyEditors.
A recent [...]]]></description>
			<content:encoded><![CDATA[<p>When Grails binds data e.g. when the controller&#8217;s <a href="http://grails.org/doc/latest/ref/Controllers/bindData.html">bindData</a> method is called, it instantiates a GrailsDataBinder to take the action. GrailsDataBinder configures itself with  some basic <a href="http://java.sun.com/javase/6/docs/api/java/beans/PropertyEditor.html">ProperyEditors</a>. The neat thing is you can extend that behaviour by adding an arbitrary named <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/beans/PropertyEditorRegistrar.html">PropertyEditorRegistrar</a> implementation to the application context. The PropertyEditorRegistrar registers one or multiple PropertyEditors.</p>
<p>A recent use case was the ability to look up some domain instance by a given key and use this for data binding. Coding a seperate PropertyEditor for each domain class would not really be <a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a>, so I decided to go the groovy way: a DomainClassLookupPropertyEditor:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DomainClassLookupPropertyEditor <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #aaaadd; font-weight: bold;">PropertyEditorSupport</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">Class</span> domainClass
    <span style="color: #aaaadd; font-weight: bold;">String</span> <span style="color: #000000; font-weight: bold;">property</span>
    <span style="color: #993333;">boolean</span> doAssert <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">true</span>
&nbsp;
    <span style="color: #aaaadd; font-weight: bold;">String</span> getAsText<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        value.<span style="color: #ff0000;">&quot;$property&quot;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #993333;">void</span> setAsText<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span> text<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        value <span style="color: #66cc66;">=</span> domainClass.<span style="color: #ff0000;">&quot;findBy${StringUtils.capitalize(property)}&quot;</span><span style="color: #66cc66;">&#40;</span>text<span style="color: #66cc66;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">assert</span> doAssert <span style="color: #66cc66;">&amp;&amp;</span> value, <span style="color: #ff0000;">&quot;no $domainClass found for $property '$text'&quot;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The PropertyEditor calls the domain class&#8217; <a href="http://grails.org/doc/latest/ref/Domain%20Classes/findBy.html"><em>findBy&lt;Property&gt;</em></a> method to look up the desired instance. The PropertyRegistrar looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyPropertyEditorRegistrar <span style="color: #000000; font-weight: bold;">implements</span> PropertyEditorRegistrar <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> registerCustomEditors<span style="color: #66cc66;">&#40;</span>PropertyEditorRegistry propertyEditorRegistry<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        propertyEditorRegistry.<span style="color: #006600;">registerCustomEditor</span><span style="color: #66cc66;">&#40;</span>Author, <span style="color: #000000; font-weight: bold;">new</span> DomainClassLookupPropertyEditor<span style="color: #66cc66;">&#40;</span>domainClass: Author, <span style="color: #000000; font-weight: bold;">property</span>: <span style="color: #ff0000;">&quot;name&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        propertyEditorRegistry.<span style="color: #006600;">registerCustomEditor</span><span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">Book</span>, <span style="color: #000000; font-weight: bold;">new</span> DomainClassLookupPropertyEditor<span style="color: #66cc66;">&#40;</span>domainClass: <span style="color: #aaaadd; font-weight: bold;">Book</span>, <span style="color: #000000; font-weight: bold;">property</span>: <span style="color: #ff0000;">&quot;isbn&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Last, we need to configure that in resources.groovy:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">beans <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
    myEditorRegistrar<span style="color: #66cc66;">&#40;</span>MyPropertyEditorRegistrar<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.armbruster-it.de/2010/01/customizing-grails-data-binding-with-a-groovy-propertyeditor/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Solved a little trouble with Hudson and Grails</title>
		<link>http://blog.armbruster-it.de/2009/10/solved-a-little-trouble-with-hudson-and-grails/</link>
		<comments>http://blog.armbruster-it.de/2009/10/solved-a-little-trouble-with-hudson-and-grails/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 12:38:24 +0000</pubDate>
		<dc:creator>Stefan Armbruster</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[hudson]]></category>

		<guid isPermaLink="false">http://blog.armbruster-it.de/?p=51</guid>
		<description><![CDATA[A few months ago I started to use Hudson for continuous  integration. Installing and running Hudson is very simple and well documented. There&#8217;s a plugin for Grails available.
In most of my Grails projects, I&#8217;m using the Acegi Plugin. By default, this plugin utilizes EhCache for caching user data. In principal this is a good idea [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago I started to use <a href="http://hudson.dev.java.net/">Hudson</a> for continuous  integration. Installing and running Hudson is very simple and well documented. There&#8217;s a <a href="http://wiki.hudson-ci.org/display/HUDSON/Grails+Plugin">plugin for Grails</a> available.</p>
<p>In most of my Grails projects, I&#8217;m using the <a href="http://www.grails.org/plugin/acegi">Acegi Plugin</a>. By default, this plugin utilizes EhCache for caching user data. In principal this is a good idea but it comes to trouble when using multiple Grails apps in Hudson. The default configuration uses /tmp/userCache.data for this cache. Since multiple apps use the same cache directory, it&#8217;s obvious that we get in trouble.</p>
<p>The most simple solution here is to completely disable the user cache. This can be easily done in grails-app/conf/SecurityConfig.groovy by adding</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">cacheUsers <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">false</span></pre></div></div>

<p>Another (and probably better) option would be using a more sophisticated cache configuration e.g. by including the application&#8217;s name in the cache store dir. Or, even better, disable the cache in development and testing environment and configure it with a unique path name for production.</p>
<p>As mostly always: use the simplest solution that could probably work.</p>
<p>Over and out.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.armbruster-it.de/2009/10/solved-a-little-trouble-with-hudson-and-grails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Example for using Neo4j with Grails</title>
		<link>http://blog.armbruster-it.de/2009/10/example-neo4j-with-grails/</link>
		<comments>http://blog.armbruster-it.de/2009/10/example-neo4j-with-grails/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 20:06:52 +0000</pubDate>
		<dc:creator>Stefan Armbruster</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[neo4j]]></category>

		<guid isPermaLink="false">http://blog.armbruster-it.de/?p=33</guid>
		<description><![CDATA[In reply to my today&#8217;s annoncement of the Neo4j Grails plugin, @StigLau asked me to provide an example for using the Neo4j Grails plugin. So here we go:

Create your sample application:

grails create-app neo4jtest; cd neo4jtest


Add the Neo4j plugin:

grails install-plugin neo4j


create some sample domain classes:

grails create-domain-class Author
grails create-domain-class Book


create a controller for the domain class

grails create-controller [...]]]></description>
			<content:encoded><![CDATA[<p>In reply to my today&#8217;s <a href="http://blog.armbruster-it.de/2009/10/neo4j-grails-plugin/">annoncement</a> of the Neo4j Grails plugin, <a href="http://twitter.com/StigLau">@StigLau</a> asked me to provide an example for using the Neo4j Grails plugin. So here we go:</p>
<ol>
<li>Create your sample application:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">grails create-app neo4jtest; <span style="color: #7a0874; font-weight: bold;">cd</span> neo4jtest</pre></div></div>

</li>
<li>Add the Neo4j plugin:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">grails install-plugin neo4j</pre></div></div>

</li>
<li>create some sample domain classes:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">grails create-domain-class Author
grails create-domain-class Book</pre></div></div>

</li>
<li>create a controller for the domain class

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">grails create-controller Author
grails create-controller Book</pre></div></div>

</li>
<li>modify the domain classes:

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">grails.plugins.neo4j.Neo4jEntity</span>
@Neo4jEntity
<span style="color: #000000; font-weight: bold;">class</span> Author <span style="color: #66cc66;">&#123;</span>
    <span style="color: #aaaadd; font-weight: bold;">String</span> name
    <span style="color: #aaaadd; font-weight: bold;">Date</span> dob
&nbsp;
    <span style="color: #000000; font-weight: bold;">static</span> hasMany <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span> books: <span style="color: #aaaadd; font-weight: bold;">Book</span> <span style="color: #66cc66;">&#93;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>and</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">grails.plugins.neo4j.Neo4jEntity</span>
@Neo4jEntity
<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #aaaadd; font-weight: bold;">Book</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #aaaadd; font-weight: bold;">String</span> title
    <span style="color: #000000; font-weight: bold;">static</span> belongsTo <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>author:Author<span style="color: #66cc66;">&#93;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

</li>
<li>modify the controller to use dynamic scaffolding:

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> AuthorController <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">def</span> scaffold <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">true</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> BookController <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">def</span> scaffold <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">true</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

</li>
<li>start up the application:

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">grails run<span style="color: #66cc66;">-</span>app</pre></div></div>

</li>
<li>use it, love it: go to <a href="http://localhost:8080/neo4jtest">http://localhost:8080/neo4jtest</a>, add some authors and books.</li>
<li>to explore the Neo4j node space created with your grails app, check out <a href="http://wiki.neo4j.org/content/Neoclipse_Guide">Neoclipse</a>.</li>
</ol>
<p><strong>UPDATE: </strong>Use Grails 1.2.1</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.armbruster-it.de/2009/10/example-neo4j-with-grails/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
