<?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>Foognostic blogs &#187; Groovy</title>
	<atom:link href="http://blogs.foognostic.net/topics/code/groovy/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.foognostic.net</link>
	<description>Seeking knowledge of foo</description>
	<lastBuildDate>Fri, 23 Apr 2010 12:45:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>introducing jawarepl</title>
		<link>http://blogs.foognostic.net/2009/01/introducing-jawarepl/</link>
		<comments>http://blogs.foognostic.net/2009/01/introducing-jawarepl/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 19:57:16 +0000</pubDate>
		<dc:creator>Seth Schroeder</dc:creator>
				<category><![CDATA[GPLv3]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[bitbucket]]></category>
		<category><![CDATA[jawarepl]]></category>

		<guid isPermaLink="false">http://blogs.foognostic.net/?p=66</guid>
		<description><![CDATA[JAWAREPL is a JAva Web Application Read Eval Print Loop. It loads a Spring-based Java .war file into groovysh, and then makes its fully actived Spring beans easy to use. Here's a quick example. It uses 'petclinic', one of the sample apps included with Spring: $ groovysh . /Users/moi/Documents/code/jawarepl/jawarepl.groovy inst = new JAWAREPL(); Here's how [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://bitbucket.org/seths/jawarepl/overview/">JAWAREPL</a> is a JAva Web Application Read Eval Print Loop. It loads a <a href="http://www.springsource.org/">Spring</a>-based Java .war file into <a href="http://groovy.codehaus.org/Groovy+Shell">groovysh</a>, and then makes its fully actived Spring beans easy to use.</p>

<p>Here's a quick example. It uses 'petclinic', one of the sample apps included with Spring:</p>

<p><pre>
$ groovysh
. /Users/moi/Documents/code/jawarepl/jawarepl.groovy
inst = new JAWAREPL();
</pre></p>

<p>Here's how you configure it:</p>

<p><pre>
inst.war_path = "/path/to/petclinic/dist/petclinic.war";
inst.context_paths = [ "WEB-INF/applicationContext-hibernate.xml" ];
ctx = inst.context;
</pre></p>

<p>After that, the sky's the limit! Start grabbing beans out and call all the methods you want. Put this into groovysh:</p>

<p><pre>
clinic = ctx.getBean("clinic");
clinic.vets.each {
   println "vet = ${it.lastName}, ${it.firstName}";
   it.specialties.each {
       println "    $it";
   }
}
</pre></p>

<p>And this should come out:</p>

<p><pre>
vet = Carter, James
vet = Douglas, Linda
    dentistry
    surgery
vet = Jenkins, Sharon
vet = Leary, Helen
    radiology
vet = Ortega, Rafael
    surgery
vet = Stevens, Henry
    radiology
</pre></p>

<p>Just to demonstrate that it's not only for reading data, here is another sample where it adds a visit to the petclinic.</p>

<p><pre>
owner = clinic.findOwners("Schroeder")[0];
owner.pets.visits.each { println "$it.date, $it.description" }
[2009-01-24, 2009-01-24], [JAWAREPL test, JAWAREPL test]
visit = new org.springframework.samples.petclinic.Visit();
visit.date = new Date();
visit.pet = pets[0];
visit.description = "JAWAREPL test2";
clinic.storeVisit(visit);
...
Hibernate: insert into visits (visit_date, description, pet_id) values (?, ?, ?)
owner = clinic.findOwners("Schroeder")[0];
owner.pets.visits.each { println "$it.date, $it.description" }
[2009-01-24, 2009-01-24, 2009-01-24], [JAWAREPL test,
JAWAREPL test2, JAWAREPL test]
</pre></p>

<p>More detailed instructions are available on <a href="http://bitbucket.org/seths/jawarepl/src/123872d5dc2f/samples.txt">bitbucket</a>.</p>

<p>JAWAREPL has been tested on three of the sample Spring apps and a basic Grails app. Those are pretty trivial samples and even so, it was a minor task to make them all work; the Grails war had none of the GORM mojo stitched in so it was really not very useful (patches anyone?) That being said, I would <b>not</b> expect a complex war file to load smoothly. I seem to recall some sort of mock/mini JNDI provider in Spring if that what goes wrong. I will try to look at any <a href="http://bitbucket.org/seths/jawarepl/issues/">bug reports</a>, or much better yet <a href="http://bitbucket.org/seths/jawarepl/src/">patches</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.foognostic.net/2009/01/introducing-jawarepl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
