<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Exploring the Meaty Bits...</title>
	<atom:link href="http://thestewscope.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://thestewscope.wordpress.com</link>
	<description>Inspired by food, peer-pressure, blog-envy and a quill shortage in the north.</description>
	<lastBuildDate>Mon, 09 Jan 2012 21:49:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='thestewscope.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Exploring the Meaty Bits...</title>
		<link>http://thestewscope.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://thestewscope.wordpress.com/osd.xml" title="Exploring the Meaty Bits..." />
	<atom:link rel='hub' href='http://thestewscope.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Supporting Multiple Versions of Ruby on OSX 10.6.7</title>
		<link>http://thestewscope.wordpress.com/2011/04/25/supporting-multiple-versions-of-ruby-on-osx-10-6-7/</link>
		<comments>http://thestewscope.wordpress.com/2011/04/25/supporting-multiple-versions-of-ruby-on-osx-10-6-7/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 23:44:20 +0000</pubDate>
		<dc:creator>Stew Welbourne</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[1.9]]></category>
		<category><![CDATA[10.6]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://thestewscope.wordpress.com/?p=286</guid>
		<description><![CDATA[I wanted a clean way of upgrading the default ruby 1.8.7 installation on my new Mac OSX 10.6.7 host, and couldn&#8217;t locate a decent explanation. As a result I&#8217;ve spent surprisingly little time unpicking the dependencies and getting my shiny new ruby 1.9.x installation sorted. Here&#8217;s how I achieved that. (Please note you need to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=286&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I wanted a clean way of upgrading the default ruby 1.8.7 installation on my new Mac OSX 10.6.7 host, and couldn&#8217;t locate a decent explanation. As a result I&#8217;ve spent surprisingly little time unpicking the dependencies and getting my shiny new ruby 1.9.x installation sorted. Here&#8217;s how I achieved that. (Please note you need to have XCode installed if you plan to build the ruby installation from source.)</p>
<p><img class="alignnone" title="tidy" src="http://www.re-sourceful.co.uk/images/cathead/tidy_illustration.jpg" alt="" width="452" height="249" /></p>
<p>Firstly it&#8217;s important to understand the landscape when considering this upgrade. Firstly, the existing 1.8.x ruby installation exists in the <strong>/System/Library/Frameworks/Ruby.framework</strong> location. Beneath that root folder is a <strong>Versions</strong> folder. Versions contained another folder called <strong>1.8</strong> (referring to the version of ruby contained therein) and a symlink by the name of <strong>Current</strong>, which pointed to that 1.8 folder.</p>
<p><strong>Decision 1</strong>: <em>Seemed like a good idea to place all my future versions of ruby in version-aware subfolders in this </em><strong><em>&#8230;/Ruby.framework/Versions</em></strong><em> folder</em>.</p>
<p>Next thing to understand is that all of the key commands relating to using the ruby framework (e.g. ruby, gem, irb, erb, &#8230;) live in the <strong>/usr/bin</strong> folder. Each of these commands are symlinks to executable files within the current ruby framework subtree. The convention here can be seen in this example:</p>
<pre>/usr/bin/ruby -&gt; /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby</pre>
<p>Next thing to understand is that all of the key commands relating to using the ruby framework (e.g. ruby, gem, irb, erb, &#8230;) live in the <strong>/usr/bin</strong> folder. Each of these commands are symlinks to executable files within the</p>
<p><strong>Decision</strong> 2: <em>If I correctly install all my subsequent versions of ruby into this same location then it should be possible for me to simply modify the <strong>Current</strong> symlink in the <strong>&#8230;/Ruby.framework/Versions</strong> folder to set the active ruby version I wish to use. All /usr/bin dependencies can simply resolve to the correct subfolder beneath the frameworks root</em>.</p>
<p>Next I downloaded the latest source distribution from somewhere, in my case I used the 1.9.2 source from here (<a href="http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/" rel="nofollow">http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/</a>). After downloading and unpacking into a temporary folder, I then executed the following commands from the root of the ruby source folder structure:</p>
<ol>
<li><strong>sudo mkdir /System/Frameworks/Library/Ruby.framework/Versions/1.9.2/usr</strong> to create the new version subtree root.</li>
<li><strong>./configure &#8211;prefix=/System/Frameworks/Library/Ruby.framework/Versions/1.9.2/usr</strong> to instruct the make utility to use my new installation folder for the deployment of the newly compiled binaries.</li>
<li><strong>sudo make &amp;&amp; make install</strong> to create my new subtree and binaries beneath my newly created target.</li>
</ol>
<div>When all that is done, assuming it goes OK, you will have all the necessary ruby executables in the subfolders beneath <strong>&#8230;/1.9.2/usr</strong> location but your system will still be set to use the &#8216;Current&#8217; version which in my case was the pre-installed 1.8.7 version.</div>
<div>Final thing to do is to re-link the &#8230;/Ruby.framework/Versions/Current link to the 1.9.2 folder. I simply executed the following from the &#8230;/Ruby.framework/Versions folder:</div>
<div>
<ol>
<li><strong>sudo unlink Current</strong></li>
<li><strong>sudo ln -s 1.9.2 Current</strong></li>
</ol>
<div>When I now run my ruby commands &#8211; they report the correct version of 1.9.2. When and if I decide to revert to another version I can simply modify this Current link, and that can be made even easier with some alias&#8217;s and other bash helpers.</div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thestewscope.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thestewscope.wordpress.com/286/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=286&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thestewscope.wordpress.com/2011/04/25/supporting-multiple-versions-of-ruby-on-osx-10-6-7/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6b9b3c5b60e4b37d2e7698a3c75fbedb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stew Welbourne</media:title>
		</media:content>

		<media:content url="http://www.re-sourceful.co.uk/images/cathead/tidy_illustration.jpg" medium="image">
			<media:title type="html">tidy</media:title>
		</media:content>
	</item>
		<item>
		<title>New Semantic Integration Blog&#8230;</title>
		<link>http://thestewscope.wordpress.com/2010/09/07/new-semantic-integration-blog/</link>
		<comments>http://thestewscope.wordpress.com/2010/09/07/new-semantic-integration-blog/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 23:56:41 +0000</pubDate>
		<dc:creator>Stew Welbourne</dc:creator>
				<category><![CDATA[soa]]></category>
		<category><![CDATA[dxsi]]></category>
		<category><![CDATA[eai]]></category>
		<category><![CDATA[owl]]></category>
		<category><![CDATA[rdf]]></category>
		<category><![CDATA[xml schema]]></category>
		<category><![CDATA[xsd]]></category>

		<guid isPermaLink="false">http://thestewscope.wordpress.com/?p=284</guid>
		<description><![CDATA[I have recently created a secondary and more specialised blog called &#8216;Semantic Integration Therapy&#8216; given my focus is now beginning to shift to this particular discipline. Semantic Integration in my terminology and context relates to achieving more effective application integration and SOA solutions by extending the traditional integration contract (XSD and informal documentation) with a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=284&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I have recently created a secondary and more specialised blog called &#8216;<a title="Semantic Integration Therapy" href="http://semanticintegration.wordpress.com/" target="_blank">Semantic Integration Therapy</a>&#8216; given my focus is now beginning to shift to this particular discipline. Semantic Integration in my terminology and context relates to achieving more effective application integration and SOA solutions by extending the traditional integration contract (XSD and informal documentation) with a more sementically aware mechanism. As such I&#8217;m now deep-diving into the use of XMLSchema pluse Schematron, RDF, OWL and commercial tooling such as Progress DXSI. There is a heavy overlap with the Semantic Web Community, but my focus is moreso on the transactional integration space within the Enterprise, as opposed to the holistic principles of the third generation or semantic web.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thestewscope.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thestewscope.wordpress.com/284/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=284&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thestewscope.wordpress.com/2010/09/07/new-semantic-integration-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6b9b3c5b60e4b37d2e7698a3c75fbedb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stew Welbourne</media:title>
		</media:content>
	</item>
		<item>
		<title>Xerces DOMParser funny&#8230;</title>
		<link>http://thestewscope.wordpress.com/2010/05/01/xerces-domparser-funny/</link>
		<comments>http://thestewscope.wordpress.com/2010/05/01/xerces-domparser-funny/#comments</comments>
		<pubDate>Sat, 01 May 2010 22:19:30 +0000</pubDate>
		<dc:creator>Stew Welbourne</dc:creator>
				<category><![CDATA[xml]]></category>
		<category><![CDATA[DOMparser]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[xerces]]></category>

		<guid isPermaLink="false">http://thestewscope.wordpress.com/?p=279</guid>
		<description><![CDATA[Working with Xerces DOMParser I have noticed a weird exception being reported arbitrarily by certain instance documents. This exception message is &#8220;The processing instruction target matching &#8220;[xX][mM][lL]&#8221; is not allowed.&#8220;. Looking at the XML source file it does have the normal &#60;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&#62; prefix so was initially unsure why this exception was firing every [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=279&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://thestewscope.files.wordpress.com/2010/05/sleuth.jpg"><img class="alignleft size-thumbnail wp-image-280" title="sleuth" src="http://thestewscope.files.wordpress.com/2010/05/sleuth.jpg?w=101&#038;h=150" alt="" width="101" height="150" /></a>Working with Xerces DOMParser I have noticed a weird exception being reported arbitrarily by certain instance documents. This exception message is &#8220;<strong><em>The processing instruction target matching &#8220;[xX][mM][lL]&#8221; is not allowed.</em></strong>&#8220;. Looking at the XML source file it does have the normal <strong>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;</strong> prefix so was initially unsure why this exception was firing every now and then?</p>
<p>Turns out that using the Xerces (JDK default) DOMParser  implementation, there is a parser exception ONLY if there are blank lines in the XML document before the <strong>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;</strong> declaration..??</p>
<p>Removing these blank lines (NOT the XML declaration header) allows the parser to complete successfully. I don&#8217;t profess to understand the science bit here, but this did knock me off track for a while. Interested to hear what relevance the blank lines do have in a document where whitespace is irrelevant&#8230;?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thestewscope.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thestewscope.wordpress.com/279/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=279&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thestewscope.wordpress.com/2010/05/01/xerces-domparser-funny/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6b9b3c5b60e4b37d2e7698a3c75fbedb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stew Welbourne</media:title>
		</media:content>

		<media:content url="http://thestewscope.files.wordpress.com/2010/05/sleuth.jpg?w=101" medium="image">
			<media:title type="html">sleuth</media:title>
		</media:content>
	</item>
		<item>
		<title>Xerces, XmlBeans and XML Schema Import Resolver</title>
		<link>http://thestewscope.wordpress.com/2010/04/30/xerces-xmlbeans-and-xml-schema-import-resolver/</link>
		<comments>http://thestewscope.wordpress.com/2010/04/30/xerces-xmlbeans-and-xml-schema-import-resolver/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 09:17:40 +0000</pubDate>
		<dc:creator>Stew Welbourne</dc:creator>
				<category><![CDATA[xml]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[resolver]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[validation]]></category>
		<category><![CDATA[xerces]]></category>
		<category><![CDATA[xmlbeans]]></category>
		<category><![CDATA[xsd]]></category>

		<guid isPermaLink="false">http://thestewscope.wordpress.com/?p=275</guid>
		<description><![CDATA[I&#8217;ve been developing a framework to provide XML validation/assurance tools based on a range of parser/validator implementations in Java. A recent experience warranted flagging, given I&#8217;ve been surprised at the number or credible examples out there on yonder interweb. The Headline XmlBeans 2.5 and Xerces 2.9 behave differently when using a runtime schema/resource resolver. XmlBeans [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=275&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been developing a framework to provide XML validation/assurance tools based on a range of parser/validator implementations in Java. A recent experience warranted flagging, given I&#8217;ve been surprised at the number or credible examples out there on yonder interweb.</p>
<p style="text-align:left;"><a href="http://thestewscope.files.wordpress.com/2010/04/red_kidney_beans.jpg"><img class="aligncenter size-medium wp-image-277" title="the_beans" src="http://thestewscope.files.wordpress.com/2010/04/red_kidney_beans.jpg?w=300&#038;h=300" alt="" width="300" height="300" /></a></p>
<p><strong><span style="text-decoration:underline;">The Headline</span></strong></p>
<p>XmlBeans 2.5 and Xerces 2.9 behave differently when using a runtime schema/resource resolver. XmlBeans relies on the use of the EntityResolver interface whereas Xerces relies on the LSResourceResolver interface, but the way the XMLSchema &lt;import /&gt; statement is put together causes some consistency problems in terms of how these resolvers are used&#8230;</p>
<p><strong><span style="text-decoration:underline;">The Goal</span></strong></p>
<p>Take a WSDL (with inline-schema) and then use that WSDL to validate XML instance documents. You cannot validate directly with a WSDL, and therefore as a developer you spend time messing with tools to extract schema and so forth. This tool will greatly simplify this process among other things. This approach involves unpacking the inline XML Schema documents in such a way that multiple XSD fragments can be utilised at the point of validation.</p>
<p><strong><span style="text-decoration:underline;">The Approach</span></strong></p>
<p>Open the WSDL, extract the schemas taking care to maintain the namespace declarations from the outer WSDL definitions section now that XSD&#8217;s will become independent XSD files and unable to inherit through context. Spin up a version of XmlBeans and Xerces, and generate a n-way schema validation report this catering for variations in the level of compliance in any one validating parser.</p>
<p><strong><span style="text-decoration:underline;">The Problem</span></strong></p>
<p>Some of the WSDL documents are very complex. They contain many, sometimes hundreds of hierarchically related XML Schema fragments, each of which &#8216;imports&#8217; the namespaces of numerous other schema fragments. Clearly when I separate the XSD&#8217;s from the WSDL these imports cannot resolve through inherited context so I have to make sure that I can resolve these at runtime when the validating parsers are fed the root schema. Problem is the inline schemas in the WSDL contain only a namespace import:</p>
<p><strong>&lt;import namespace=&#8221;<a href="http://some.other.namespace&#038;#8221" rel="nofollow">http://some.other.namespace&#038;#8221</a>; /&gt;</strong></p>
<p>And when this is exported to a standalone XSD file, you need to use a runtime SchemaResolver to acquire the other related XSD files such that the XmlBeans or Xerces engines can assimilate all of the type and namespace set necessary to validate the specified XML instance document. I spent a lot of time diagnosing why my XmlBeans implementation was not triggering the necessary &#8216;<strong><em>tell me where this schema lives?</em></strong>&#8216; events, such that element references were remaining unresolved, and the validation of the XML instance document was failing. With exactly the same input artifacts the Xerces resolver was happily going about it&#8217;s business and allowing me to feed it schema fragments all the way home.</p>
<p><span style="text-decoration:underline;"><strong>So Watch Out For This&#8230;</strong></span></p>
<p>If you are using XmlBeans, and you want to use a root XMLSchema to validate an XML document, but if the root XMLSchema contains &lt;import /&gt; statements, then you must have a schemaLocation present.</p>
<p><strong>&lt;import namespace=&#8221;<a href="http://some.other.namespace&#038;#8221" rel="nofollow">http://some.other.namespace&#038;#8221</a>;  schemaLocation=&#8221;file:/some.where&#8221;/&gt;</strong></p>
<p>Only with the schemaLocation present will the core XmlBeans.compileXsd() function call out to your custom EntityResolver such that you can then map the requested &#8216;namespace&#8217; to a physical input source. On the other hand the Xerces parser will work with the shorter format which is already present in my</p>
<p><strong>&lt;import namespace=&#8221;<a href="http://some.other.namespace&#038;#8221" rel="nofollow">http://some.other.namespace&#038;#8221</a>; /&gt;</strong></p>
<p>Now the only problem here is that I did not want to modify the XMLSchema artifacts I was extracting from the WSDL on the basis that I am offering a service based on the inputs supplied. However, I have been forced into a position of needing to inject a schemaLocation tag into all the XSD&#8217;s as I&#8217;m extracting them from the parent WSDL. That said I am not specifying a physical location for the schemaLocation, merely reiterating the same generic namespace. I do this to just force the trigger of the resolver events, from which I then use only the supplied <strong><em>namespace=&#8221;<a href="http://some.other.namespace&#038;#8221" rel="nofollow">http://some.other.namespace&#038;#8221</a>;<span style="font-weight:normal;"><span style="font-style:normal;"> tag in conjunction with some context information that I know in relation to where I put the schemas in my file-system, to resolve and supply the linkage to the required schema. This is sufficiently generic that I don&#8217;t deem it to be overly intrusive into the base schema, and I end up with the following modified import statements:</span></span></em></strong></p>
<p><strong>&lt;import namespace=&#8221;<a href="http://external.namespace&#038;#8221" rel="nofollow">http://external.namespace&#038;#8221</a>;  schemaLocation=&#8221;<a href="http://external.namespace&#8221;/&#038;gt" rel="nofollow">http://external.namespace&#8221;/&#038;gt</a>;</strong></p>
<p>With this format I get uniform behaviour between XmlBeans and Xerces. Both call out to my runtime resolvers which are then able to use a simple mapping scheme to supply the schema content and I now able to operate consistently.</p>
<p>This did take me a long time to diagnose, so hopefully it will be of use to others.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thestewscope.wordpress.com/275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thestewscope.wordpress.com/275/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=275&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thestewscope.wordpress.com/2010/04/30/xerces-xmlbeans-and-xml-schema-import-resolver/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6b9b3c5b60e4b37d2e7698a3c75fbedb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stew Welbourne</media:title>
		</media:content>

		<media:content url="http://thestewscope.files.wordpress.com/2010/04/red_kidney_beans.jpg?w=300" medium="image">
			<media:title type="html">the_beans</media:title>
		</media:content>
	</item>
		<item>
		<title>Spring MVC: Serving Static and Dynamic Content</title>
		<link>http://thestewscope.wordpress.com/2010/04/06/spring-mvc-service-static-and-dynamic-content/</link>
		<comments>http://thestewscope.wordpress.com/2010/04/06/spring-mvc-service-static-and-dynamic-content/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 08:23:21 +0000</pubDate>
		<dc:creator>Stew Welbourne</dc:creator>
				<category><![CDATA[SpringMVC]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[InternalResourceViewResolver]]></category>
		<category><![CDATA[jsp]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[serving static content]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring mvc]]></category>

		<guid isPermaLink="false">http://thestewscope.wordpress.com/?p=263</guid>
		<description><![CDATA[I have been revisiting SpringMVC recently as a basis for creating a web application. I had a positive experience some time ago building out a RESTful abstraction layer across a range of disparate data-sources. primarily for programmatic access, so I wanted to build on that learning and create a fully featured web-app this time around. Whilst I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=263&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://thestewscope.files.wordpress.com/2010/04/desert_safari2.jpg"><img class="aligncenter size-full wp-image-269" title="desert_safari" src="http://thestewscope.files.wordpress.com/2010/04/desert_safari2.jpg?w=450" alt=""   /></a></p>
<p>I have been revisiting SpringMVC recently as a basis for creating a web application. I had a positive experience some time ago building out a RESTful abstraction layer across a range of disparate data-sources. primarily for programmatic access, so I wanted to build on that learning and create a fully featured web-app this time around.</p>
<p>Whilst I really like the Spring MVC framework, I am completely amazed that in some cases it is almost impossible to find simple explanations about relatively simple things involved in building out a web-application. This post is motivated by that lack of clarity, and after a few days of googling, I now believe I&#8217;ve evolved at least one of the myriad common-sense approaches to serving up both static and dynamic content from a Spring MVC applicaiton.</p>
<p>Firstly my environment:</p>
<address> Mac OS/X 10.6</address>
<address> Java 1.6.0_17</address>
<address> Spring 2.5.5</address>
<address> Tomcat 6.0.24</address>
<p>Secondly the goal was to create a simple presentation layer with a largely static html homepage, with embedded images, with links to Spring controllers which would deliver dynamic content through JSP&#8217;s. When I started down this road I had assumed this would be pretty common, but my experiences on google have proven that wrong so here goes&#8230;</p>
<p>As a backdrop for my own variations I used the very helpful article &#8220;<a href="http://static.springsource.org/docs/Spring-MVC-step-by-step/">Developing a Spring MVC Application step-by-step</a>&#8221; which is great, but lulled me into a false sense of security before dropping me flat just as the real questions started emerging. I followed all steps in that tutorial and progressed very quickly to section 2, at which point I stopped, because I was less concerned with the addition of business logic, service PoJo&#8217;s and a persistence tier, than I was about <strong>breaking away from the text only presentation layer</strong> used in the example. So I have to point out &#8211; I&#8217;m not a presentation guy, I rarely move into the front-end discipline, but in this situation I have to &#8211; and as a result my inclination is immediatley to want to know how this static/dynamic stuff works.</p>
<p>So at section 2.1 in the tutorial I started to feel uneasy! Before I delve into this in detail let me backtrack.</p>
<p>1. I have a basic project structure as per the tutorial, with a <strong>web.xml</strong> and a <strong>&lt;servlet&gt;-context.xml</strong> for my primary controller. The relationship between these config files is covered in detail in the tutorial.</p>
<p>2. All of my <strong>JSP</strong>&#8216;s live in the <strong>WEB-INF/jsp</strong> sub-folder of my source tree, and are packaged into that location in the WAR (I cover how these are located when I explain my view resolver later in the article) I deploy into tomcat.</p>
<p>3. I have a single <strong>index.jsp</strong> in the <strong>war/</strong> root folder, and this index.jsp is referred to in my web.xml as follows:</p>
<address> &lt;servlet&gt;</address>
<address> &lt;servlet-name&gt;frontEndController&lt;/servlet-name&gt;</address>
<address> &lt;servlet-class&gt;</address>
<address> org.springframework.web.servlet.DispatcherServlet</address>
<address> &lt;/servlet-class&gt;</address>
<address> &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;</address>
<address> &lt;/servlet&gt;</address>
<address></address>
<address> &lt;servlet-mapping&gt;</address>
<address> &lt;servlet-name&gt;frontEndController&lt;/servlet-name&gt;</address>
<address> &lt;url-pattern&gt;<strong>*.htm</strong>&lt;/url-pattern&gt;</address>
<address> &lt;/servlet-mapping&gt;</address>
<address></address>
<address> &lt;welcome-file-list&gt;</address>
<address> &lt;welcome-file&gt;</address>
<address> index.jsp</address>
<address> &lt;/welcome-file&gt;</address>
<address> &lt;/welcome-file-list&gt;</address>
<p>No surprises here &#8211; <strong>I&#8217;m pushing all the HTM URL&#8217;s</strong> entering my application context (i.e. requests arriving at Tomcat for host/port/context-root) towards my frontEndController which I&#8217;ll come-back to in a short while, but more specifically you&#8217;ll see that I&#8217;m using the <strong>*.htm</strong> naming convention in my presentation layer for all the links into my application. In other words I&#8217;m not allowing users to directly reference *.JSP files in my app &#8211; I could use any suffix for that matter (<strong>*.private</strong> for example) given it is only relevant for routing requests for content into my controller so my MVC engine can deal with it.</p>
<p>Now &#8211; I did have a static HTML index.html as my welcome page in the WAR root folder from where it was directly accessible by Tomcat. As such I could type <strong>&#8216;<a href="http://localhost:8080/myapp/index.html&#038;#8217" rel="nofollow">http://localhost:8080/myapp/index.html&#038;#8217</a>;</strong> and get my page back ok, but there is a Spring MVC/JSP convention for not doing this &#8211; but instead redirecting the request for the &#8216;welcome&#8217; page into the MVC/JSP engine such that it becomes instrumented and visible to the spring context. This is covered in section 2.1 of the tutorial &#8211; but for the record my war/index.html is now war/index.jsp, and it contains the following:</p>
<address> &lt;%@ include file=&#8221;/WEB-INF/jsp/include.jsp&#8221; %&gt;</address>
<address> &lt;%&#8211; Redirected &#8211; we can&#8217;t set the welcome page to a virtual URL. &#8211;%&gt;</address>
<address> &lt;c:redirect url=&#8221;/index.htm&#8221;/&gt;</address>
<address></address>
<address><span style="font-style:normal;">where include.jsp is the inclusion of the necessary JSP tag libraries to support features such as this redirecting:</span></address>
<address><span style="font-style:normal;"><br />
</span></address>
<address> &lt;%@ page session=&#8221;false&#8221;%&gt;</address>
<address> &lt;%@ taglib prefix=&#8221;c&#8221; uri=&#8221;<a href="http://java.sun.com/jsp/jstl/core&#038;#8221" rel="nofollow">http://java.sun.com/jsp/jstl/core&#038;#8221</a>; %&gt;</address>
<address> &lt;%@ taglib prefix=&#8221;fmt&#8221; uri=&#8221;<a href="http://java.sun.com/jsp/jstl/fmt&#038;#8221" rel="nofollow">http://java.sun.com/jsp/jstl/fmt&#038;#8221</a>; %&gt;</address>
<p>So what we have here is a request to my application for &#8216;/&#8217; or &#8216;index.jsp&#8217; will redirect to a request for <strong>virtual &#8216;index.htm&#8217;</strong> page. This forces the request into my SpringMVC controller &#8216;frontEndController&#8217; on the basis of the *.htm pattern-match. At that point I simply wanted to return a JSP, containing html source, but also containing static images. <strong>Try as I might I could not find a simple explanation of how to achieve this !!</strong></p>
<p>So here it is. Firstly &#8211; only requests for dynamic content are be pushed into the frontEndController. The *.htm pattern is a &#8216;codename&#8217; in my application context for &#8216;give me some JSP content&#8217;. Fine. But what about the statics that those dynamics might require?? <strong>!!WATCH-OUT!!</strong> I used a <strong>/ui/*</strong> pattern initially in my &lt;servlet&gt;-context.xml which caused me problems with static content. Any embedded CSS or IMG resources also fall under that path name, and as such all requests hitting tomcat for <strong>/ui/page.htm</strong> or <strong>/ui/img/banner.jpg</strong> were being pushed into my frontEndController &#8211; from where I could not serve the images, nor did I want to. As such changing to the *.htm pattern means that only the htm page names are pushed in the MVC controller and all embedded resources can be<strong> managed separately</strong>.</p>
<p>There are 3 key messages here. Firstly my index.jsp in the WEB-INF is not really dynamic (other than I have used a templating solution to assemble my pages but that is irrelevant here). But by handling it in this way I have ensured that &#8216;all&#8217; html content is generated/served under the control of my MVC engine &#8211; and therefore visible to all the nice things such as logging, access control, and all the other stuff I aint even thought of yet that I&#8217;m able to implement as cross-cutters in my MVC context. I don&#8217;t have a blind-spot where my static content may be beign hammered yet I&#8217;m seeing low usage on my MVC generated content for example.</p>
<p>Secondly <strong>you do NOT have to implement a custom controller for JSP&#8217;s which ARE largely static</strong> content. The normal flow is that the &lt;servlet&gt;-context.xml for the relevant controller declated in web.xml offers a second level of routing. Normal convention would be to add an entry such as:</p>
<address> &lt;bean&gt;</address>
<address> &lt;property name=&#8221;urlMap&#8221;&gt;</address>
<address> &lt;map&gt;</address>
<address> &lt;entry key=&#8221;/index.htm&#8221; value-ref=&#8221;homepageController&#8221;&gt;&lt;/entry&gt;</address>
<address> &lt;/map&gt;</address>
<address> &lt;/property&gt;</address>
<address> &lt;/bean&gt;</address>
<p>which pushed such requests to the POJO controller declared in that same XML file as below:</p>
<address> &lt;bean name=&#8221;homepageController&#8221; </address>
<address> class=&#8221;com.myapp.web.HomepageController&#8221; /&gt;</address>
<p>But this forces me to implement a java object HomepageController to effectively do &#8216;nothing&#8217; other than return a &#8216;view&#8217;name of &#8216;index.jsp&#8217; which then returns the &#8216;static&#8217; index.jsp to the client. <strong>Have no fear</strong> there is a better way &#8211; and we use something called the <strong>UrlFilenameViewController</strong>. As such &#8211; for any &#8216;pages&#8217; that I want to serve in my MVC engine, which are static &#8211; I can re-wire the request as follows:</p>
<address> &lt;bean&gt;</address>
<address> &lt;property name=&#8221;urlMap&#8221;&gt;</address>
<address> &lt;map&gt;</address>
<address> &lt;entry key=&#8221;/index.htm&#8221; value-ref=&#8221;urlFilenameViewController&#8221; /&gt;</address>
<address> &lt;entry key=&#8221;/static-about.htm&#8221; value-ref=&#8221;urlFilenameViewController&#8221; /&gt;</address>
<address> &lt;entry key=&#8221;/termsandconditions.htm&#8221; value-ref=&#8221;urlFilenameViewController&#8221; /&gt;</address>
<address> &lt;/map&gt;</address>
<address> &lt;/property&gt;</address>
<address> &lt;/bean&gt;</address>
<address> </address>
<address> &lt;!&#8211; For direct mapping between URL (i.e. index.htm -&gt; index) and the JSP to render &#8211;&gt;</address>
<address> &lt;bean id=&#8221;urlFilenameViewController&#8221; </address>
<address> class=&#8221;org.springframework.web.servlet.mvc.UrlFilenameViewController&#8221;/&gt;</address>
<p>By convention this means that I would <strong>need to have 3 JSP files in my WEB-INF/jsp index.jsp, static-about.jsp, and termsandconditions.jsp</strong>. The urlFilenameViewController simply converts the requested html resource name into a token, which is passed to the view-resolver in the same servlet context, which then needs to be configured to look in the WEB-INF/jsp folder as such:</p>
<address> &lt;bean id=&#8221;viewResolver&#8221; class=&#8221;org.springframework.web.servlet.view.InternalResourceViewResolver&#8221;&gt;</address>
<address> &lt;property name=&#8221;viewClass&#8221; value=&#8221;org.springframework.web.servlet.view.JstlView&#8221; /&gt;</address>
<address> &lt;property name=&#8221;prefix&#8221; value=&#8221;/WEB-INF/jsp/&#8221; /&gt;</address>
<address> &lt;property name=&#8221;suffix&#8221; value=&#8221;.jsp&#8221; /&gt;</address>
<address> &lt;/bean&gt;</address>
<p>Hey presto ! We now have a consistent mechanism to serve up static html content as JSP from within the SpringMVC engine. I like symmetry and as such like to have my static and dynamic pages all being managed in a consistent way &#8211; but there may be plenty of counter arguments to suggest this approach has problems. (If so I&#8217;m very keen to hear them !).</p>
<p>Secondly the static content such as images, and CSS for example, should NOT be inside the WEB-INF folder, but instead such static resources referenced by the returned JSP pages, should live in the WAR root folder &#8217;where Tomcat can serve them directly&#8217; to the user outside of the controller back-end. As such I have a <strong>war/img</strong>, and <strong>war/css</strong> folder alongside my <strong>war/WEB-INF</strong> folder. Any html content I generate from my JSP handling framework refers to static resources such as:</p>
<address> &lt;img src=&#8221;img/application-logo.jpg&#8221; alt=&#8221;some text&#8221;/&gt;</address>
<p>which means that User-Agents will resolve the address for the subsidiary resources to:</p>
<address> <a href="http://host/applicaiton-path/img/application-logo.jpg" rel="nofollow">http://host/applicaiton-path/img/application-logo.jpg</a></address>
<p>and this means that Tomcat can serve up those resources directly from the application without touching the SpringMVC engine. This now means that I have a seamless framework for taking all page requests into my controller architecture (even pages that may be largely static which I still want to be managed in a consistent way), and storing all supporting collateral in a simple place from where they can be served up.</p>
<p>This may seem like trivial or common-sense but it has taken me a long time to grind through the frustrating combination of too many option combinations offered by SpringMVC framework, and a lack of clear explanations on how to achieve this effectively including images or other static resources.</p>
<p>Hope this is useful.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thestewscope.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thestewscope.wordpress.com/263/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=263&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thestewscope.wordpress.com/2010/04/06/spring-mvc-service-static-and-dynamic-content/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6b9b3c5b60e4b37d2e7698a3c75fbedb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stew Welbourne</media:title>
		</media:content>

		<media:content url="http://thestewscope.files.wordpress.com/2010/04/desert_safari2.jpg" medium="image">
			<media:title type="html">desert_safari</media:title>
		</media:content>
	</item>
		<item>
		<title>Anglet Beach Rugby 2009</title>
		<link>http://thestewscope.wordpress.com/2009/07/27/anglet-beach-rugby-2009/</link>
		<comments>http://thestewscope.wordpress.com/2009/07/27/anglet-beach-rugby-2009/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 23:16:12 +0000</pubDate>
		<dc:creator>Stew Welbourne</dc:creator>
				<category><![CDATA[rugby]]></category>
		<category><![CDATA[2009]]></category>
		<category><![CDATA[anglet]]></category>
		<category><![CDATA[beach]]></category>
		<category><![CDATA[leeds winoes]]></category>

		<guid isPermaLink="false">http://thestewscope.wordpress.com/2009/07/27/anglet-beach-rugby-2009/</guid>
		<description><![CDATA[The morning of the big day Originally uploaded by Wertster The Leeds Winoes travelled to the amazing coastal venue of Anglet near Biarritz in the South of France this weekend to take part in one of the best beach-rugby events of the year. After an amazing effort we made it through to the second round [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=256&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<div style="float:right;margin-left:10px;margin-bottom:10px;"><a title="photo sharing" href="http://www.flickr.com/photos/leeds-winoes-touch-rugby/3761843930/"><img style="border:solid 2px #000000;" src="http://farm3.static.flickr.com/2008/3761843930_ae07100b51_m.jpg" alt="" /></a></p>
<p><span style="font-size:.9em;margin-top:0;"><br />
<a href="http://www.flickr.com/photos/leeds-winoes-touch-rugby/3761843930/">The morning of the big day</a></span></p>
<p>Originally uploaded by <a href="http://www.flickr.com/people/leeds-winoes-touch-rugby/">Wertster</a></div>
<p>The Leeds Winoes travelled to the amazing coastal venue of Anglet near Biarritz in the South of France this weekend to take part in one of the best beach-rugby events of the year. After an amazing effort we made it through to the second round before crashing out and retreating to the beer tent. What an unforgettable experience and what an amazingly well organised event. Can&#8217;t wait for next year.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thestewscope.wordpress.com/256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thestewscope.wordpress.com/256/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=256&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thestewscope.wordpress.com/2009/07/27/anglet-beach-rugby-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6b9b3c5b60e4b37d2e7698a3c75fbedb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stew Welbourne</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2008/3761843930_ae07100b51_m.jpg" medium="image" />
	</item>
		<item>
		<title>Installing Metric_Fu on Centos/Red-Hat Linux</title>
		<link>http://thestewscope.wordpress.com/2009/07/22/installing-metric_fu-on-centosred-hat-linux/</link>
		<comments>http://thestewscope.wordpress.com/2009/07/22/installing-metric_fu-on-centosred-hat-linux/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 11:06:17 +0000</pubDate>
		<dc:creator>Stew Welbourne</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[code quality]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[metric_fu]]></category>

		<guid isPermaLink="false">http://thestewscope.wordpress.com/?p=245</guid>
		<description><![CDATA[To gain the benefit of integrated code-quality analysis within my continuous integration process for my Ruby projects, I&#8217;ve been integrating the excellent Metric_Fu package by Jake Scruggs. I&#8217;ve now completed an installation on OS-X, CentOS and Red-Hat where I had some quirks to resolve on CentOS and RedHat. This post provides my view on the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=245&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>To gain the benefit of integrated code-quality analysis within my continuous integration process for my Ruby projects, I&#8217;ve been integrating the excellent <a href="http://metric-fu.rubyforge.org/">Metric_Fu package by Jake Scruggs</a>. I&#8217;ve now completed an installation on OS-X, CentOS and Red-Hat where I had some quirks to resolve on CentOS and RedHat. This post provides my view on the best install procedure I can offer.</p>
<p><img class="aligncenter size-medium wp-image-248" title="dependencies" src="http://thestewscope.files.wordpress.com/2009/07/50649402-jbdsc12845.jpg?w=300&#038;h=199" alt="dependencies" width="300" height="199" /></p>
<p><strong>First the underlying OS package pre-requisites&#8230;</strong></p>
<pre>sudo yum install libxml2           =&gt; v2.6.26-2.1.2.1</pre>
<pre>sudo yum install libxml2-devel     =&gt; v2.6.26-2.1.2</pre>
<pre>sudo yum install libxslt           =&gt; v1.1.17-2</pre>
<pre>sudo yum install libxslt-devel     =&gt; v1.1.17-2</pre>
<pre>sudo yum install ImageMagick       =&gt; v6.2.8.0-3.el5.4(see note)
sudo yum install ImageMagick-devel =&gt; v6.2.8.0-3.el5.4</pre>
<p>Note the version of the <strong>ImageMagick</strong> package I have installed. There is a version depenency here with the rmagick gem which is installed in the next section. As far as I can see, for this version of the ImageMagick package, you must install the v1.x gem. As such I installed the highest version of the gem v1.15.17 below the v2.x.x baseline. If you have later versions of this ImageMagick package then I believe you can avoid this particular issue.</p>
<p><strong>The TrueType Fonts dependency&#8230;</strong></p>
<p>The rmagick gem has an installation dependency on the the presence of a set of true-type fonts in the base OS installation. On both the CentOS and RedHat installs I have done, this issue has been present. So before we go ahead and install the gems, we need to rectify this issue.The dependency relates to the presence of the <strong>/usr/share/fonts/default/TrueType</strong> folder which needs to be created with the following steps. (<em>Note &#8211; you don&#8217;t need to install these fonts if you already have TrueType fonts installed &#8211; in which case skip to the next section</em>).</p>
<pre>yum install rpm-build wget http://www.cabextract.org.uk/cabextract-1.2-1.i386.rpm
rpm -ivh cabextract-1.2-1.i386.rpm 
wget http://corefonts.sourceforge.net/msttcorefonts-2.0-1.spec
rpmbuild -ba msttcorefonts-2.0-1.spec
rpm -ivh /usr/src/redhat/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm
cd /usr/share/fonts/default
ln -s /usr/share/fonts/msttcorefonts/ TrueType</pre>
<p><strong>Now the Gems&#8230;</strong></p>
<p>Then install the gems:</p>
<pre>sudo gem sources -a http://gems.github.com
sudo gem install jscruggs-metric_fu</pre>
<p>Note at this point one of the installed depenencies, the &#8216;flog&#8217; gem at v2.1.2, has an issue that will prevent it from running. I have explicitly modified the following file to get this to work:</p>
<pre>vi /usr/local/lib/ruby/gems/1.8/gems/flog-2.1.2/bin/flog</pre>
<p>Change the line:   <strong>flogger.flog_files ARGV</strong> to <strong>flogger.flog ARGV</strong> and save the file. This is only a quick-n-dirty solution to get the flog integration to work within metric_fu.</p>
<pre>sudo gem install reek
sudo gem install roodi
sudo gem install gruff
sudo gem install rmagick -v 1.15.17</pre>
<p>When these gem installations complete you&#8217;re now ready to play with Metric_Fu. For more information on next steps refer to <a href="http://thestewscope.wordpress.com/2009/07/09/ruby-code-quality-and-metric_fu/">this article about some more version specific fixes</a> or <a href="http://metric-fu.rubyforge.org/">Jakes Metric_fu home</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thestewscope.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thestewscope.wordpress.com/245/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=245&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thestewscope.wordpress.com/2009/07/22/installing-metric_fu-on-centosred-hat-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6b9b3c5b60e4b37d2e7698a3c75fbedb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stew Welbourne</media:title>
		</media:content>

		<media:content url="http://thestewscope.files.wordpress.com/2009/07/50649402-jbdsc12845.jpg?w=300" medium="image">
			<media:title type="html">dependencies</media:title>
		</media:content>
	</item>
		<item>
		<title>New Earswick Tag Rugby Tournement July 2009</title>
		<link>http://thestewscope.wordpress.com/2009/07/14/new-earswick-tag-rugby-tournement-july-2009-3/</link>
		<comments>http://thestewscope.wordpress.com/2009/07/14/new-earswick-tag-rugby-tournement-july-2009-3/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 19:09:21 +0000</pubDate>
		<dc:creator>Stew Welbourne</dc:creator>
				<category><![CDATA[rugby]]></category>
		<category><![CDATA[leeds winoes]]></category>
		<category><![CDATA[tag rugby]]></category>

		<guid isPermaLink="false">http://thestewscope.wordpress.com/2009/07/14/new-earswick-tag-rugby-tournement-july-2009-3/</guid>
		<description><![CDATA[winoes at York July 2009 Originally uploaded by Wertster Our merry band of rugby-bandits descended onto the turf at our latest tag-rugby tournament in York on the 11th July, hosted by New Earswick RLFC. With a low turn-out we got to work and had a great time, winning out overall in what was a really [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=242&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<div style="float:right;margin-left:10px;margin-bottom:10px;"><a title="photo sharing" href="http://www.flickr.com/photos/leeds-winoes-touch-rugby/3715510771/"><img style="border:solid 2px #000000;" src="http://farm4.static.flickr.com/3426/3715510771_9a00e23019_m.jpg" alt="" /></a></p>
<p><span style="font-size:.9em;margin-top:0;"><br />
<a href="http://www.flickr.com/photos/leeds-winoes-touch-rugby/3715510771/">winoes at York July 2009</a></span></p>
<p>Originally uploaded by <a href="http://www.flickr.com/people/leeds-winoes-touch-rugby/">Wertster</a></div>
<p>Our merry band of rugby-bandits descended onto the turf at our latest tag-rugby tournament in York on the 11th July, hosted by New Earswick RLFC. With a low turn-out we got to work and had a great time, winning out overall in what was a really good natured day. Hopefully we&#8217;ll get a bigger turn-out next year. Looks like our next stop is now the Winoes Tour to the Anglet Beach Rugby Festival in Biarritz on the 25th July, where we&#8217;ll joust with our French cousins in the shadow of what I hear is a well stocked beer tent.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thestewscope.wordpress.com/242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thestewscope.wordpress.com/242/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=242&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thestewscope.wordpress.com/2009/07/14/new-earswick-tag-rugby-tournement-july-2009-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6b9b3c5b60e4b37d2e7698a3c75fbedb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stew Welbourne</media:title>
		</media:content>

		<media:content url="http://farm4.static.flickr.com/3426/3715510771_9a00e23019_m.jpg" medium="image" />
	</item>
		<item>
		<title>The CI, TDD and OO Love Triangle</title>
		<link>http://thestewscope.wordpress.com/2009/07/14/the-ci-tdd-and-oo-love-triangle/</link>
		<comments>http://thestewscope.wordpress.com/2009/07/14/the-ci-tdd-and-oo-love-triangle/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 16:54:07 +0000</pubDate>
		<dc:creator>Stew Welbourne</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[ci]]></category>
		<category><![CDATA[continuous integration]]></category>
		<category><![CDATA[object orientation]]></category>
		<category><![CDATA[oo]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[test driven development]]></category>

		<guid isPermaLink="false">http://thestewscope.wordpress.com/?p=231</guid>
		<description><![CDATA[I would not describe myself as a purist in any aspect of my life, least of all my software engineering practices. I&#8217;ve been re-establishing myself as a coder after a long while in the more abstract realms of architecture and design, and on the return-path I&#8217;m seeing things in a somewhat different light, and I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=231&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">I would not describe myself as a purist in any aspect of my life, least of all my software engineering practices. I&#8217;ve been re-establishing myself as a coder after a long while in the more abstract realms of architecture and design, and on the return-path I&#8217;m seeing things in a somewhat different light, and I think it&#8217;s an interesting observation hence this post.</p>
<p style="text-align:justify;"><img class="size-full wp-image-232 aligncenter" title="thinker" src="http://thestewscope.files.wordpress.com/2009/07/thinker.jpg?w=450" alt="thinker"   /><br />
Object Orientation was an approach I previously adopted to partition my problem-space into a group of components &#8211; so I could start hacking, rather than putting on the &#8216;everything is an object and so is its mother&#8217; spectacles. I never quite got my head around why colleagues and &#8216;real developers&#8217; would sit for hours debating the 99th level of object decomposition and whether an object had to be so fine-grained it should actually contain no code?</p>
<p style="text-align:justify;">My return journey to the world of software development has intersected with new (I say &#8216;new&#8217; given I was a full-on hacker in the mid 90&#8242;s so this is new to me) and emerging trends around Continuous Integration and Test Driven Development and I have to say these intersections have made a huge impression on me to the extent that I&#8217;m now passionate about the benefit brought about by these techniques. Maybe I&#8217;m so pro-CI and pro-TDD because I lived through the appalling software engineering practices of the 80&#8242;s and early 90&#8242;s, or may be it&#8217;s just because it makes so&#8230;much&#8230;sense.</p>
<p style="text-align:justify;">So to my point. <strong>Continuous Integration</strong> has a simple benefit. You know when your code-base has been tainted. The more frequently you get to know that the better. I&#8217;ll avoid quoting the scientists who waffle about cost exponentials for fixing defects today versus tomorrow blah. No &#8211; it just&#8230;makes&#8230;.so&#8230;.much&#8230;.sense ! I didn&#8217;t need a PhD in chin rubbing to work that out.</p>
<p style="text-align:justify;">Next <strong>Test-Driven Development</strong>. Right this one took time, just a little time to get my head around, even though I was convinced that CI was the way to go no questions asked. I found myself asking the stereotypical questions like &#8220;won&#8217;t I be 50% productive if I spend half my time writing tests for the code I am writing?&#8221;. Let me just pause while I give myself 10 lashes for being so narrow-minded. THWACK, THWACK, THWACK, THWACK, THWACK, THWACK, THWACK, THWACK, THWACK, THWACK&#8230;and one for luck THHHHHWACK!!  So it&#8217;s a natural inclination to feel like test-cases are just code that you&#8217;d traditionally throw into the code-base, but when you consider the fact that you&#8217;re actually building inherent certainty into the code-base at every step of the way the lightbulb goes on in a big way. When I sat back and appreciated that I wouldn&#8217;t have to run huge amounts of code to verify and exercise a small method I just changed it&#8230;.just&#8230;.makes&#8230;.so&#8230;much&#8230;.sense. All the regression testing scenarios I was carrying round in my head ! The lack of repeatability in my approach to testing !! The gradual feeling of dread that I&#8217;d become used-to, after deploying a stable version of code, in case I had to, god-forbid, change it at some point??! It all cries out for an inherent approach that means you lock-down every function you implement as you implement it &#8211; such that you can purge all that baggage from your poor little cranial-walnut. It&#8230;.just&#8230;.makes&#8230;.so&#8230;.much&#8230;sense. I was soon a TDD convert, but only at that point did it strike me like a bolt from the blue&#8230;finally my life made sense&#8230;.finally I could truly embrace the love-triangle of CI-&gt;TDD-&gt;OO.</p>
<p style="text-align:justify;">The effectiveness of my CI/TDD regime relied totally on the level of granularity I could descend to with my class definitions, and the simplification of each and every function to it&#8217;s thinnest possible form.  Real fundamental <strong>Object Orientation</strong> finally became the underpinning foundation &#8211; notice I place it in that underpinning role &#8211; as I&#8217;ve only now seen OO as an enabler for the &#8216;common-sense&#8217; and &#8216;value-adding&#8217; techniques of CI and TDD. I&#8217;m a little weird that way &#8211; but I found my way into rigorous OO not via the brain-washing from the chin-rubbing ranks of &#8220;my object is more objecty than yours&#8221; brigade, but instead through the simple realisation that I can squeeze ever more value from my CI/TDD framework if I force my test-cases into finer and finer levels of granularity (within reason of course, I aint lost my roots yet !! )</p>
<p style="text-align:justify;">So there you have. CI drives me to TDD. TDD drives me to appreciate why OO should exist, NOT vice versa&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thestewscope.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thestewscope.wordpress.com/231/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=231&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thestewscope.wordpress.com/2009/07/14/the-ci-tdd-and-oo-love-triangle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6b9b3c5b60e4b37d2e7698a3c75fbedb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stew Welbourne</media:title>
		</media:content>

		<media:content url="http://thestewscope.files.wordpress.com/2009/07/thinker.jpg" medium="image">
			<media:title type="html">thinker</media:title>
		</media:content>
	</item>
		<item>
		<title>Ruby Code Quality and Metric_Fu</title>
		<link>http://thestewscope.wordpress.com/2009/07/09/ruby-code-quality-and-metric_fu/</link>
		<comments>http://thestewscope.wordpress.com/2009/07/09/ruby-code-quality-and-metric_fu/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 09:25:46 +0000</pubDate>
		<dc:creator>Stew Welbourne</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[ci]]></category>
		<category><![CDATA[code quality]]></category>
		<category><![CDATA[continuous integration]]></category>
		<category><![CDATA[jscruggs]]></category>
		<category><![CDATA[metric_fu]]></category>

		<guid isPermaLink="false">http://thestewscope.wordpress.com/?p=215</guid>
		<description><![CDATA[I’ve been putting together a continuous integration framework for my Ruby projects and was very pleased to find the great work by Jake Scruggs (http://metric-fu.rubyforge.org/ ) by the name of Metric_Fu. On the whole this aggregation of tools covers all the key ‘quality’ bases and generates some elegant graphical reports that can be simply published [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=215&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I’ve been putting together a continuous integration framework for my Ruby projects and was very pleased to find the great work by Jake Scruggs (<a href="http://metric-fu.rubyforge.org/">http://metric-fu.rubyforge.org/</a> ) by the name of Metric_Fu. On the whole this aggregation of tools covers all the key ‘quality’ bases and generates some elegant graphical reports that can be simply published alongside other build artifacts in CruiseControl.rb for example. On the whole the installation is very simple, but I hit some issues with the code and had to apply some class method overrides to get it to work.</p>
<p style="text-align:center;"><img class="size-full wp-image-218 aligncenter" title="Inspector" src="http://thestewscope.files.wordpress.com/2009/07/magnifying_glass.png?w=450" alt="Inspector"   /></p>
<p>My base environment is OSX 10.5.7, Ruby 1.8.6, Gem 1.3.3. I installed the gems jscruggs-metric_fu (1.1.1), rcov (0.8.1.2.0), flog (2.1.2), flay (1.3.0), reek (1.1.3), roodi (1.4.0) and Saikuro (1.1.0). Following the instructions at <a href="http://metric-fu.rubyforge.org/">http://metric-fu.rubyforge.org/</a> I was complete in short order, and ran the rake task as per the example.</p>
<p>The first problem I hit was a method naming issue where the a Flog#flog_files method was being called which didn’t exist in the versions I was using. I ended up with a quick-n-dirty fix which involved amending the /gems/flog-2.1.2/bin/flog script to remove the call to flog_files, replacing it with the correct method name flog:</p>
<pre>
...
flogger = Flog.new options
flogger.flog ARGV
flogger.report
...
</pre>
<p>Second problem I hit was some floating point and divide-by-zero issue in the MetricFu::Generator#round_to_tenths method. I don’t profess to understand the core issue here, but the value of ‘NaN’ was appearing in the calculation – so I added a ‘very’ primitve override to filter this condition (elegance is not my middle name I you hadn’t realised already):</p>
<pre>
module MetricFu
  class Generator
    def round_to_tenths(decimal)
      decimal=0.0 if decimal.to_s.eql?('NaN')
      (decimal.to_i * 10).round / 10.0
    end
  end
end
</pre>
<p>Next I hit an issue with rcov not returning any results into the dashboard? I checked this out and located an error in the rcov.txt file generated as part of the execution. This simply informed me that the rcov commandline generated within the metric_fu rcov generator class was incorrect. After a little experimentation I worked out that the –include-file parameter was the issue…so I again redefined the problematic class method in my Rakefile to remove this issue:</p>
<pre>
Module MetricFu
  class Rcov
    def emit
      begin
        FileUtils.rm_rf(MetricFu::Rcov.metric_directory, :verbose =&gt; false)
        Dir.mkdir(MetricFu::Rcov.metric_directory)
        test_files = FileList[*MetricFu.rcov[:test_files]].join(' ')
        rcov_opts = MetricFu.rcov[:rcov_opts].join(' ')
        output = "&gt;&gt; #{MetricFu::Rcov.metric_directory}/rcov.txt"
        #PROBLEM: `rcov --include-file #{test_files}  #{rcov_opts} #{output}`
        `rcov #{test_files}  #{rcov_opts} #{output}`
      rescue LoadError
        if RUBY_PLATFORM =~ /java/
          puts 'running in jruby - rcov tasks not available'
        else
          puts 'sudo gem install rcov # if you want the rcov tasks'
        end
      end
    end
  end
end
</pre>
<p>Next I hit a problem when modifying my declared MetricFu::Configuration object to change the location of the outputs of the analysis, to reduce the pollution in my project folder hierarchy (yep…I probably do have some deeper issues). I had added the following lines to the sample provide by Jake:</p>
<pre>
MetricFu::Configuration.run do |config|
  config.base_directory = ENV['CC_BUILD_ARTIFACTS'] || 'quality'
  config.scratch_directory = File.join(config.base_directory, 'scratch')
  config.output_directory = File.join(config.base_directory, 'output')
  config.data_directory = File.join(config.base_directory, '_data')
  etc
</pre>
<p>With this new folder structure I also had to add a tweek to the Saikuro configuration entry in the same sample, to make sure the Saikuro outputs are picked up by the report aggregator. Without this tweek I was just getting a blank Saikuro template page offered by Metric_Fu:</p>
<p><em>(Ignore the space between the colon and the &#8216;o&#8217; &#8211; it&#8217;s giving me smilies for some reason)</em></p>
<pre>
config.saikuro  = { : output_directory =&gt; 
                              File.join(config.scratch_directory, 'saikuro'), 
</pre>
<p>This change caused a failure in the MetricFu::Graph#generate method – which on closer inspection appeared to be hardwired in expecting a depth of 3 folders in the locations specified for these outputs? So again I re-declared this class in my Rakefile to make the specific change necessary to support any level of nesting. This fixed the problem and my folder feng-shui returned to equilibrium…mmmmmmm.</p>
<pre>
Module MetricFu
  class Graph
    def generate
      puts "Generating graphs"
      Dir[File.join(MetricFu.data_directory, '*.yml')].sort.each do |metric_file|
        puts "Generating graphs for #{metric_file}"
        #PROBLEM: date = metric_file.split('/')[3].split('.')[0]
        date = metric_file.split('/').last.split('.')[0]
        metrics = YAML::load(File.open(metric_file))
        self.clazz.each do |grapher|
          grapher.get_metrics(metrics, date)
        end
      end
      self.clazz.each do |grapher|
        grapher.graph!
      end
    end
  end
end
</pre>
<p>So my installation of metric_fu works perfectly now and I’m very impressed with the output it’s providing so long as I don’t dwell too much on the fact that it’s telling me my code quality is somewhere between <strong>criminal</strong> and <strong>insane</strong> !!!</p>
<p>I hope these notes may help others experiencing similar frustration in trying to get the install working…and again my thanks to Jake Scruggs for this piece of goodness.</p>
<p>Cheers all !</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thestewscope.wordpress.com/215/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thestewscope.wordpress.com/215/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thestewscope.wordpress.com&#038;blog=2207920&#038;post=215&#038;subd=thestewscope&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thestewscope.wordpress.com/2009/07/09/ruby-code-quality-and-metric_fu/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6b9b3c5b60e4b37d2e7698a3c75fbedb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Stew Welbourne</media:title>
		</media:content>

		<media:content url="http://thestewscope.files.wordpress.com/2009/07/magnifying_glass.png" medium="image">
			<media:title type="html">Inspector</media:title>
		</media:content>
	</item>
	</channel>
</rss>
