<?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>Restafarian.org &#187; Code</title>
	<atom:link href="http://blog.restafarian.org/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.restafarian.org</link>
	<description>What’s in a name? That which we call a rose By any other name would smell as sweet.</description>
	<lastBuildDate>Sat, 24 Jul 2010 01:47:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Getting into the Swing of Things</title>
		<link>http://blog.restafarian.org/2010/07/getting-into-the-swing-of-things/</link>
		<comments>http://blog.restafarian.org/2010/07/getting-into-the-swing-of-things/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 01:47:01 +0000</pubDate>
		<dc:creator>Restamon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[ibm]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[sun]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://blog.restafarian.org/?p=661</guid>
		<description><![CDATA[I guess I have always been a Web programmer, and not a Java programmer. My first &#8220;dynamic&#8221; web pages were generated on an IBM Mainframe by a COBOL program and then placed on the web server by an FTP step in the JCL. Later on, I discovered the joys of Perl and CGI, and eventually, [...]]]></description>
			<content:encoded><![CDATA[<p>I guess I have always been a <em>Web</em> programmer, and not a <em>Java</em> programmer. My first &#8220;dynamic&#8221; web pages were generated on an <a href="http://www.ibm.com/us/en/" target="_blank">IBM</a> <a href="http://www-03.ibm.com/systems/z/" target="_blank">Mainframe</a> by a <a href="http://www-01.ibm.com/software/awdtools/cobol/zos/" target="_blank">COBOL</a> program and then placed on the web server by an FTP step in the <a href="http://publib.boulder.ibm.com/infocenter/zos/basics/index.jsp?topic=/com.ibm.zos.zconcepts/zconc_whatisjcl.htm" target="_blank">JCL</a>. Later on, I discovered the joys of Perl and CGI, and eventually, I found my way to <a href="http://java.sun.com/" target="_blank">Java</a> (I still can&#8217;t get used to the <a href="http://www.oracle.com/" target="_blank">Oracle</a> brand popping up on that link!), once again thanks to IBM and their <a href="http://www-01.ibm.com/software/websphere/" target="_blank">WebSphere</a> line (and their now ancient history <a href="http://en.wikipedia.org/wiki/IBM_VisualAge" target="_blank">VisualAge for Java</a> IDE).</p>
<p>So, I have been coding Java for a long time, but just that subset of Java that lives within the realm of a web application server. I never really had occasion to build anything like an application with its own GUI that lived on the desktop. For one reason or another, that&#8217;s just something that had never come up.</p>
<p>Until now.</p>
<p>It may be the same language, but I have to say, it&#8217;s an entirely different world. Labels and Frames; Panels and Panes; Listeners and Layouts; TrayIcons and Popups; Bindings and Actions; GridBagLayouts, SplitPanes, Buttons, and Borders.</p>
<p>Timers and Workers and Threads &#8230; Oh, My!</p>
<p>We are definitely not in Kansas anymore, Toto!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.restafarian.org/2010/07/getting-into-the-swing-of-things/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding an Icon to Your Bookmarklet</title>
		<link>http://blog.restafarian.org/2010/07/adding-an-icon-to-your-bookmarklet/</link>
		<comments>http://blog.restafarian.org/2010/07/adding-an-icon-to-your-bookmarklet/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 19:05:29 +0000</pubDate>
		<dc:creator>Restamon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[icon]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://blog.restafarian.org/?p=647</guid>
		<description><![CDATA[The other day I needed to create a bookmarklet, which was an interesting exercise in and of itself, but once I got all of those issues worked out, I wanted to make it pretty by adding an icon. Apparently, this is not something easily accomplished, and there is little information out there that I could [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I needed to create a <a href="http://en.wikipedia.org/wiki/Bookmarklet" target="_blank">bookmarklet</a>, which was an interesting exercise in and of itself, but once I got all of those issues worked out, I wanted to make it pretty by adding an icon. Apparently, this is not something easily accomplished, and there is little information out there that I could locate on how one might go about doing this. I did manage to find this, though, over at <a href="http://www.tapper-ware.net/blog/?p=97" target="_blank">tapper[ware]</a>:</p>
<p><a href="http://www.tapper-ware.net/blog/?p=97" target="_blank">Offering Bookmarklets with icons</a></p>
<p>Now, I have to say that his little hack to make all of this magic happen is rather ingenious, and I do like it. I just could not get it to work in my version of Firefox. Everything started out great in the beginning. The first example worked just fine for me. I can take this little icon:</p>
<p><img src="http://blog.restafarian.org/wp-content/uploads/2010/07/chat.png"/></p>
<p>&#8230; and add it to this bookmarklet:</p>
<p><a href="javascript:'%3C!DOCTYPE html%3E%3Chtml%3E%3Chead%3E%3Clink%20rel=&quot;icon&quot;%20type=&quot;image/png&quot;%20href=&quot;http://blog.restafarian.org/wp-content/uploads/2010/07/chat.png&quot;/%3E%3C/head%3E%3Cbody%20onload=&quot;history.back();&quot;%3E%3C/body%3E%3C/html%3E';">Click Me!</a></p>
<p>&#8230;. and the image shows up just as advertised. Drag it up to your browser&#8217;s tool bar and see for yourself. It works! But when I started getting into the conditional stuff, the icon would only show up when the HTML side was true, not when the Javascript side was true. In other words, I could have my choice of a working bookmarklet with no icon or a bookmarklet with a nice icon that didn&#8217;t do anything! I could never figure out how to get it to recognize the HTML side of the conditional and load the icon, yet execute the Javascript when the bookmarklet was clicked. I could get one to work, or I could get the other to work, but I could never get them both to work at the same time.</p>
<p>Apparently, I&#8217;m just not smart enough to figure that out, so I did the next best thing and just gave up trying, and then went with a slightly different approach:</p>
<p><a href="javascript:if(window.location.href.indexOf('http://blog.restafarian.org/')==0){'%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3Clink%20rel=&quot;icon&quot;%20type=&quot;image/png&quot;%20href=&quot;http://blog.restafarian.org/wp-content/uploads/2010/07/chat.png&quot;/%3E%3C/head%3E%3Cbody%20onload=&quot;history.back();&quot;%3E%3C/body%3E%3C/html%3E';}else{alert('Do%20bookmarklet%20stuff%20...');}">Click Me!</a></p>
<p>This version uses the <code>window.location.href</code> as it&#8217;s conditional, so if you are on the page that hosts the bookmarklet you get the HTML, otherwise you get the Javascript. Now, using this approach, the bookmarklet doesn&#8217;t function on the page on which you got it, but when you are on that page, you can load the icon, and once loaded, it&#8217;s there for life. Here&#8217;s what it looks like under the hood:</p>
<pre>
&lt;a href="javascript:if(window.location.href.indexOf('http://blog.restafarian.org/')==0)
{'%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3Clink%20rel=&quot;icon
&quot;%20type=&quot;image/png&quot;%20href=&quot;http://blog.restafarian.org
/wp-content/uploads/2010/07/chat.png&quot;/%3E%3C/head%3E%3Cbody%20onload=
&quot;history.back();&quot;%3E%3C/body%3E%3C/html%3E';}else{
alert('Do%20bookmarklet%20stuff%20...');}"&gt;Click Me!&lt;/a&gt;
</pre>
<p>There&#8217;s probably a better way to do this still, but I did what I could to do what I wanted to do, and that&#8217;s going to have to be good enough for now!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.restafarian.org/2010/07/adding-an-icon-to-your-bookmarklet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It&#8217;s Joda Time!</title>
		<link>http://blog.restafarian.org/2010/07/its-joda-time/</link>
		<comments>http://blog.restafarian.org/2010/07/its-joda-time/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 19:15:53 +0000</pubDate>
		<dc:creator>Restamon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[ISO8601]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[joda time]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://blog.restafarian.org/?p=640</guid>
		<description><![CDATA[For the longest time now I have been WWWAAAYYY too busy to even think about doing any blogging, but hopefully that is all starting to change now. Things are starting to settle down a little, and I should have a wee bit more time. Speaking of time (nice segue, no?), I have been having fun [...]]]></description>
			<content:encoded><![CDATA[<p>For the longest time now <a href="http://blog.restafarian.org/2009/10/build-a-restful-web-service-using-jersey-and-apache-tomcat/">I have been WWWAAAYYY too busy to even think about doing any blogging</a>, but hopefully that is all starting to change now. Things are starting to settle down a little, and I should have a wee bit more time.</p>
<p>Speaking of time (nice segue, no?), I have been <a href="http://blog.restafarian.org/2008/02/iso-8601-date-formatting-client-side/">having fun</a> with <a href="http://www.iso.org/iso/catalogue_detail?csnumber=40874" target="_blank">ISO 8601</a> dates and times for quite a while. On the sever side, I have just been using plain old <a href="http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/api/java/util/Date.html" target="_blank">java.util.Date</a> and <a href="http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/api/java/text/DateFormat.html" target="_blank">java.text.DateFormat</a>. Then I found this:</p>
<p><strong><a href="http://joda-time.sourceforge.net/" target="_blank">Joda Time &#8211; Java date and time API</a></strong></p>
<p>According to their home page, <em>&#8220;Joda-Time has been created to radically change date and time handling in Java. The JDK classes Date and Calendar are very badly designed, have had numerous bugs and have odd performance effects.&#8221;</em>. At this point, I have only played around with <a href="http://joda-time.sourceforge.net/api-release/org/joda/time/DateTime.html" target="_blank">DateTime</a>, but I have to say that I like it so far.</p>
<p>One thing that I never did like about DateFormat was that the Time Zone component never rendered out with the colon (&#8220;:&#8221;) in between the offset hours and offset minutes. I had to add this code:</p>
<pre>
    String string = FORMAT.format(date);
    return string.substring(0, string.length() - 2) + ":" +
         string.substring(string.length() - 2);
</pre>
<p>&#8230; to <a href="http://blog.restafarian.org/2008/02/iso-8601-date-formatting/">this</a> back in the day. With Joda Time, you can accomplish the same thing with this (assuming that &#8220;date&#8221; is a Joda Time DateTime object):</p>
<pre>
    String string = date.toString();
</pre>
<p>It&#8217;s one of my new standards!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.restafarian.org/2010/07/its-joda-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring 3.0.0 and Maven</title>
		<link>http://blog.restafarian.org/2009/12/spring-3-0-0-and-maven/</link>
		<comments>http://blog.restafarian.org/2009/12/spring-3-0-0-and-maven/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 15:51:03 +0000</pubDate>
		<dc:creator>Restamon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring 3]]></category>

		<guid isPermaLink="false">http://blog.restafarian.org/?p=628</guid>
		<description><![CDATA[First of all, it&#8217;s always best to read the instructions. Second, if you were successfully using the last Spring 3 release candidate in your Maven project, you cannot simply pull up the pom.xml in an editor and change all &#8220;.RC3&#8243; to &#8220;&#8221;. Actually, to be completely accurate, you can do that &#8212; you&#8217;ll just get [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, it&#8217;s always best to <a title="http://blog.springsource.com/2009/12/02/obtaining-spring-3-artifacts-with-maven/" href="http://blog.springsource.com/2009/12/02/obtaining-spring-3-artifacts-with-maven/" target="_blank">read the instructions</a>.</p>
<p>Second, if you were successfully using <a title="Spring 3.0.0.RC3 is now available" href="http://blog.restafarian.org/2009/12/spring-3-0-0-rc3-is-now-available/" target="_self">the last Spring 3 release candidate</a> in your Maven project, you cannot simply pull up the <em>pom.xml</em> in an editor and change all &#8220;.RC3&#8243; to &#8220;&#8221;. Actually, to be completely accurate, you <em>can</em> do that &#8212; you&#8217;ll just get a &#8220;Build Failed&#8221; when you attempt to build your project. The official name of the GA release of <a title="It’s official: Spring 3.0.0 is now final" href="http://blog.restafarian.org/2009/12/its-official-spring-3-0-0-is-now-final/" target="_self">Spring 3</a> is not 3.0.0 &#8212; it&#8217;s 3.0.0.RELEASE. So &#8230; you can do a change all &#8220;.RC3&#8243; to &#8220;.RELEASE&#8221; and <em>that</em> will actually work:</p>
<pre>[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Thu Dec 17 07:33:41 PST 2009
[INFO] Final Memory: 4M/26M
[INFO] ------------------------------------------------------------------------</pre>
<p>And since the artifacts are now coming from the main Maven repository, you can also remove this from your <em>pom.xml</em>:</p>
<pre>&lt;repositories&gt;
 &lt;repository&gt;
  &lt;id&gt;Springframework milestone&lt;/id&gt;
  &lt;url&gt;http://maven.springframework.org/milestone&lt;/url&gt;
 &lt;/repository&gt;
&lt;/repositories&gt;</pre>
<p>&#8230; unless, of course, you are also using the release candidates for Spring Security 3, which does not have a GA version out just yet. In that case, you just shot yourself in the foot by pulling that out prematurely. Not that I know anyone who would do that; I&#8217;m just saying &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.restafarian.org/2009/12/spring-3-0-0-and-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It&#8217;s official: Spring 3.0.0 is now final</title>
		<link>http://blog.restafarian.org/2009/12/its-official-spring-3-0-0-is-now-final/</link>
		<comments>http://blog.restafarian.org/2009/12/its-official-spring-3-0-0-is-now-final/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 13:29:55 +0000</pubDate>
		<dc:creator>Restamon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[spring 3]]></category>
		<category><![CDATA[spring framework]]></category>

		<guid isPermaLink="false">http://blog.restafarian.org/?p=626</guid>
		<description><![CDATA[No more release candidates; you can now download and start working with the real deal: It&#8217;s here just in time for the holidays! Arjen Poutsma has just announced that Spring 3.0.0 is now final and Juergen Hoeller has blogged about the features in the release. Download &#124; Documentation &#124; Javadoc API &#124; Change Log &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>No more release candidates; you can now download and start working with <a title="http://www.springsource.org/node/2266" href="http://www.springsource.org/node/2266" target="_blank">the real deal</a>:</p>
<blockquote>
<div>
<p>It&#8217;s here just in time for the holidays! <a href="http://blog.springsource.com/author/arjenp/">Arjen Poutsma</a> has just <a href="http://twitter.com/poutsma">announced</a> that Spring 3.0.0 is now final and <a href="http://blog.springsource.com/author/juergenh/">Juergen Hoeller</a> has <a href="http://blog.springsource.com/2009/12/16/spring-framework-3-0-goes-ga/">blogged</a> about the features in the release.</p>
<p><a href="http://www.springsource.com/download/community?project=Spring%20Framework&amp;version=3.0.0.RELEASE" target="_blank">Download</a> | <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/">Documentation</a> | <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/" target="_blank">Javadoc API</a> | <a href="http://static.springsource.org/spring/docs/3.0.0.RELEASE/changelog.txt" target="_blank">Change Log</a> | <a href="http://jira.springframework.org/browse/SPR">JIRA</a></p>
<p>Congratulations to Juergen, Arjen and all the other SpringSource engineers that worked so hard on the release. Also a huge thank you to all of the dedicated community members that have given <a href="http://forum.springsource.org/forumdisplay.php?f=21">feedback</a> and identified <a href="http://jira.springframework.org/browse/SPR">issues</a> along the way. Please keep up the good work so that we can continue to make all the Spring projects better and better.</div>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.restafarian.org/2009/12/its-official-spring-3-0-0-is-now-final/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring 3.0.0.RC3 is now available</title>
		<link>http://blog.restafarian.org/2009/12/spring-3-0-0-rc3-is-now-available/</link>
		<comments>http://blog.restafarian.org/2009/12/spring-3-0-0-rc3-is-now-available/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 18:44:50 +0000</pubDate>
		<dc:creator>Restamon</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://blog.restafarian.org/?p=624</guid>
		<description><![CDATA[I missed this earlier in the week, but Spring 3.0.0.RC3 came out on Tuesday: It&#8217;s getting closer. Arjen Poutsma has just announced that Spring 3.0.0.RC3 is now available. This release candidate contains lots of fixes to issues raised by community members. Download &#124; Documentation &#124; Javadoc API &#124; Change Log &#124; JIRA Thank you to [...]]]></description>
			<content:encoded><![CDATA[<p>I missed this earlier in the week, but <a title="http://www.springsource.org/node/2198" href="http://www.springsource.org/node/2198" target="_blank">Spring 3.0.0.RC3 came out on Tuesday</a>:</p>
<blockquote>
<div>
<p>It&#8217;s getting closer. <a href="http://blog.springsource.com/author/arjenp/">Arjen Poutsma</a> has just <a href="http://twitter.com/poutsma">announced</a> that Spring 3.0.0.RC3 is now available. This release candidate contains lots of fixes to issues raised by community members.</p>
<p><a href="http://www.springsource.com/download/community?project=Spring%20Framework&amp;version=3.0.0.RC3" target="_blank">Download</a> | <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/">Documentation</a> | <a href="http://static.springsource.org/spring/docs/3.0.0.RC3/javadoc-api/" target="_blank">Javadoc API</a> | <a href="http://static.springsource.org/spring/docs/3.0.0.RC3/changelog.txt" target="_blank">Change Log</a> | <a href="http://jira.springframework.org/browse/SPR">JIRA</a></p>
<p>Thank you to all of the dedicated community members that have given <a href="http://forum.springsource.org/forumdisplay.php?f=21">feedback</a> and identified <a href="http://jira.springframework.org/browse/SPR">issues</a>. Please keep up the good work so that we can get a high quality 3.0 GA release.</div>
</blockquote>
<p>So, another quick &#8220;change all&#8221; and BAM!:</p>
<pre>[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22 seconds
[INFO] Finished at: Fri Dec 04 10:38:33 PST 2009
[INFO] Final Memory: 3M/48M
[INFO] ------------------------------------------------------------------------</pre>
<p>Just the way I like it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.restafarian.org/2009/12/spring-3-0-0-rc3-is-now-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring 3.0.0.RC2 is now available</title>
		<link>http://blog.restafarian.org/2009/11/spring-3-0-0-rc2-is-now-available/</link>
		<comments>http://blog.restafarian.org/2009/11/spring-3-0-0-rc2-is-now-available/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 18:13:12 +0000</pubDate>
		<dc:creator>Restamon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring 3]]></category>
		<category><![CDATA[spring security]]></category>

		<guid isPermaLink="false">http://blog.restafarian.org/?p=622</guid>
		<description><![CDATA[Check it out: Spring 3.0.0.RC2 is (tentatively) scheduled to be released today! Regards, Sam p.s. if you check JIRA now, you&#8217;ll notice that there are no more open issues on the RC2 road map. I did a &#8220;change all &#60;version&#62;3.0.0.RC1&#60;/version&#62; to &#60;version&#62;3.0.0.RC2&#60;/version&#62;&#8221; in my pom.xml, but that was a little overzealous, since this announcement does [...]]]></description>
			<content:encoded><![CDATA[<p><a title="http://forum.springsource.org/showthread.php?p=269326" href="http://forum.springsource.org/showthread.php?p=269326" target="_blank">Check it out</a>:</p>
<blockquote><p>Spring 3.0.0.RC2 is (tentatively) scheduled to be released today! <img title="Wink" src="http://forum.springsource.org/images/smilies/wink.gif" border="0" alt="" /></p>
<p>Regards,</p>
<p>Sam</p>
<p>p.s. if you check JIRA now, you&#8217;ll notice that there are no more open issues on the RC2 road map.</p></blockquote>
<p>I did a &#8220;change all <em>&lt;version&gt;3.0.0.RC1&lt;/version&gt;</em> to <em>&lt;version&gt;3.0.0.RC2&lt;/version&gt;</em>&#8221; in my <em>pom.xml</em>, but that was a little overzealous, since this announcement does not include Spring Security. So, I had to go back in and reset those back to RC1, after which I was rewarded with my favorite build/install outcome:</p>
<pre>[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9 seconds
[INFO] Finished at: Fri Nov 13 10:05:25 PST 2009
[INFO] Final Memory: 3M/52M
[INFO] ------------------------------------------------------------------------</pre>
<p>Pretty cool!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.restafarian.org/2009/11/spring-3-0-0-rc2-is-now-available/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Build a RESTful Web service using Jersey and Tomcat</title>
		<link>http://blog.restafarian.org/2009/10/build-a-restful-web-service-using-jersey-and-apache-tomcat/</link>
		<comments>http://blog.restafarian.org/2009/10/build-a-restful-web-service-using-jersey-and-apache-tomcat/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 21:37:15 +0000</pubDate>
		<dc:creator>Restamon</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://blog.restafarian.org/?p=618</guid>
		<description><![CDATA[Unfortunately, I have been WWWAAAYYY too busy to even think about doing any blogging lately, but I have been having a lot of fun trying to figure out how to make this work with Spring 3.0.0RC1: Summary: Representational state transfer (REST) was introduced in early 2000 by Roy Fielding&#8217;s doctoral dissertation. However, in the Java™ [...]]]></description>
			<content:encoded><![CDATA[<p>Unfortunately, I have been WWWAAAYYY too busy to even think about doing any blogging lately, but I have been having a lot of fun trying to figure out how to make <a title="http://www.ibm.com/developerworks/library/wa-aj-tomcat/" href="http://www.ibm.com/developerworks/library/wa-aj-tomcat/" target="_blank">this</a> work with <a title="http://blog.restafarian.org/2009/09/spring-3-0-is-getting-closer/" href="http://blog.restafarian.org/2009/09/spring-3-0-is-getting-closer/" target="_self">Spring 3.0.0RC1</a>:</p>
<blockquote><p><strong>Summary:</strong> Representational state transfer (REST) was introduced in early 2000 by Roy Fielding&#8217;s doctoral dissertation.          However, in the Java™ community, it was not standardized until the JSR            311(JAX-RS) specification was          finalized in 2008. The first release of its reference implementation is          even later. In this article, I introduce Jersey, which is the reference          implementation of JSR 311, by describing its essential APIs and annotations. I&#8217;ll          also show you how you can smoothly transfer from servlet-style services to          RESTful services by integrating Jersey into Apache Tomcat.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.restafarian.org/2009/10/build-a-restful-web-service-using-jersey-and-apache-tomcat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Look-up Tables: Service configuration</title>
		<link>http://blog.restafarian.org/2009/06/look-up-tables-service-configuration/</link>
		<comments>http://blog.restafarian.org/2009/06/look-up-tables-service-configuration/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 19:10:28 +0000</pubDate>
		<dc:creator>Restamon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[look-up tables]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.restafarian.org/?p=592</guid>
		<description><![CDATA[Yesterday, I tossed out a copy of my new LookupTableService without going into much detail about the use of the service or how to go about setting it up. Today, I&#8217;d like to correct that and add a little context to the story. Basically, I wanted to be able to get to table entries, not [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I tossed out a copy of my new <a title="Look-up Tables: LookupTableService" href="http://blog.restafarian.org/2009/06/look-up-tables-lookuptableservice/" target="_self">LookupTableService</a> without going into much detail about the use of the service or how to go about setting it up. Today, I&#8217;d like to correct that and add a little context to the story.</p>
<p>Basically, I wanted to be able to get to table entries, not as they are defined on the database, but as they are configured in the system. This primarily relates to user-defined properties, which are stored on the database as property01, property02, property03, etc, but which have been given certain characteristics by their creator when the look-up table was defined. Such characteristics include things like name and type and length and source and so on, which is how I wanted to get to things, as opposed to property01, property02, and so forth. That&#8217;s why you see this little tidbit of code inside of the service:</p>
<pre>  /**
   * &lt;p&gt;Returns the requested table entry.&lt;/p&gt;
   *
   * @param tableName the name of the requested table
   * @param entryId the id of the requested entry
   * @return the requested table entry
   */
  private Map&lt;String,Object&gt; buildTableEntry(LookupTable lookupTable, LookupTableEntry lookupTableEntry) {
    Map&lt;String,Object&gt; entry = new TreeMap&lt;String,Object&gt;();

    entry.put("id", lookupTableEntry.getEntryId());
    entry.put("description", lookupTableEntry.getDescription());
    if (lookupTable.getProperties() != null &amp;&amp; lookupTable.getProperties().size() &gt; 0) {
      Iterator&lt;LookupTableProperty&gt; i = lookupTable.getProperties().iterator();
      while (i.hasNext()) {
        LookupTableProperty lookupTableProperty = i.next();
        int index = lookupTableProperty.getSequence();
        String name = lookupTableProperty.getName();
        if (StringUtils.isEmpty(lookupTableEntry.getProperty(index))) {
          entry.put(name, "");
        } else {
          entry.put(name, lookupTableEntry.getProperty(index));
        }
      }
    }

    return entry;
  }</pre>
<p>The current version just drops the value string into the map at this point, but I have visions of one day using the property&#8217;s &#8220;type&#8221; value to convert the data in to an Integer or Date or whatever object might be appropriate based on the &#8220;type&#8221; &#8230; but I was just too lazy to work all of that out right at the moment.</p>
<p>The service is set up to be configured by Spring, so to make it work, you need to add a little something to your <em>applicationContext.xml</em> file:</p>
<pre>&lt;bean id="lookupTableService" class="org.restafarian.core.service.LookupTableService"&gt;
  &lt;property name="lookupTableManager" ref="lookupTableManager"/&gt;
  &lt;property name="lookupTableEntryManager" ref="lookupTableEntryManager"/&gt;
  &lt;property name="context" value="${lookup.table.service.context}"/&gt;
&lt;/bean&gt;</pre>
<p>The service is set up to take advantage of <a title="Look-up Tables revisited" href="http://blog.restafarian.org/2009/01/look-up-tables-revisited/" target="_self">the recent addition of &#8220;context&#8221;</a> to the Look-up Table framework, so you have to specify which context you want to work with. If you need to access tables from more than one context, say the global context and your application&#8217;s specific context, you can simply define an instance of the service for each context required, reusing the same data manager beans for each:</p>
<pre>&lt;bean id="globalLookupTableService" class="org.restafarian.core.service.LookupTableService"&gt;
  &lt;property name="lookupTableManager" ref="lookupTableManager"/&gt;
  &lt;property name="lookupTableEntryManager" ref="lookupTableEntryManager"/&gt;
  &lt;property name="context" value="global"/&gt;
&lt;/bean&gt;

&lt;bean id="applLookupTableService" class="org.restafarian.core.service.LookupTableService"&gt;
  &lt;property name="lookupTableManager" ref="lookupTableManager"/&gt;
  &lt;property name="lookupTableEntryManager" ref="lookupTableEntryManager"/&gt;
  &lt;property name="context" value="${my.application.context}"/&gt;
&lt;/bean&gt;</pre>
<p>Once Spring injects the bean with all of the dependencies and turns it over to your application, then you can just use it to grab tables and table entries as needed:</p>
<pre>countryTable = globalLookupTableService.getTable("country");</pre>
<p>Now that that is done, I need to get busy putting it to work!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.restafarian.org/2009/06/look-up-tables-service-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Look-up Tables: LookupTableService</title>
		<link>http://blog.restafarian.org/2009/06/look-up-tables-lookuptableservice/</link>
		<comments>http://blog.restafarian.org/2009/06/look-up-tables-lookuptableservice/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 14:09:55 +0000</pubDate>
		<dc:creator>Restamon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[look-up tables]]></category>
		<category><![CDATA[service]]></category>

		<guid isPermaLink="false">http://blog.restafarian.org/?p=588</guid>
		<description><![CDATA[Most of my usage of the Look-up Table service that we created has been on the client side of things, but ocassionally, I will have a need to reference a look-up table back on the server, or in a stand-alone batch job. To accommodate that, I could utilize the HttpClient library and access the data [...]]]></description>
			<content:encoded><![CDATA[<p>Most of my usage of the <a title="Next Up: Universal look-up tables" href="http://blog.restafarian.org/2008/06/next-up-universal-look-up-tables/" target="_self">Look-up Table service</a> that we created has been on the client side of things, but ocassionally, I will have a need to reference a look-up table back on the server, or in a <a title="Stand-alone Spring application runner" href="http://blog.restafarian.org/2009/05/stand-alone-spring-application-runner/" target="_self">stand-alone batch job</a>. To accommodate that, I could utilize the <a title="http://hc.apache.org/httpclient-3.x/" href="http://hc.apache.org/httpclient-3.x/" target="_blank">HttpClient</a> library and access the data through the REST interface, but that&#8217;s a little overkill when I have access to the data right there via Java. Still, the manager classes in the service layer are not quite designed for the seamless access that I was looking for, so I finally broke down and created a <a title="http://trac2.assembla.com/restafarian/browser/core/trunk/src/main/java/org/restafarian/core/service/LookupTableService.java" href="http://trac2.assembla.com/restafarian/browser/core/trunk/src/main/java/org/restafarian/core/service/LookupTableService.java" target="_blank">Look-up Table service module</a>:</p>
<pre>package org.restafarian.core.service;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import org.apache.commons.lang.StringUtils;
import org.restafarian.core.beans.LookupTable;
import org.restafarian.core.beans.LookupTableEntry;
import org.restafarian.core.beans.LookupTableProperty;
import org.restafarian.core.manager.LookupTableEntryManager;
import org.restafarian.core.manager.LookupTableManager;

/**
 * &lt;p&gt;This is the LookupTable service.&lt;/p&gt;
 */
public class LookupTableService {
  private String context = null;
  private LookupTableManager lookupTableManager = null;
  private LookupTableEntryManager lookupTableEntryManager = null;

  /**
   * &lt;p&gt;Returns a list of lookup tables in this context.&lt;/p&gt;
   *
   * @return a list of lookup tables in this context
   */
  public List&lt;LookupTable&gt; getTables() {
    return lookupTableManager.findByContext(context);
  }

  /**
   * &lt;p&gt;Returns a list of lookup table names in this context.&lt;/p&gt;
   *
   * @return a list of lookup table names in this context
   */
  public List&lt;String&gt; getTableNames() {
    List&lt;String&gt; tableNames = new ArrayList&lt;String&gt;();

    List&lt;LookupTable&gt; tableInfo = lookupTableManager.findByContext(context);
    if (tableInfo != null) {
      Iterator&lt;LookupTable&gt; i = tableInfo.iterator();
      while (i.hasNext()) {
        tableNames.add(i.next().getTableName());
      }
    }

    return tableNames;
  }

  /**
   * &lt;p&gt;Returns the definition of the requested lookup table.&lt;/p&gt;
   *
   * @param tableName the name of the requested table
   * @return the definition of the requested lookup table
   */
  public LookupTable getTableDefinition(String tableName) {
    return lookupTableManager.findByContextAndTableName(context, tableName);
  }

  /**
   * &lt;p&gt;Returns the contents of the requested lookup table.&lt;/p&gt;
   *
   * @param tableName the name of the requested table
   * @return the contents of the requested lookup table
   */
  public Map&lt;String,Map&lt;String,Object&gt;&gt; getTable(String tableName) {
    Map&lt;String,Map&lt;String,Object&gt;&gt; table = null;

    LookupTable lookupTable = lookupTableManager.findByContextAndTableName(context, tableName);
    if (lookupTable != null) {
      table = new TreeMap&lt;String,Map&lt;String,Object&gt;&gt;();
      List&lt;LookupTableEntry&gt; lookupTableEntryList =
           lookupTableEntryManager.findByContextAndTableName(context, tableName);
      if (lookupTableEntryList != null &amp;&amp; lookupTableEntryList.size() &gt; 0) {
        Iterator&lt;LookupTableEntry&gt; i = lookupTableEntryList.iterator();
        while (i.hasNext()) {
          LookupTableEntry lookupTableEntry = i.next();
          table.put(lookupTableEntry.getEntryId(), buildTableEntry(lookupTable,
               lookupTableEntry));
        }
      }
    }

    return table;
  }

  /**
   * &lt;p&gt;Returns the requested table entry.&lt;/p&gt;
   *
   * @param tableName the name of the requested table
   * @param entryId the id of the requested entry
   * @return the requested table entry
   */
  public Map&lt;String,Object&gt; getTableEntry(String tableName, String entryId) {
    Map&lt;String,Object&gt; entry = null;

    LookupTable lookupTable = lookupTableManager.findByContextAndTableName(context, tableName);
    if (lookupTable != null) {
      LookupTableEntry lookupTableEntry =
           lookupTableEntryManager.findByContextTableEntry(context, tableName, entryId);
      if (lookupTableEntry != null) {
        entry = buildTableEntry(lookupTable, lookupTableEntry);
      }
    }

    return entry;
  }

  /**
   * &lt;p&gt;Returns the requested table entry.&lt;/p&gt;
   *
   * @param tableName the name of the requested table
   * @param entryId the id of the requested entry
   * @return the requested table entry
   */
  private Map&lt;String,Object&gt; buildTableEntry(LookupTable lookupTable, LookupTableEntry
         lookupTableEntry) {
    Map&lt;String,Object&gt; entry = new TreeMap&lt;String,Object&gt;();

    entry.put("id", lookupTableEntry.getEntryId());
    entry.put("description", lookupTableEntry.getDescription());
    if (lookupTable.getProperties() != null &amp;&amp; lookupTable.getProperties().size() &gt; 0) {
      Iterator&lt;LookupTableProperty&gt; i = lookupTable.getProperties().iterator();
      while (i.hasNext()) {
        LookupTableProperty lookupTableProperty = i.next();
        int index = lookupTableProperty.getSequence();
        String name = lookupTableProperty.getName();
        if (StringUtils.isEmpty(lookupTableEntry.getProperty(index))) {
          entry.put(name, "");
        } else {
          entry.put(name, lookupTableEntry.getProperty(index));
        }
      }
    }

    return entry;
  }

  /**
   * @param context the context to set
   */
  public void setContext(String context) {
    this.context = context;
  }

  /**
   * @param lookupTableManager the lookupTableManager to set
   */
  public void setLookupTableManager(LookupTableManager lookupTableManager) {
    this.lookupTableManager = lookupTableManager;
  }

  /**
   * @param lookupTableEntryManager the lookupTableEntryManager to set
   */
  public void setLookupTableEntryManager(LookupTableEntryManager lookupTableEntryManager) {
    this.lookupTableEntryManager = lookupTableEntryManager;
  }
}</pre>
<p>There&#8217;s obviously more that could be done here, but for now, it serves its purpose.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.restafarian.org/2009/06/look-up-tables-lookuptableservice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
