<?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>Cameron Stokes's Blog</title>
	<atom:link href="http://cameronstokes.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://cameronstokes.com</link>
	<description>A blog by Cameron Stokes.</description>
	<lastBuildDate>Tue, 24 Aug 2010 04:02:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Replacement UPS batteries and RefurbUPS.com</title>
		<link>http://cameronstokes.com/2010/08/23/replacement-ups-batteries-refurbups-com/</link>
		<comments>http://cameronstokes.com/2010/08/23/replacement-ups-batteries-refurbups-com/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 03:29:29 +0000</pubDate>
		<dc:creator>Cameron Stokes</dc:creator>
				<category><![CDATA[diy]]></category>
		<category><![CDATA[geek]]></category>

		<guid isPermaLink="false">http://cameronstokes.com/?p=1040</guid>
		<description><![CDATA[The tldr version is&#8230;RefurbUPS.com is awesome and saved me over $80 off buying original manufacturer batteries and over $200 off buying all new UPS units. Read on for the full story.
Several years back I purchased two uninterruptible power supply units (UPS) for my home file-server and firewall. The idea, of course, was to prevent these [...]]]></description>
			<content:encoded><![CDATA[<p><em>The <a href="http://en.wiktionary.org/wiki/TLDR" onclick="javascript:pageTracker._trackPageview ('/outbound/en.wiktionary.org');">tldr</a> version is&#8230;<a href="http://www.refurbups.com/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.refurbups.com');">RefurbUPS.com</a> is awesome and saved me over $80 off buying original manufacturer batteries and over $200 off buying all new UPS units. Read on for the full story.</em></p>
<p>Several years back I purchased two <a href="http://en.wikipedia.org/wiki/Uninterruptible_power_supply" onclick="javascript:pageTracker._trackPageview ('/outbound/en.wikipedia.org');">uninterruptible power supply </a>units (UPS) for my home file-server and firewall. The idea, of course, was to prevent these systems from experiencing temporary power interruptions and potentially causing file corruption in the case of my file-server or just being a nuisance for the firewall. Last year both units died within a month of each other. I couldn&#8217;t believe it&#8230; I was convinced they had a time trigger to fail after X number of years in a ruse to get customers to spend more money. Not wanting to fall for this, I started looking for alternatives.</p>
<p>A new, comparable UPS would cost approximately $150 (these were high-end models) and I certainly wasn&#8217;t excited about buying two.  Replacement batteries from the manufacturer would have cost approximately $80 each so I was still looking at roughly $160. I looked around at replacement battery sites and was largely unimpressed. Let&#8217;s just say the site design for several sites left me questioning their credibility. I finally found RefurbUPS.com and was sold when I found their instructional video for how to replace the batteries. It wasn&#8217;t a complicated procedure but that gave me the warm, fuzzy feeling I was looking for to buy from them. Total price from RefurbUPS.com including shipping was $90.29 for two sets of batteries.</p>
<p>After receiving the replacement batteries I installed them and was dismayed when the UPS started beeping and the <em>Replace Battery</em> LED lit after being turned on. I re-installed them a few times with the same results. I watched the instructional video again, realizing it was hard to mess up a two and a half step process, and was stumped. My one thought was maybe the UPS needed to charge a bit. I left the unit plugged in but turned off overnight and when I checked the next day all was well.  The UPS turned on fine, no beeps, and when I hooked it up to my file-server it said it had a full charge.</p>
<p>The UPS have been up and running with the new batteries for a few months now and are holding strong.</p>
]]></content:encoded>
			<wfw:commentRss>http://cameronstokes.com/2010/08/23/replacement-ups-batteries-refurbups-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Best Present Ever</title>
		<link>http://cameronstokes.com/2010/07/18/best-present-ever/</link>
		<comments>http://cameronstokes.com/2010/07/18/best-present-ever/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 23:47:40 +0000</pubDate>
		<dc:creator>Cameron Stokes</dc:creator>
				<category><![CDATA[beer]]></category>

		<guid isPermaLink="false">http://cameronstokes.com/?p=1026</guid>
		<description><![CDATA[My girlfriend (Rhonda) and I recently celebrated an anniversary and she completely outdid herself this year.  Knowing my obsession for beer, she gave me a personalized glassware set complete with pitcher, two pilsner glasses, and two Frankfurt beer mugs.  Here&#8217;s a shot of one of the Frankfurt beer mugs:
Rhonda purchased the set through [...]]]></description>
			<content:encoded><![CDATA[<p>My girlfriend (Rhonda) and I recently celebrated an anniversary and she completely outdid herself this year.  Knowing my obsession for beer, she gave me a personalized glassware set complete with pitcher, two pilsner glasses, and two Frankfurt beer mugs.  Here&#8217;s a shot of one of the Frankfurt beer mugs:</p>
<div id="attachment_1033" class="wp-caption aligncenter" style="width: 490px"><a href="http://cameronstokes.com/wp-content/uploads/2010/06/home-brewery.jpg"><img src="http://cameronstokes.com/wp-content/uploads/2010/06/home-brewery.jpg" alt="" title="My awesome glassware." width="480" height="321" class="size-full wp-image-1033" /></a><p class="wp-caption-text">My awesome glassware.</p></div>
<p>Rhonda purchased the set through <a href="http://www.theglassfox.com/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.theglassfox.com');">The Glass Fox</a>.  She called them prior to ordering and asked about personalizing beyond the normal options on the site and they were able to accommodate exactly what she wanted.</p>
<p>I highly recommend them and expect to use them again in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://cameronstokes.com/2010/07/18/best-present-ever/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pandora Bookmarklet</title>
		<link>http://cameronstokes.com/2010/05/30/pandora-bookmarklet/</link>
		<comments>http://cameronstokes.com/2010/05/30/pandora-bookmarklet/#comments</comments>
		<pubDate>Mon, 31 May 2010 01:28:22 +0000</pubDate>
		<dc:creator>Cameron Stokes</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[geek]]></category>

		<guid isPermaLink="false">http://cameronstokes.com/?p=1003</guid>
		<description><![CDATA[Every time I listen to Pandora I open the site in a new window and scroll and resize the window to fit the player just right and hide the noise (ads) on the page.  I finally sat down and put together a bookmarklet to do this for me.  It&#8217;s not perfect, but is [...]]]></description>
			<content:encoded><![CDATA[<p>Every time I listen to <a href="http://www.pandora.com/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.pandora.com');">Pandora</a> I open the site in a new window and scroll and resize the window to fit the player just right and hide the noise (ads) on the page.  I finally sat down and put together a <a href="http://en.wikipedia.org/wiki/Bookmarklet" onclick="javascript:pageTracker._trackPageview ('/outbound/en.wikipedia.org');">bookmarklet</a> to do this for me.  It&#8217;s not perfect, but is good enough.  Right-click the link below and click Bookmark This Link (in Firefox) and you can use the same script to load Pandora and only see what you really care about, the music.</p>
<p><a href="javascript:function%20pandora(){window.open('http://pandora.com/#radio','_blank','width=725,height=340,scrollbars=1,location=0,menubar=0,titlebar=0,toolbar=0');}pandora();" onclick="javascript:pageTracker._trackPageview ('/outbound/pandora.com');">Bookmark This Link.</a></p>
<p>Here&#8217;s the code (prettified):</p>
<pre class="brush: javascript">
javascript: function pandora() {
    window.open( 'http://pandora.com/#radio',
                 '_blank',
                 'width=725,height=340,' +
                 'scrollbars=1,location=0,menubar=0,titlebar=0,toolbar=0'
    );
}
pandora();
</pre>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://cameronstokes.com/2010/05/30/pandora-bookmarklet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Euca2ools on Mac OS X</title>
		<link>http://cameronstokes.com/2010/05/11/installing-euca2ools-on-mac-os-x/</link>
		<comments>http://cameronstokes.com/2010/05/11/installing-euca2ools-on-mac-os-x/#comments</comments>
		<pubDate>Tue, 11 May 2010 23:38:33 +0000</pubDate>
		<dc:creator>Cameron Stokes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[geek]]></category>

		<guid isPermaLink="false">http://cameronstokes.com/?p=991</guid>
		<description><![CDATA[Having been bit by the cloud bug, I recently looked into the cloud computing software Eucalyptus.  Using the Ubuntu Enterprise Cloud distribution I setup a controller and a couple nodes and then went to install Euca2ools on my Macbook.  Following the instructions here, I soon ran into an issue.  Here is the [...]]]></description>
			<content:encoded><![CDATA[<p>Having been bit by the cloud bug, I recently looked into the cloud computing software <a href="http://en.wikipedia.org/wiki/Eucalyptus_%28computing%29" onclick="javascript:pageTracker._trackPageview ('/outbound/en.wikipedia.org');">Eucalyptus</a>.  Using the <a href="http://www.ubuntu.com/cloud/private" onclick="javascript:pageTracker._trackPageview ('/outbound/www.ubuntu.com');">Ubuntu Enterprise Cloud</a> distribution I setup a controller and a couple nodes and then went to install <a href="http://open.eucalyptus.com/wiki/Euca2oolsGuide_v1.1" onclick="javascript:pageTracker._trackPageview ('/outbound/open.eucalyptus.com');">Euca2ools</a> on my Macbook.  Following the instructions <a href="http://open.eucalyptus.com/wiki/Euca2oolsSourceInstall" onclick="javascript:pageTracker._trackPageview ('/outbound/open.eucalyptus.com');">here</a>, I soon ran into an issue.  Here is the error I received:<br />
<code><br />
stokesc-mbp:euca2ools-1.2 stokesc$ sudo make<br />
...<br />
Processing dependencies for euca2ools==1.0<br />
Finished processing dependencies for euca2ools==1.0<br />
install: root: Invalid argument<br />
make: *** [install] Error 67<br />
stokesc-mbp:euca2ools-1.2 stokesc$<br />
</code><br />
A quick internet search didn&#8217;t reveal too much but I soon found my way into the <em>MakeFile</em> and noticed the group for the install command seemed off.  Knowing Mac OS X&#8217;s ancestry is <a href="http://en.wikipedia.org/wiki/Berkeley_Software_Distribution" onclick="javascript:pageTracker._trackPageview ('/outbound/en.wikipedia.org');">BSD</a> and from my past experience with OpenBSD, I knew the <em>root</em> group did not exist in the BSD operating system and was in fact named <em>wheel</em>.  I changed all references to the group <em>root</em> (the -g option), but left the owner references alone (the -o option) and Euca2ools was soon installed.  Here is the snippet from my new MakeFile:<br />
<code><br />
...<br />
	@install -g wheel -o root -m 755 -d $(PREFIX)/bin<br />
	@install -g wheel -o root -m 755  bin/* $(PREFIX)/bin/<br />
	@install -g wheel -o root -m 755 -d $(PREFIX)/man/man1<br />
	@if [ -d $(MANDIR) ]; then install -g wheel -o root -m 644  $(MANDIR)/* $(PREFIX)/man/man1; fi<br />
	@if [ -d $(BASH_COMPLETION) ]; then install -g wheel -o root -m 644  $(UTILDIR)/* $(BASH_COMPLETION); fi<br />
...<br />
</code><br />
I opened bug <a href="https://bugs.launchpad.net/eucalyptus/+bug/558420" onclick="javascript:pageTracker._trackPageview ('/outbound/bugs.launchpad.net');">558420</a> with the Eucalyptus project to address this.  As of this post, this issue affects version 1.2 of the Euca2ools download and likely previous versions.</p>
]]></content:encoded>
			<wfw:commentRss>http://cameronstokes.com/2010/05/11/installing-euca2ools-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m on Google Street View</title>
		<link>http://cameronstokes.com/2010/04/14/im-on-google-street-view/</link>
		<comments>http://cameronstokes.com/2010/04/14/im-on-google-street-view/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 03:00:23 +0000</pubDate>
		<dc:creator>Cameron Stokes</dc:creator>
				<category><![CDATA[google]]></category>
		<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://cameronstokes.com/?p=976</guid>
		<description><![CDATA[Almost eighteen months ago, I found the Google Street View guy near work and followed him for a bit trying to stay in view.  For several weeks following I checked the location online nearly every day and eventually gave up.  Thanks to a commenter on my original post I checked again and we are there.  [...]]]></description>
			<content:encoded><![CDATA[<p>Almost eighteen months ago, I found the Google Street View guy near work and followed him for a bit trying to stay in view.  For several weeks following I checked the location online nearly every day and eventually gave up.  Thanks to a commenter on my original post I checked again and we are there.  They removed the frames of us hanging out the window talking to the driver, but there I am in the driver seat.<a href="http://cameronstokes.com/wp-content/uploads/2010/04/google-street-view.png"><br />
</a><a href="http://cameronstokes.com/wp-content/uploads/2010/04/google-street-view.jpg"><img class="aligncenter size-full wp-image-978" title="google-street-view" src="http://cameronstokes.com/wp-content/uploads/2010/04/google-street-view.jpg" alt="" width="480" height="371" /></a>Click <a href="http://local.google.com/?ie=UTF8&amp;ll=33.931361,-84.337342&amp;spn=0,0.021973&amp;z=16&amp;layer=c&amp;cbll=33.931274,-84.337338&amp;panoid=vlMcaMbCrpgMsIM3Psm1SA&amp;cbp=12,263.04,,0,21.7" onclick="javascript:pageTracker._trackPageview ('/outbound/local.google.com');">here</a> to see us on the map.  My original post is <a href="../2008/08/16/im-going-to-be-on-google-street-view-i-hope/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cameronstokes.com/2010/04/14/im-on-google-street-view/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beer from afar</title>
		<link>http://cameronstokes.com/2010/03/06/beer-from-afar/</link>
		<comments>http://cameronstokes.com/2010/03/06/beer-from-afar/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 15:35:42 +0000</pubDate>
		<dc:creator>Cameron Stokes</dc:creator>
				<category><![CDATA[beer]]></category>

		<guid isPermaLink="false">http://cameronstokes.com/?p=960</guid>
		<description><![CDATA[I&#8217;m a beer lover.  I don&#8217;t hide it, I don&#8217;t deny it, I think and talk way too much about beer.  The other night I had a dream that our Scotch ale (currently in the fermenter) turned out to be the best beer ever.  One of the many  upsides to this obsession is that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a beer lover.  I don&#8217;t hide it, I don&#8217;t deny it, I think and talk way too much about beer.  The other night I had a dream that our Scotch ale (currently in the fermenter) turned out to be the best beer ever.  One of the many  upsides to this obsession is that friends and family know how much I love beer and help feed my obsession.  Case in point&#8230;just this week I received two special deliveries!</p>
<p>The first delivery was from a friend who just returned from  California.</p>
<div id="attachment_961" class="wp-caption aligncenter" style="width: 490px"><img class="size-full wp-image-961" title="beer-from-california" src="http://cameronstokes.com/wp-content/uploads/2010/03/beer-from-california.jpg" alt="California Delivery" width="480" height="321" /><p class="wp-caption-text">California Delivery</p></div>
<p>From left to right: Brew Free or Die IPA from <a href="http://www.21st-amendment.com/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.21st-amendment.com');">21st Amendment Brewery</a>, Hitachino Nest White Ale and Hitachino Nest Red Rice Ale from <a href="http://www.kodawari.cc/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.kodawari.cc');">Kiuchi Brewery</a>, and Pliny the Elder from <a href="http://www.russianriverbrewing.com/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.russianriverbrewing.com');">Russian River Brewing Company</a>.</p>
<p>The next delivery came by way of my Grandmother from North Carolina.  There&#8217;s a great little beer store in her town and she&#8217;s recently started going and asking the owner about beers that I might like.</p>
<div id="attachment_962" class="wp-caption aligncenter" style="width: 490px"><img class="size-full wp-image-962" title="beer-from-north-carolina" src="http://cameronstokes.com/wp-content/uploads/2010/03/beer-from-north-carolina.jpg" alt="Beer from North Carolina" width="480" height="283" /><p class="wp-caption-text">North Carolina Delivery</p></div>
<p>From left to right again: Fourteen Ale from <a href="http://www.weyerbacher.com/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.weyerbacher.com');">Wyerbacher</a>, Celebrator Doppelbock from <a href="http://www.ayinger.de/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.ayinger.de');">Ayinger Bier</a>, Dragon&#8217;s Milk from <a href="http://www.newhollandbrew.com/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.newhollandbrew.com');">New Holland Brewing Company</a>, Urthel Samaranth from <a href="http://www.urthel.com/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.urthel.com');">De Leyerth Brouwerijen</a>, and Samichlaus from <a href="http://www.schloss-eggenberg.at/de/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.schloss-eggenberg.at');">Castle Brewery Eggenberg</a>.</p>
<p>Some of these I  could likely find in Georgia but don&#8217;t think I&#8217;ve seen any of them before.  I&#8217;m fairly certain I could find the Hitachino Nest beers locally but I  know for a fact 21st Amendment and Russian River do not distribute to  Georgia, though <a href="http://www.atlantabeermaster.com/?p=976" onclick="javascript:pageTracker._trackPageview ('/outbound/www.atlantabeermaster.com');">I hear</a> 21st  Amendment will be starting soon.  I can&#8217;t wait to try each of these beers but am most excited about Dragon&#8217;s Milk, Pliny the Elder, and Fourteen Ale.</p>
<p>In other beer news, I&#8217;ve posted photos of the <a href="http://www.premiereventslive.com/winterbeercarnival/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.premiereventslive.com');">Winter Beer Carnival</a> Rhonda and I attend last weekend; it was a blast!  Photos are <a href="http://cameronstokes.com/gallery/winter-beer-carnival-february-2010/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cameronstokes.com/2010/03/06/beer-from-afar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Announcing kui!</title>
		<link>http://cameronstokes.com/2010/02/05/announcing-kui/</link>
		<comments>http://cameronstokes.com/2010/02/05/announcing-kui/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 03:50:23 +0000</pubDate>
		<dc:creator>Cameron Stokes</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[kui]]></category>

		<guid isPermaLink="false">http://cameronstokes.com/?p=937</guid>
		<description><![CDATA[I am excited to announce the initial release of kui!  kui is a modern, browser-based administration tool for Java applications supporting the JMX specification.  While tools already exist to monitor Java applications using JMX, kui takes a different approach to cure your JMX woes!
Key features of kui are:

Browser-based: Once installed, all you need is a [...]]]></description>
			<content:encoded><![CDATA[<p>I am excited to announce the initial release of kui!  kui is a modern, browser-based administration tool for Java applications supporting the <span class="mw-redirect">JMX</span> specification.  While tools already exist to monitor Java applications using JMX, kui takes a different approach to cure your JMX woes!</p>
<p>Key features of kui are:</p>
<ul>
<li><strong>Browser-based</strong>: Once installed, all you need is a browser to access your MBeans.</li>
<li><strong>Easy-to-use interface</strong>: kui provides a familiar and consistent interface for viewing and administering your MBeans.</li>
<li><strong>Standards based</strong>: kui works with a wide variety of application servers and browsers.</li>
<li><strong>Pure Java and JavaScript</strong>: kui is written using Java and JavaScript for easy modifications.</li>
<li><strong>Open source</strong>: kui is distributed under the New BSD License.</li>
</ul>
<p>Head on over to the <a href="http://www.marker55.com/kui/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.marker55.com');">kui website</a> for more information, screenshots, and available downloads.</p>
]]></content:encoded>
			<wfw:commentRss>http://cameronstokes.com/2010/02/05/announcing-kui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting things done with a list</title>
		<link>http://cameronstokes.com/2009/12/30/getting-things-done-with-a-list/</link>
		<comments>http://cameronstokes.com/2009/12/30/getting-things-done-with-a-list/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 23:38:40 +0000</pubDate>
		<dc:creator>Cameron Stokes</dc:creator>
				<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://cameronstokes.com/?p=920</guid>
		<description><![CDATA[I consider myself a very focused and productive person, but over the past couple of weeks I&#8217;ve realized that I am much more productive when working from a task list.  The list keeps my mind from wondering to other tasks and I get a great satisfaction in checking tasks off  and reviewing the list [...]]]></description>
			<content:encoded><![CDATA[<p>I consider myself a very focused and productive person, but over the past couple of weeks I&#8217;ve realized that I am much more productive when working from a task list.  The list keeps my mind from wondering to other tasks and I get a great satisfaction in checking tasks off  and reviewing the list at the end of the day to see what I have accomplished.  I have some ideas on how to improve my list (and digitize it); let&#8217;s see how much more productive I can get!</p>
<p>This week&#8217;s task list:</p>
<div id="attachment_921" class="wp-caption aligncenter" style="width: 490px"><img class="size-full wp-image-921" title="to-do-list" src="http://cameronstokes.com/wp-content/uploads/2009/12/todo-list.jpg" alt="My latest to-do list" width="480" height="360" /><p class="wp-caption-text">This week&#39;s task list</p></div>
]]></content:encoded>
			<wfw:commentRss>http://cameronstokes.com/2009/12/30/getting-things-done-with-a-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Intercepting controllers in Spring MVC</title>
		<link>http://cameronstokes.com/2009/12/26/intercepting-controllers-in-spring-mvc/</link>
		<comments>http://cameronstokes.com/2009/12/26/intercepting-controllers-in-spring-mvc/#comments</comments>
		<pubDate>Sun, 27 Dec 2009 02:00:51 +0000</pubDate>
		<dc:creator>Cameron Stokes</dc:creator>
				<category><![CDATA[software development]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://cameronstokes.com/?p=886</guid>
		<description><![CDATA[Working on my latest project the past couple days I was trying to figure out a way to enforce authentication for some requests but not others.  I first wrote a Filter but when I started mapping the filter to my specific URLs I realized how tedious this could become.  I then remembered that Spring allowed [...]]]></description>
			<content:encoded><![CDATA[<p>Working on <a href="/2009/10/12/new-project/">my latest project</a> the past couple days I was trying to figure out a way to enforce authentication for some requests but not others.  I first wrote a <a href="http://java.sun.com/products/servlet/Filters.html" onclick="javascript:pageTracker._trackPageview ('/outbound/java.sun.com');">Filter</a> but when I started mapping the filter to my specific URLs I realized how tedious this could become.  I then remembered that <a href="http://www.springsource.org/about" onclick="javascript:pageTracker._trackPageview ('/outbound/www.springsource.org');">Spring</a> allowed for interceptors in its web framework and after a quick glance through their documentation I found <a href="http://static.springsource.org/spring/docs/2.5.x/reference/mvc.html#mvc-handlermapping-interceptor" onclick="javascript:pageTracker._trackPageview ('/outbound/static.springsource.org');">the section I was looking for</a>.  Unfortunately this still wasn&#8217;t exactly what I needed as Spring applies your interceptors to all requests configured in your handler mapping.  Looking at the <a href="http://static.springsource.org/spring/docs/2.5.x/api/index.html" onclick="javascript:pageTracker._trackPageview ('/outbound/static.springsource.org');">HandlerInterceptor API</a> I found I had access to the handler that was being processed and I just needed to decorate my handlers that needed authentication and adjust my interceptor to first check the handler.  I decided to create an empty Interface named <em>AuthenticatedController</em> which my controllers could implement to indicate they needed to be protected from unauthenticated access.  You could also do this using annotations, but here&#8217;s my code:</p>
<p><em>AuthenticatedController.java</em></p>
<pre class="brush: java">public interface AuthenticatedController {
    // This is empty on purpose.
}</pre>
<p><em>SimpleController.java</em></p>
<pre class="brush: java">import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

public class StateController implements AuthenticatedController {

    public ModelAndView handleRequest( final HttpServletRequest httpServletRequest,
            final HttpServletResponse httpServletResponse ) throws Exception {
        ...
    }

}</pre>
<p><em>AuthenticationInterceptor.java</em></p>
<pre class="brush: java">import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class AuthenticationInterceptor extends HandlerInterceptorAdapter {

    public boolean preHandle( HttpServletRequest request, HttpServletResponse response,
            Object handler ) throws Exception {

        if ( !( handler instanceof AuthenticatedController ) ) {
            // Authentication not needed, allow request to continue.
            return true;
        }

        boolean isAuthenticated = checkAuthentication(...);

        if ( !isAuthenticated ) {
            // User is not authenticated, handle response as needed, and halt processing.
            response.setStatus( HttpServletResponse.SC_FORBIDDEN );
            return false;
        }

        // User is authenticated, allow request to continue.
        return true;
    }
}</pre>
<p><em>spring-beans.xml</em></p>
<pre class="brush: xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt;

&lt;bean name="authenticationInterceptor" class="custom.AuthenticationInterceptor" /&gt;

&lt;bean name="urlMapping"
    class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;
    &lt;property name="interceptors"&gt;
         &lt;list&gt;
	     &lt;ref bean="authenticationInterceptor" /&gt;
	&lt;/list&gt;
    &lt;/property&gt;
    &lt;property name="mappings"&gt;
	&lt;props&gt;
            &lt;prop key="/controller1.json"&gt;controller1&lt;/prop&gt;
            &lt;prop key="/controller2.json"&gt;controller2&lt;/prop&gt;
            &lt;prop key="/controller3.json"&gt;controller3&lt;/prop&gt;
        &lt;/props&gt;
    &lt;/property&gt;
&lt;/bean&gt;

&lt;/beans&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://cameronstokes.com/2009/12/26/intercepting-controllers-in-spring-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using svnversion from Ant</title>
		<link>http://cameronstokes.com/2009/12/12/using-svnversion-from-ant/</link>
		<comments>http://cameronstokes.com/2009/12/12/using-svnversion-from-ant/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 15:35:10 +0000</pubDate>
		<dc:creator>Cameron Stokes</dc:creator>
				<category><![CDATA[software development]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[ant maven subversion]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://cameronstokes.com/?p=869</guid>
		<description><![CDATA[At work we use a combination of Subversion (svn), Maven, and Ant to build and deploy our applications  and integrate the svn revision number into our deployment packages.  As an example, if we&#8217;re packaging our callcenter application our build scripts will create a callcenter-7175.jar package.  This makes it easy for us to upgrade and [...]]]></description>
			<content:encoded><![CDATA[<p>At work we use a combination of <em><a href="http://en.wikipedia.org/wiki/Subversion_%28software%29" onclick="javascript:pageTracker._trackPageview ('/outbound/en.wikipedia.org');">Subversion (svn)</a></em>, <em><a href="http://en.wikipedia.org/wiki/Apache_Maven" onclick="javascript:pageTracker._trackPageview ('/outbound/en.wikipedia.org');">Maven</a></em>, and <em><a href="http://en.wikipedia.org/wiki/Apache_Ant" onclick="javascript:pageTracker._trackPageview ('/outbound/en.wikipedia.org');">Ant</a></em> to build and deploy our applications  and integrate the <em>svn</em> revision number into our deployment packages.  As an example, if we&#8217;re packaging our <em>callcenter</em> application our build scripts will create a <em>callcenter-7175.jar</em> package.  This makes it easy for us to upgrade and rollback between versions as needed.</p>
<p>The   <em>svnversion</em> program makes it easy to get the revision number of your working copy by simply executing the program:</p>
<pre>macbookpro:rel-091105 stokesc$ svnversion
7175</pre>
<p>To use this from <em>Ant</em> we can use the <a href="http://ant.apache.org/manual/CoreTasks/exec.html" onclick="javascript:pageTracker._trackPageview ('/outbound/ant.apache.org');">exec</a> task.  The example below will execute <em>svnversion</em> and capture its output into the <em>Ant</em> property <em>repository.revision</em> which is used later on in our build script:</p>
<pre class="brush: xml">&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
&lt;project name="Build Script" default="make" basedir="."&gt;

    &lt;target name="make"&gt;

        &lt;!-- Get current working directory. --&gt;
        &lt;exec executable="pwd" outputproperty="dir.root" /&gt;

        &lt;!-- Get subversion revision number. --&gt;
        &lt;exec executable="svnversion" outputproperty="repository.revision" /&gt;

        &lt;echo message="Repository revision is ${repository.revision}" /&gt;

    &lt;/target&gt;

&lt;/project&gt;</pre>
<p>This worked well for us for a few years but when we needed to build from an older branch the revision number wasn&#8217;t representative of the last revision in the branch.  Looking at the options for <em>svnversion</em> I found passing <em>-c</em> will return the revision number of the last change rather than the current revision which is what we really wanted.</p>
<pre>macbookpro:rel-091105 stokesc$ svnversion -c
1:6985</pre>
<p>You can see the difference in revision numbers from this command versus the one above, but this still isn&#8217;t perfect due to the starting revision number that&#8217;s been added.  A little change to our <em>Ant</em> script can strip this off for us.  Here we use the <a href="http://ant.apache.org/manual/CoreTypes/redirector.html" onclick="javascript:pageTracker._trackPageview ('/outbound/ant.apache.org');">redirector</a> and <a href="http://ant.apache.org/manual/CoreTypes/filterchain.html" onclick="javascript:pageTracker._trackPageview ('/outbound/ant.apache.org');">filterchain</a> types and a <a href="http://en.wikipedia.org/wiki/Regular_expression" onclick="javascript:pageTracker._trackPageview ('/outbound/en.wikipedia.org');">regular expression</a> to modify the output.</p>
<pre class="brush: xml">&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
&lt;project name="Build Script" default="make" basedir="."&gt;

    &lt;target name="make"&gt;

        &lt;!-- Get current working directory. --&gt;
        &lt;exec executable="pwd" outputproperty="dir.root" /&gt;

        &lt;!-- Get subversion revision number. --&gt;
        &lt;exec executable="svnversion" outputproperty="repository.revision"&gt;
            &lt;!-- Specify '-c' to get last changed rather than current revisions. --&gt;
            &lt;arg value="-c" /&gt;
            &lt;!-- Use redirector/filterchain to parse output.
                 svnversion -c will return output in format [initial]:[current]
                 and we want to strip off [initial]: --&gt;
            &lt;redirector&gt;
                &lt;outputfilterchain&gt;
                    &lt;tokenfilter&gt;
                        &lt;replaceregex pattern="[0-9]+\:" replace="" /&gt;
                    &lt;/tokenfilter&gt;
                &lt;/outputfilterchain&gt;
            &lt;/redirector&gt;
        &lt;/exec&gt;

        &lt;echo message="Repository revision is ${repository.revision}" /&gt;

    &lt;/target&gt;

&lt;/project&gt;</pre>
<p>We&#8217;re now able to go back and package older versions of our application with a true indication of their <em>svn</em> revision.</p>
]]></content:encoded>
			<wfw:commentRss>http://cameronstokes.com/2009/12/12/using-svnversion-from-ant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
