<?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>Addictive Software &#187; rest</title>
	<atom:link href="http://blog.addictivesoftware.net/tag/rest/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.addictivesoftware.net</link>
	<description>ramblings of a chaotic mind</description>
	<lastBuildDate>Tue, 06 Jul 2010 09:04:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rest easy</title>
		<link>http://blog.addictivesoftware.net/2009/12/rest-easy/</link>
		<comments>http://blog.addictivesoftware.net/2009/12/rest-easy/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 14:10:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.addictivesoftware.net/?p=49</guid>
		<description><![CDATA[I’ve been playing around with REST (REpresentational State Transfer) for a bit and decided to write a small tutorial to show how easy it is to create a rest interface to your business objects
Advantages of rest

Works over HTTP, known protocol with known data formats (mime types), no weird ports open in your firewall
Every resource is [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been playing around with <a href="http://en.wikipedia.org/wiki/REST">REST</a> (REpresentational State Transfer) for a bit and decided to write a small tutorial to show how easy it is to create a rest interface to your business objects</p>
<p>Advantages of rest</p>
<ul>
<li>Works over HTTP, known protocol with known data formats (mime types), no weird ports open in your firewall</li>
<li>Every resource is uniquely identified by a URI</li>
<li>Can do CRUD on those resources (they are just called POST, GET, PUT, DELETE)</li>
<li>used by all the major players for cloud applications (<a href="http://kenai.com/projects/suncloudapis/pages/Home">SUN's cloudApi</a>, <a href="http://www.microsoft.com/windowsazure/">Microsoft's Azure services platform</a>)</li>
<li>we might finally get rid of webdav</li>
</ul>
<p>I'll be using the <a href="https://jersey.dev.java.net/">Jersey</a> Framework for this.<br />
As i’ve been working on a backend that will allow you to manage <a href="http://en.wikipedia.org/wiki/Agile_development">agile development</a> processes (Scrum, Kanban etc) I thought I use that.</p>
<p>In this application every object is represented by a Card for instance a Story, Task, Bug, work Item, etc.<br />
Cards have a hierarchical structure and can each have custom properties<br />
The class looks something like this (removed methods for clarity):</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #000000; font-weight: bold;">class</span> Card <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">long</span> id<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>Card<span style="color: #339933;">&gt;</span> children <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Card<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>Entry<span style="color: #339933;">&gt;</span> properties <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Entry<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>and then for instance the Story class with some default values set in the constructor:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Story <span style="color: #000000; font-weight: bold;">extends</span> Card <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> Story<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		addProperty<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title&quot;</span>, <span style="color: #0000ff;">&quot;A new story&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		addProperty<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Description&quot;</span>, <span style="color: #0000ff;">&quot;as a .. I want .. for the benefit of ..&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		addProperty<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Storypoints&quot;</span>, <span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>To be able to return these objects through REST they need to be in a format that can be distributed over HTTP, in this case we will be using XML and JSON.<br />
The <a href="https://jaxb.dev.java.net/">Java XML Bindings</a> are perfectly suited to create xml representations of our classes</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@XmlRootElement<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;card&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #000000; font-weight: bold;">class</span> Card <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">long</span> id<span style="color: #339933;">;</span>
&nbsp;
	@XmlAttribute<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;type&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #003399;">String</span> instance <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getSimpleName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	@XmlElement<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;card&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>Card<span style="color: #339933;">&gt;</span> children <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Card<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	@XmlElement<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;property&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>Entry<span style="color: #339933;">&gt;</span> properties <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Entry<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	@XmlAttribute
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">long</span> getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>* the Entry class is a simple class with a name and value property, I choose this approach as JAXB has an issue in representing HashMaps() in XML<br />
this will produce the following xml</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;card</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Task&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;nobody&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;assigned&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Slay dragon&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Title&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;his weak spot seems to be a small spot on his belly&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Description&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;hours&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/card<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>for JSON we don’t need to do anything special then include the jersey-json.jar to the project.</p>
<p>Now to configure and hookup the rest servlet<br />
I added the jersey servlet to my web.xml</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Rest Web Service<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.sun.jersey.spi.container.servlet.ServletContainer<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;load-on-startup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/load-on-startup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Rest Web Service<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/services/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>And create the service provider class</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@PerRequest
@Path<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/agileassistant&quot;</span><span style="color: #009900;">&#41;</span>
@Consumes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> MediaType.<span style="color: #006633;">APPLICATION_JSON</span>, MediaType.<span style="color: #006633;">APPLICATION_XML</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
@Produces<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> MediaType.<span style="color: #006633;">APPLICATION_JSON</span>, MediaType.<span style="color: #006633;">APPLICATION_XML</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> AgileAssistantService <span style="color: #009900;">&#123;</span>
 ...
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This will tell Jersey that this is a provider that will respond to requests to /rest/agileassistant, accept JSON and XML and can output JSON or XML depending on the accept headers sent by the client</p>
<p>Now if we for instance want to return the first card (rootCard) and all its children we add this method</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> Card rootCard <span style="color: #339933;">=</span> Card.<span style="color: #006633;">createCard</span><span style="color: #009900;">&#40;</span>Root.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	@GET
	<span style="color: #000000; font-weight: bold;">public</span> Card getRoot<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> rootCard<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>(in my data model the rootCard is always present and functions as a starting point to add the rest of the cards in a hierarchical structure)<br />
So requesting this card will effectively return the entire structure for my test data:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;card</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Root&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;card</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Story&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Convince King&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Title&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;to let the prince go on an adventure&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Description&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Storypoints&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/card<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;card</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Story&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;card</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Task&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;nobody&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;assigned&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Slay dragon&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Title&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;his weak spot seems to be a small spot on his belly&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Description&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;hours&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/card<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;card</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Task&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;nobody&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;assigned&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Rescue Princess&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Title&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;She'll be the one screaming from the tower window&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Description&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;hours&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/card<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Once upon a time&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Title&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;in a land far far away&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Description&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Storypoints&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/card<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/card<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Doing a parameterized query is almost as easy</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">	@GET
	@Path<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/card/{id}&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> Card getCard<span style="color: #009900;">&#40;</span>@PathParam<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">long</span> id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> getCardById<span style="color: #009900;">&#40;</span>rootCard, id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>here the id that you specify will be injected into the parameter<br />
giving the following output</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;card</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Task&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;nobody&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;assigned&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Slay dragon&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Title&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;his weak spot seems to be a small spot on his belly&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Description&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;hours&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/card<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>To conclude enabling rest for your applications is pretty easy, writing this blog took longer than writing the code.<br />
In a next post I will add POST/PUT/DELETE requests to store data in your application</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.addictivesoftware.net/2009/12/rest-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
