<?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:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>a regular expression</title>
	<atom:link href="http://johnnywey.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://johnnywey.wordpress.com</link>
	<description>life, technology, and the vast expanse</description>
	<lastBuildDate>Wed, 04 Nov 2009 17:50:11 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='johnnywey.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/10bdc75575dba7a1fdf335ffee292bb4?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>a regular expression</title>
		<link>http://johnnywey.wordpress.com</link>
	</image>
			<item>
		<title>Careful With Your Binary Resources!</title>
		<link>http://johnnywey.wordpress.com/2009/11/04/careful-with-your-binary-resources/</link>
		<comments>http://johnnywey.wordpress.com/2009/11/04/careful-with-your-binary-resources/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 16:49:28 +0000</pubDate>
		<dc:creator>johnnywey</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://johnnywey.wordpress.com/?p=378</guid>
		<description><![CDATA[Our production application stack has a fair amount of external service connections that require the use of certs for SSL security.  We used to use a static reference (e.g. /config/certs or c:\config\certs for you Windows people) to locate the certificates, but this was always suboptimal as it made the application less portable.  I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=378&subd=johnnywey&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Our production application stack has a fair amount of external service connections that require the use of <a href="http://en.wikipedia.org/wiki/Ssl_certificate">certs</a> for SSL security.  We used to use a static reference (e.g. /config/certs or c:\config\certs for you Windows people) to locate the certificates, but this was always suboptimal as it made the application less portable.  I finally got around to moving from the static reference and landing on Java jar introspection to find the file (using something similar to <code>ClassName.getResource("/cert.pks");</code>).</p>
<p>This conversion worked very well and everything seemed fine until the change got to our <a href="http://en.wikipedia.org/wiki/Continuous_integration">continuous integration</a> (or CI) box.  That machine, a <a href="http://en.wikipedia.org/wiki/Centos">Centos</a> distribution, kept failing with the error <code>Invalid keystore format</code> when we tried to initialize the keystore in code.  I spent hours trying to figure out the difference between my local machine (running OS X, which worked fine) and the CI box.  I finally diff&#8217;d the cert file in src/main/resources and the resulting file in target/classes.  I discovered that the two files were radically different.</p>
<p>Maven has a very cool feature that not only copies values from src/main/resources into target/classes and, ultimately, the resulting Jar file but also can substitute tokens in text files as part of the build (referred to as &#8220;filtering&#8221;).  To enable this, all you have to do is add</p>
<pre class="brush: xml;">
&lt;resources&gt;
            &lt;resource&gt;
                &lt;directory&gt;src/main/resources&lt;/directory&gt;
                &lt;filtering&gt;true&lt;/filtering&gt;
            &lt;/resource&gt;
&lt;/resources&gt;
</pre>
<p>to your pom.xml file and you&#8217;re off to the races.  However, Maven will process every file in the src/main/resources directory as part of performing this substitution.  This normally wouldn&#8217;t be an issue, but certificate files contain some raw text and Maven dutifully filters them just as it would any resource.  This caused a serious issue with the character encoding as Maven was writing out a file with a completely different encoding scheme than the file was created with.  Basically, Maven filtering was corrupting our certs.</p>
<p>To fix this, I created a subdirectory off of src/main/resources (I called it binary) and added a manual exclusion in the pom.xml file.  The resulting XML looks as follows:</p>
<pre class="brush: xml;">
&lt;resources&gt;
            &lt;resource&gt;
                &lt;directory&gt;src/main/resources&lt;/directory&gt;
                &lt;filtering&gt;true&lt;/filtering&gt;
                &lt;excludes&gt;
                    &lt;exclude&gt;**/binary/*&lt;/exclude&gt;
                &lt;/excludes&gt;
            &lt;/resource&gt;
            &lt;resource&gt;
                &lt;directory&gt;src/main/resources/binary&lt;/directory&gt;
            &lt;/resource&gt;
&lt;/resources&gt;
</pre>
<p>This worked perfectly.  Hopefully, it helps some of you as well!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnnywey.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnnywey.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnnywey.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnnywey.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnnywey.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnnywey.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnnywey.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnnywey.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnnywey.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnnywey.wordpress.com/378/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=378&subd=johnnywey&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://johnnywey.wordpress.com/2009/11/04/careful-with-your-binary-resources/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a06c3df15297e9c39c4eb483a415460?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">johnnywey</media:title>
		</media:content>
	</item>
		<item>
		<title>Grails Acegi Plugin and Securing Multiple Resources using Basic Authentication</title>
		<link>http://johnnywey.wordpress.com/2009/10/29/grails-acegi-plugin-and-securing-multiple-resources-using-basic-authentication/</link>
		<comments>http://johnnywey.wordpress.com/2009/10/29/grails-acegi-plugin-and-securing-multiple-resources-using-basic-authentication/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 01:47:09 +0000</pubDate>
		<dc:creator>johnnywey</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://johnnywey.wordpress.com/?p=373</guid>
		<description><![CDATA[Grails is pretty awesome.  Not only does it use Groovy as its main language, but it also provides nice DSL access to Spring settings.
Securing a website is something that can often be fairly complex and easy to get wrong.  Grails provides a plugin for the state-of-the-art security model Spring Security (also called Acegi) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=373&subd=johnnywey&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://www.grails.org">Grails</a> is pretty awesome.  Not only does it use <a href="http://groovy.codehaus.org">Groovy</a> as its main language, but it also provides nice <a href="http://en.wikipedia.org/wiki/Domain-specific_language">DSL</a> access to <a href="http://www.springsource.org/about">Spring</a> settings.</p>
<p>Securing a website is something that can often be fairly complex and easy to get wrong.  Grails provides a plugin for the state-of-the-art security model <a href="http://www.acegisecurity.org/">Spring Security (also called Acegi)</a> (plugin can be found <a href="http://grails.org/plugin/acegi">here</a>).</p>
<p>Everything was all well and good until I tried to use two different security models simultaneously: a form-based login for human beings and an http basic authentication login for machines consuming an API.</p>
<p>This turned out to be pretty hard.  The plugin requires setting the following in the resources.groovy file to work with basic authentication at all:</p>
<pre class="brush: java;">
beans = {
  authenticationEntryPoint(org.springframework.security.ui.basicauth.BasicProcessingFilterEntryPoint) {
    realmName = 'Grails Realm'
  }
}
</pre>
<p>(The plugin is supposed to automatically do this by setting the <code>basicProcessingFilter = true</code> flag in the SecurityConfigure.groovy file, but there is a bug as of version 0.5.2 which is, as of now, the latest production release.)  This worked for basic authentication, but would no longer redirect users to the form-based login.</p>
<p>Back to the drawing board.</p>
<p>What I discovered was that I could change between using the form-based login or the http headers authentication but not use them both.  (I should clarify this by saying that I could shove the headers into the request and it would work, but a challenge response of 401 was not being sent back to the client which technically breaks the http authentication spec.)  I found <a href="http://www.nabble.com/ACEGI-tc20480575.html">this</a> thread (with contributions from the author of the Acegi plugin itself) but, while it pointed me in a nice direction, it didn&#8217;t answer the question fully.  What I really needed was a way to use the URL to decide how to authenticate.</p>
<p>I finally discovered that the ExceptionTranslationFilter was not unique for the URLs I was using.  In short, if the URL looked like: <code>http://www.test.com/application/api/user/show/1</code>, I wanted to use basic authentication and if the URL was <code>http://www.test.com/application/user/show/1</code>, I wanted to use the form-based authentication.  The redirect is controlled by the ExceptionTranslationFilter and there was only one (so only one model would work at a time).</p>
<p>All I ended up having to do is create my own ExceptionTranslationFilter and wire it to the API URL.  The final code in resources.groovy looks as follows:</p>
<pre class="brush: java;">
import org.springframework.security.util.FilterChainProxy
import org.codehaus.groovy.grails.plugins.springsecurity.GrailsAccessDeniedHandlerImpl
import org.springframework.security.ui.ExceptionTranslationFilter

// Place your Spring DSL code here
beans = {
  basicAuthenticationEntryPoint(org.springframework.security.ui.basicauth.BasicProcessingFilterEntryPoint) {
    realmName = 'Grails Realm'
  }

  basicExceptionTranslationFilter(ExceptionTranslationFilter) {
    authenticationEntryPoint = ref('basicAuthenticationEntryPoint')
    accessDeniedHandler = ref('accessDeniedHandler')
    portResolver = ref('portResolver')
  }

  springSecurityFilterChain(FilterChainProxy) {
    filterInvocationDefinitionSource = &quot;&quot;&quot;
         CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
         PATTERN_TYPE_APACHE_ANT
         /xml*/**=authenticationProcessingFilter,basicProcessingFilter,securityContextHolderAwareRequestFilter,anonymousProcessingFilter,basicExceptionTranslationFilter,filterInvocationInterceptor
         /**=httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor
         &quot;&quot;&quot;
  }
}
</pre>
<p>Now, visiting any URL that prefixed by a <code>/xml/</code> will be a call to the basic authentication headers and every other prefix will be a standard form-based login.</p>
<p>Since I <a href="http://en.wiktionary.org/wiki/yak_shaving">shaved a serious yak</a> figuring this out, I hope it helps someone!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnnywey.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnnywey.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnnywey.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnnywey.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnnywey.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnnywey.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnnywey.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnnywey.wordpress.com/373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnnywey.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnnywey.wordpress.com/373/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=373&subd=johnnywey&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://johnnywey.wordpress.com/2009/10/29/grails-acegi-plugin-and-securing-multiple-resources-using-basic-authentication/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a06c3df15297e9c39c4eb483a415460?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">johnnywey</media:title>
		</media:content>
	</item>
		<item>
		<title>Staying Together for the Kids</title>
		<link>http://johnnywey.wordpress.com/2009/09/22/staying-together-for-the-kids/</link>
		<comments>http://johnnywey.wordpress.com/2009/09/22/staying-together-for-the-kids/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 18:06:49 +0000</pubDate>
		<dc:creator>johnnywey</dc:creator>
				<category><![CDATA[Spirituality]]></category>

		<guid isPermaLink="false">http://johnnywey.wordpress.com/?p=369</guid>
		<description><![CDATA[After the church I was involved with fell apart a couple of years ago, a group of us from the music team continued to meet and play together.  Occasionally, we’ll get calls from other churches asking us to fill in for their Sunday service and give their worship team a chance to take a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=369&subd=johnnywey&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>After the church I was involved with fell apart a couple of years ago, a group of us from the music team continued to meet and play together.  Occasionally, we’ll get calls from other churches asking us to fill in for their Sunday service and give their worship team a chance to take a break (playing week-in / week-out can get tiresome and often strain volunteer musicians to an emotional breaking point).</p>
<p>One church we recently had the pleasure of subbing for is in the middle of a church split due to the recent vote by the ELCA (Evangelical Lutheran Church in America) to allow for those in “life-long, monogamous, same-gendered&#8221; relationships to serve in leadership positions (find out more at <a href="http://www.washingtonpost.com/wp-dyn/content/article/2009/08/21/AR2009082103343.html">http://www.washingtonpost.com/wp-dyn/content/article/2009/08/21/AR2009082103343.html</a>).  For those who don’t know, the ELCA is the largest Lutheran denomination in the United States and has classically been a bit more liberal than other Lutheran organizations.  The provision does not require churches to accept homosexual ministers but allows for churches that desire integration of same-sex couples into leadership to do so.</p>
<p>To be clear, I’m not Lutheran.  However, observing all of this has impacted me fairly heavily, perhaps bringing back some difficult memories of the demise of our faith community in early 2007.</p>
<p>One of the reasons I believe Christianity has been able to survive as long as it has revolves around its ability to adapt to cultural shifts and maintain relevancy.  For example, there was a period of time when the church strictly forbade divorce, but it has largely moved away from that stance and has welcomed divorced individuals into fellowship.  In fact, <a href="http://www.christianpost.com/article/20080404/study-christian-divorce-rate-identical-to-national-average/index.html">studies show the current divorce rate among Christians is very similar, if not identical, to the national average</a>.</p>
<p>It’s hard to imagine a time when a church would split over an issue like divorce, but it did happen (part of the reason for the creation of the <a href="http://en.wikipedia.org/wiki/Church_of_england">Anglican Church</a>) and many people held passionate views one way or the other.  I see a mirrored situation currently taking place as Christianity struggles to find a place for homosexuals in both fellowship and leadership.</p>
<p>The interesting thing about this decision by the ELCA is that it did not <em>require</em> member congregations to appoint gay elders and even allowed congregations to reject the practice internally.  The fact that church splits are taking place over an issue that will probably have little pragmatic impact on them serves to show just how heated and difficult it is.</p>
<p>I’m not writing to weigh in on one side or the other.  I am writing, however, to encourage those on both sides to try and find common ground and avoid splits if possible.  Speaking from experience, the destruction of a community has a severely negative impact on those involved and should always be considered a last resort of sorts.  There is lots of room for discussion and debate on the matter, but I think it is important that the issue is placed in a historical context.  The church has flexed to allow for lifestyles in today’s modern day that it would have never even considered hundreds of years ago.  As charged as the fight for or against allowing women into leadership was at the time, it seems rather petty in today’s modern world.  The same goes with a host of other issues such as the allowance of tattoos or the orbit of the planets in the solar system.</p>
<p>My opinion is that none of these are worth the destruction and heartbreak that a division has both internally in the community experiencing it and externally to those looking in at the faith.  If there is a way to maintain unity, I hope they can find it regardless of the perceived cost!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnnywey.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnnywey.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnnywey.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnnywey.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnnywey.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnnywey.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnnywey.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnnywey.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnnywey.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnnywey.wordpress.com/369/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=369&subd=johnnywey&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://johnnywey.wordpress.com/2009/09/22/staying-together-for-the-kids/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a06c3df15297e9c39c4eb483a415460?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">johnnywey</media:title>
		</media:content>
	</item>
		<item>
		<title>Book Review: Craig Walls &#8211; Modular Java</title>
		<link>http://johnnywey.wordpress.com/2009/09/02/book-review-craig-walls-modular-java/</link>
		<comments>http://johnnywey.wordpress.com/2009/09/02/book-review-craig-walls-modular-java/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 02:40:51 +0000</pubDate>
		<dc:creator>johnnywey</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://johnnywey.wordpress.com/?p=354</guid>
		<description><![CDATA[A few weeks ago, I had the pleasure of getting a promotional copy of Craig Walls&#8217; (from Spring In Action fame) new book and thought I&#8217;d post a review of it here on my blog.

For more information on OSGi, visit http://www.osgi.org
For more information on the Spring Framework, start at http://www.springsource.org


Modular Java: Creating Flexible Applications with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=354&subd=johnnywey&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><em>A few weeks ago, I had the pleasure of getting a promotional copy of Craig Walls&#8217; (from <a href="http://www.amazon.com/Spring-Action-Craig-Walls/dp/1933988134/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1251945563&amp;sr=1-1">Spring In Action</a> fame) new book and thought I&#8217;d post a review of it here on my blog.</p>
<ul>
<li>For more information on OSGi, visit <a href="http://www.osgi.org">http://www.osgi.org</a></li>
<li>For more information on the Spring Framework, start at <a href="http://www.springsource.org">http://www.springsource.org</a></li>
</ul>
<p></em></p>
<p><a href="http://www.amazon.com/Modular-Java-Applications-Pragmatic-Programmers/dp/1934356409/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1251945503&amp;sr=8-1">Modular Java: Creating Flexible Applications with OSGi and Spring</a> provides a great introduction to those either curious about OSGi or wanting to get more out of their existing OSGi workflow using the Spring Framework.  <div id="attachment_361" class="wp-caption alignleft" style="width: 210px"><img src="http://johnnywey.files.wordpress.com/2009/09/osgi.jpg?w=200&#038;h=200" alt="The cover to Modular Java" title="Craig Walls Modular Java Cover" width="200" height="200"><p class="wp-caption-text">Modular Java by Craig Walls</p></div>Craig Walls, author of “Spring in Action, 2nd Edition”, opens the book explaining why OSGi matters and how it can be used to enhance the modularity and maintainability of those application stacks containing multiple and complex moving parts.  He not only serves up a great introduction to the technology, but also directs the reader to several tools that make OSGi development significantly easier.</p>
<p>In the second portion of the book, Craig throws Spring into the mix and demonstrates how the power of Spring Dependency Injection, autowiring, and the Spring MVC web framework can not only run seamlessly in an OSGi container, but also remove a large portion of the burden that OSGi’s API can put on application development.</p>
<p>Finally, Craig spends some time describing how an actual deployment might look in a production environment using both Tomcat and Jetty and provides optimization tips that make the process as painless as possible.</p>
<p>The book itself is logically organized and Craig’s writing style is approachable and easy to follow.  All the example source code is available online, and Craig demonstrates how to install OSGi packages using both Eclipse Equinox and Apache Felix, leaving the final OSGi container decision up to the preference and requirements of the project.  The sample application Craig uses to demonstrate the concepts in the book is surprisingly fun and useful, and the book contains some wonderful appendices that function as a great reference for current and future development projects.  The book is a relatively quick read but surprisingly complete.</p>
<p>For someone looking to get the most out of OSGi or wanting to find out what all the “buzz” is about, Craig Walls’ book is an outstanding choice.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnnywey.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnnywey.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnnywey.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnnywey.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnnywey.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnnywey.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnnywey.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnnywey.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnnywey.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnnywey.wordpress.com/354/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=354&subd=johnnywey&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://johnnywey.wordpress.com/2009/09/02/book-review-craig-walls-modular-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a06c3df15297e9c39c4eb483a415460?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">johnnywey</media:title>
		</media:content>

		<media:content url="http://johnnywey.files.wordpress.com/2009/09/osgi.jpg" medium="image">
			<media:title type="html">Craig Walls Modular Java Cover</media:title>
		</media:content>
	</item>
		<item>
		<title>The Perils of MySQL Timestamps</title>
		<link>http://johnnywey.wordpress.com/2009/08/19/the-perils-of-mysql-timestamps/</link>
		<comments>http://johnnywey.wordpress.com/2009/08/19/the-perils-of-mysql-timestamps/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 02:34:53 +0000</pubDate>
		<dc:creator>johnnywey</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://johnnywey.wordpress.com/?p=332</guid>
		<description><![CDATA[Or, perhaps more accurately, learning about timezone oddities in MySQL the Hard Way

The decision was made and we were ready to switch our entire system to UTC.  Operating in a timezone with daylight savings, and one which most of our users didn&#8217;t themselves operate in, made it a no-brainer.  Making the switch on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=332&subd=johnnywey&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h3><em>Or, perhaps more accurately, learning about timezone oddities in MySQL the Hard Way</em></h3>
<hr />
The decision was made and we were ready to switch our entire system to UTC.  Operating in a timezone with daylight savings, and one which most of our users didn&#8217;t themselves operate in, made it a no-brainer.  Making the switch on production was easy: simply modify the local timezone and restart the application stack.  Aside from modifying the timing of some cron jobs, the only real headache was how to manage legacy data.<br />
<br />
The system had been running in Mountain Time since June of 2008.  We had accumulated a large amount of data with timestamps used for all sorts of mission-critical decisions and we naturally wanted those timestamps to be updated to UTC as part of the switch.<br />
<br />
My first approach was to write a really simple groovy script (edited for proprietary content and formatted to fit in your browser window):</p>
<pre><code>
// the sql var points to the database sql connection info
def startTime = new Date()
sql.eachRow("show tables") { row-&gt;
  tables &lt;&lt; row['Tables_in_database']
}
sql.eachRow("show columns from " + table) { field-&gt;
  if(field['Type']=='timestamp') {
    println "Found timestamp field of ${field['Field']} in ${table}"
    def updateStatement = "update " + table +
    " set ${field['Field']} = " +
    "(select date_add(${field['Field']}, INTERVAL 6 HOUR)) " +
    "where ${field['Field']} is not null"
    println "Updated ${sql.executeUpdate(updateStatement)} " +
    "records from ${table}"
    }
}

Integer totalSeconds = ((new Date()).time - startTime.time)/1000
println "\n\nComplete!  Total time: ${totalSeconds} second(s)"
</code></pre>
<p>Not bad.  The script simply runs through each of the tables with a timestamp and adds 6 hours (the difference between MDT and UTC) to the timestamps.  It&#8217;s not perfect (we had another time change to think about), but it was deemed good enough since timestamps with dates before the last &#8220;spring forward&#8221; change from MST to MDT were beyond the point where their hour of innacuraccy would have a measurable affect on the system (we&#8217;re all about pragmatism).</p>
<p>However, I kept getting a very odd error when running the script against test data.  <em>Data truncation: Incorrect datetime value &#8220;2009-03-08 02:08:00&#8243;</em>  After some research, the reason became obvious: there is no 2am hour on the 8th of March!  That hour was skipped when daylight savings took affect.  Makes sense, but I was dissappointed that MySQL didn&#8217;t just figure that out for me.  No big deal &#8230; I modified the above script to take that into account.  We were off.</p>
<p>Or so we thought.</p>
<p>In testing today, we found out that MySQL stores timestamps internally as UTC times and does the timezone extrapolation dynamically.  This meant that I didn&#8217;t need to go through the above excercise at all &#8230; all we had to do was verify the MySQL server was running in the same timezone as the server itself (<code>select @timezone;</code>), update the server&#8217;s timezone, and restart mysqld!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnnywey.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnnywey.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnnywey.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnnywey.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnnywey.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnnywey.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnnywey.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnnywey.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnnywey.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnnywey.wordpress.com/332/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=332&subd=johnnywey&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://johnnywey.wordpress.com/2009/08/19/the-perils-of-mysql-timestamps/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a06c3df15297e9c39c4eb483a415460?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">johnnywey</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding SOAP Headers to CXF Calls</title>
		<link>http://johnnywey.wordpress.com/2009/04/09/adding-soap-headers-to-cxf-calls/</link>
		<comments>http://johnnywey.wordpress.com/2009/04/09/adding-soap-headers-to-cxf-calls/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 17:48:01 +0000</pubDate>
		<dc:creator>johnnywey</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://johnnywey.wordpress.com/?p=301</guid>
		<description><![CDATA[Recently, I consumed a WSDL with Apache CXF that required authentication information to be placed into a SOAP Header rather than through standard HTTP authentication.  This is all well and good, but I couldn&#8217;t figure out how to attach the headers to the CXF method calls.  The authentication object had been generated by [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=301&subd=johnnywey&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Recently, I consumed a WSDL with <a href="http://cxf.apache.org/">Apache CXF</a> that required authentication information to be placed into a <a href="http://www.w3schools.com/soap/soap_header.asp">SOAP Header</a> rather than through standard HTTP authentication.  This is all well and good, but I couldn&#8217;t figure out how to attach the headers to the CXF method calls.  The authentication object had been generated by CXF, but there was no way to attach the object to the other methods.</p>
<p>After some research, I found the answer.  Adding <code>-exsh true</code> to WSDL2JAVA updated the method signatures to include the header object as a valid parameter.  If you&#8217;re cool like me and use the <a href="http://cwiki.apache.org/CXF20DOC/maven-integration-and-plugin.html">CXF Maven code generator plugin</a>, the XML looks like this:<br />
<code></p>
<pre>
&lt;execution&gt;
&lt;id&gt;generate-sources-vixxi&lt;/id&gt;
  &lt;phase&gt;generate-sources&lt;/phase&gt;
    &lt;configuration&gt;
      &lt;sourceRoot&gt;target/generated-sources&lt;/sourceRoot&gt;
        &lt;wsdlOptions&gt;
          &lt;wsdlOption&gt;
            &lt;extraargs&gt;
              &lt;extraarg&gt;-exsh&lt;/extraarg&gt;
              &lt;extraarg&gt;true&lt;/extraarg&gt;
            &lt;/extraargs&gt;
          &lt;wsdl&gt;yourWSDLPathHere&lt;/wsdl&gt;
        &lt;/wsdlOption&gt;
      &lt;/wsdlOptions&gt;
    &lt;/configuration&gt;
    &lt;goals&gt;
      &lt;goal&gt;wsdl2java&lt;/goal&gt;
    &lt;/goals&gt;
&lt;/execution&gt;
</pre>
<p></code><br />
<br />
I verified this works with CXF 2.0.9 and 2.1.4.  I haven&#8217;t tested it on any other versions, but I don&#8217;t see any reason why it wouldn&#8217;t work on 2.0.9+.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnnywey.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnnywey.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnnywey.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnnywey.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnnywey.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnnywey.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnnywey.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnnywey.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnnywey.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnnywey.wordpress.com/301/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=301&subd=johnnywey&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://johnnywey.wordpress.com/2009/04/09/adding-soap-headers-to-cxf-calls/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a06c3df15297e9c39c4eb483a415460?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">johnnywey</media:title>
		</media:content>
	</item>
		<item>
		<title>An Example of a Poor UI and Poor Customer Service</title>
		<link>http://johnnywey.wordpress.com/2009/03/04/an-example-of-a-poor-ui-and-poor-customer-service/</link>
		<comments>http://johnnywey.wordpress.com/2009/03/04/an-example-of-a-poor-ui-and-poor-customer-service/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 04:17:34 +0000</pubDate>
		<dc:creator>johnnywey</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://johnnywey.wordpress.com/?p=294</guid>
		<description><![CDATA[Or, perhaps more fittingly, why I am unhappy with Comcast.
Since I got back to Colorado from Hawaii in 2003, I&#8217;ve used, and been relatively happy with, Comcast broadband Internet.  There have been issues, but nothing that has been so bad as for me to consider moving to another service.
Unfortunately, that changed last week.
Let me [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=294&subd=johnnywey&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><em>Or, perhaps more fittingly, why I am unhappy with Comcast.</em></p>
<p>Since I got back to Colorado from Hawaii in 2003, I&#8217;ve used, and been relatively happy with, Comcast broadband Internet.  There have been issues, but nothing that has been so bad as for me to consider moving to another service.</p>
<p>Unfortunately, that changed last week.</p>
<p>Let me back up and say that I don&#8217;t often use my Blog to call out a company for something irritating (that&#8217;s usually relegated to <a href="http://www.twitter.com/johnnywey">Twitter</a>).  In this case, however, I feel it a good object lesson in how poor design coupled with horrible customer service can transform a (mostly) satisfied customer and cause them to look into other options.</p>
<p>What took place is pretty simple to understand.  My wife and I share the account, and her email address is one of the six email accounts that I can have attached to our service.  She decided she wanted to add another address.  What she didn&#8217;t know, and what the UI didn&#8217;t tell her (in <span style="color:#ff0000;"><strong>BIG RED WARNING LETTERS</strong></span>) was she was actually <em>changing</em> her email account.  Without any &#8220;are you sure you understand what you are doing and want to do this?&#8221; type of dialog, her email address was changed and her previous account stopped receiving mail immediately.</p>
<p>When she realized what happened, she frantically clicked back to get her old address re-activated, but the UI continued to tell her the username was in use <em>even though it had been deactivated</em>.</p>
<p>She called me pretty upset, and I got on the phone with Comcast.  They told me that they couldn&#8217;t do anything about the issue for a minimum of 30 days.  When I asked them why, they told me that when an email address is deactivated, it gets placed into a &#8220;holding&#8221; status for 30 days to insure another person doesn&#8217;t take the alias and start receiving mail intended for another customer.  This makes a lot of sense to me.  The odd thing is that they couldn&#8217;t re-activate it <em>for the same customer</em>!</p>
<p>I told the CSR on the phone that someone should be able to quite easily login to their database and type something like:<br />
<code><br />
update user set status="active" where username = "[Amber's username]";<br />
</code><br />
and that, while I knew <em>he</em> couldn&#8217;t do it, someone with a shiny Comcast data-center badge could.</p>
<p>After much back and forth, he finally submitted an &#8220;IT&#8221; ticket for me.  Since then, and his promise that this would be resolved in 72 hours (over a week and a half ago from today), I&#8217;ve heard nothing.</p>
<p>There are a couple of lessons here.  The first is that it is obvious Comcast doesn&#8217;t get how important an email address is.  <em>I would have rather Amber lost her phone number than her email address</em>.  From our online banking to Facebook, it is extremely difficult to change an email address when you have no access to the old one.  Most services send confirmation messages to the old email address.  The CSR I spoke with and Comcast&#8217;s policies in general around this issue prove that, while they claim to be on the vanguard of Internet technology, they just don&#8217;t get it.  At all.</p>
<p>Secondly, it is extremely easy to add UI confirmations so do it!  There is no excuse for this type of oversight whatsoever.</p>
<p>Our current plan is to switch over to Qwest Fiber as soon as it becomes available in our area.  Unfortunately, Comcast has lost our confidence.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnnywey.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnnywey.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnnywey.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnnywey.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnnywey.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnnywey.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnnywey.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnnywey.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnnywey.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnnywey.wordpress.com/294/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=294&subd=johnnywey&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://johnnywey.wordpress.com/2009/03/04/an-example-of-a-poor-ui-and-poor-customer-service/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a06c3df15297e9c39c4eb483a415460?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">johnnywey</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Autocompleter.Local with Ajax Lists</title>
		<link>http://johnnywey.wordpress.com/2009/01/14/using-autocompleterlocal-with-ajax-lists/</link>
		<comments>http://johnnywey.wordpress.com/2009/01/14/using-autocompleterlocal-with-ajax-lists/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 03:20:27 +0000</pubDate>
		<dc:creator>johnnywey</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Prototype/Scriptaculous]]></category>

		<guid isPermaLink="false">http://johnnywey.wordpress.com/?p=289</guid>
		<description><![CDATA[The Autocompleter suite of functions in Scriptaculous are pretty nice.  While they don&#8217;t solve every autocomplete problem straight out, they do provide a good starting point.
However, the answers to problems in Javascript are not always obvious.  Despite some amazing support from Firebug, debugging is often difficult and tracing down problems can be rough.
Earlier [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=289&subd=johnnywey&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The Autocompleter suite of functions in Scriptaculous are pretty nice.  While they don&#8217;t solve every autocomplete problem straight out, they do provide a good starting point.</p>
<p>However, the answers to problems in Javascript are not always obvious.  Despite some amazing support from Firebug, debugging is often difficult and tracing down problems can be rough.</p>
<p>Earlier this week, I ran into a very strange problem with Autocompleter.Local.  I was designing a page that would query the server for a list of cities in a state and load that list into the Autocompleter.  The catch was that the state could be changed at any time by the user, and the array containing the list of cities available would be updated asynchronously from the server.  (While there is an Autocompleter.Ajax for automatic server updates, this assumes the autocompletion is done on the server side which I deemed too slow to be very functional in our case.)  The specific issue I was having was that the city name was inserted into the target text field multiple times as the number of hits to the server for updated city lists increased.</p>
<p>I discovered, after looking over code in control.js, that the Autocompleter attaches event observers every time it is newed up.  These event observers are difficult to remove manually because they pass in states of the specific object that are often no longer available.  I had code that was doing something like:</p>
<pre>
<code>
[get list of city names for a state into cityNameList]
if(!autocompleter)
  autocompleter = new Autocompleter.Local('cityTextfield',
   'cityAutocompleteList', cityNameList);
</code>
</pre>
<p>but the the observers that the Autocompleter was creating were being piled up on each other every time I &#8220;reset&#8221; the Autocompleter to a new instance.</p>
<p>I discovered that the Autocompleter data is stored in the .options.array field.  While it is not documented as part of the API, updating this array effectively updated the Autocompleter without adding new event observers.  All I had to do was new up the Autocompleter variable once and then update this array field (directly; using dot notation) every time the data from the server changed.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnnywey.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnnywey.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnnywey.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnnywey.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnnywey.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnnywey.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnnywey.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnnywey.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnnywey.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnnywey.wordpress.com/289/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=289&subd=johnnywey&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://johnnywey.wordpress.com/2009/01/14/using-autocompleterlocal-with-ajax-lists/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a06c3df15297e9c39c4eb483a415460?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">johnnywey</media:title>
		</media:content>
	</item>
		<item>
		<title>Manually Set Map Value in Struts 2</title>
		<link>http://johnnywey.wordpress.com/2008/12/24/manually-set-map-value-in-struts-2/</link>
		<comments>http://johnnywey.wordpress.com/2008/12/24/manually-set-map-value-in-struts-2/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 15:59:34 +0000</pubDate>
		<dc:creator>johnnywey</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Struts 2]]></category>

		<guid isPermaLink="false">http://johnnywey.wordpress.com/?p=281</guid>
		<description><![CDATA[Often, the Struts 2 tag library doesn&#8217;t offer enough functionality to support a nice DHTML type of layout.  In those cases, I find myself creating URLs manually to send to the action.
In most cases, this isn&#8217;t a bid deal.  However, to make it work right, you have to duplicate the format that Struts [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=281&subd=johnnywey&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Often, the Struts 2 tag library doesn&#8217;t offer enough functionality to support a nice DHTML type of layout.  In those cases, I find myself creating URLs manually to send to the action.</p>
<p>In most cases, this isn&#8217;t a bid deal.  However, to make it work right, you have to duplicate the format that Struts uses to receive the data.  For example, to send a list of items (such as <code>List&lt;String&gt; names;</code>), you would format your URL to look like </p>
<p><code><br />
&amp;names=johnny&amp;names=tim&amp;names=bill<br />
</code></p>
<p>Maps are a little harder.  To create a URL to send to a map, you can use the following format:</p>
<p><code><br />
&amp;variableName[key]=value<br />
</code></p>
<p>Say you have the following map:</p>
<p><code>Map&lt;Integer, Integer&gt; userIdOrderIdMap = new HashMap&lt;Integer, Integer&gt;();</code></p>
<p>To set the map from Struts 2, you&#8217;d use the following URL string: </p>
<p><code><br />
&amp;userIdOrderIdMap[0]=1&amp;userIdOrderIdMap[10]=15</code></p>
<p>This is the equivalent of:</p>
<p><code><br />
userIdOrderIdMap.put(0, 1);<br />
userIdOrderIdMap.put(10, 15);<br />
</code></p>
<p>You will probably have to manually call encodeURIComponent() on the URL string to make sure the brackets and any other special characters are escaped properly, but you already knew that, right?</p>
<p>You can also use a dot notation (such as <code>&amp;variableName.key=value</code>), but I find that a bit counterintuitive to the way KVC types are intended to be represented.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnnywey.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnnywey.wordpress.com/281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnnywey.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnnywey.wordpress.com/281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnnywey.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnnywey.wordpress.com/281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnnywey.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnnywey.wordpress.com/281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnnywey.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnnywey.wordpress.com/281/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=281&subd=johnnywey&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://johnnywey.wordpress.com/2008/12/24/manually-set-map-value-in-struts-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a06c3df15297e9c39c4eb483a415460?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">johnnywey</media:title>
		</media:content>
	</item>
		<item>
		<title>The Power of Unit Tests</title>
		<link>http://johnnywey.wordpress.com/2008/12/12/the-power-of-unit-tests/</link>
		<comments>http://johnnywey.wordpress.com/2008/12/12/the-power-of-unit-tests/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 13:51:24 +0000</pubDate>
		<dc:creator>johnnywey</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://johnnywey.wordpress.com/?p=270</guid>
		<description><![CDATA[Yesterday, my dev team embarked on a significant refactor of our main code base in order to merge in a branch alongside implementing new functionality and changing some existing classes.  A trifecta of complexity if you will.  For a production quality system, one that we expect to deploy very soon and is the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=270&subd=johnnywey&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Yesterday, my dev team embarked on a significant refactor of our main code base in order to merge in a branch alongside implementing new functionality <b>and</b> changing some existing classes.  A trifecta of complexity if you will.  For a production quality system, one that we expect to deploy very soon and is the backbone of our company&#8217;s infrastructure, you might expect us to have been a bit more careful / timid in making our changes.</p>
<p>However, you&#8217;d be wrong and it&#8217;s all because of unit tests (that and we are all rock-star engineers, but that&#8217;s another post).</p>
<p>I didn&#8217;t work with unit tests much before my current position.  This was mostly due to legacy platform limitations that did not make automated testing easy.  Now, I couldn&#8217;t live without them.  Confidence in my work is much greater now than it was previously for a good reason: unit tests give engineers power.</p>
<p>I know that the requirements of a particular class are laid out in the classes&#8217; test.  Whatever I do to the class, it must not only compile but light up green.  This gives me the boldness to make large changes without worrying that the refactor is going to negatively impact (read: break) other parts of the system.</p>
<p>Code these days often exists beyond the classes themselves and in places like configuration files and build scripts, and we&#8217;ve created tests that take these pieces of auxiliary setup into account.  Doing that extends our confidence beyond our primary classes and into our build process, database connections, and system as a cohesive whole.  Very cool.</p>
<p>Unit tests are great for creating interfaces (working with the API before you actually write the implementation is a good way to make sure it doesn&#8217;t suck), verifying complex functionality, and system integration.  The most empowering thing they offer, however, is confidence.  In an agile shop such as ours, this gives us the ability to work as quickly and fluidly as possible and is a huge factor in why our little team has been so successful.</p>
<blockquote><p>&#8220;A compiler tells you your code is well formed, a unit test tells you your code is well behaved.&#8221;</p></blockquote>
<p> &#8211; No Fluff Just Stuff, Fall 2008</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnnywey.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnnywey.wordpress.com/270/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnnywey.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnnywey.wordpress.com/270/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnnywey.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnnywey.wordpress.com/270/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnnywey.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnnywey.wordpress.com/270/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnnywey.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnnywey.wordpress.com/270/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnnywey.wordpress.com&blog=1415338&post=270&subd=johnnywey&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://johnnywey.wordpress.com/2008/12/12/the-power-of-unit-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a06c3df15297e9c39c4eb483a415460?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">johnnywey</media:title>
		</media:content>
	</item>
	</channel>
</rss>