<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Todd Huss &#187; Java</title>
	<atom:link href="http://gabrito.com/post/category/technical/java/feed" rel="self" type="application/rss+xml" />
	<link>http://gabrito.com</link>
	<description>Anecdotes on Technology Leadership, Ruby, Java, Scala, Cloud Computing, Open-Source, SEO, and Design</description>
	<lastBuildDate>Wed, 18 Aug 2010 23:33:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Code readability through conciseness</title>
		<link>http://gabrito.com/post/code-readability-through-conciseness</link>
		<comments>http://gabrito.com/post/code-readability-through-conciseness#comments</comments>
		<pubDate>Tue, 10 Aug 2010 22:06:51 +0000</pubDate>
		<dc:creator>Todd Huss</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://gabrito.com/?p=286</guid>
		<description><![CDATA[One of the things I love about newer languages like Ruby and Scala (and to a degree Python and Groovy) are the language features that allow you to dial conciseness up or down for readability. Take for instance the typical &#8230; <a href="http://gabrito.com/post/code-readability-through-conciseness">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://gabrito.com/wp-content/uploads/2010/08/lambda.jpeg" alt="" title="lambda" width="72" height="80" class="alignleft size-full wp-image-287" />One of the things I love about newer languages like  Ruby and Scala (and to a degree Python and Groovy) are the language features that allow you to dial conciseness up or down for readability. Take for instance the typical one liner for summing numbers in languages that support anonymous functions (which can be a bit cryptic in terms of readability):</p>
<p><code><strong>Ruby</strong><br />
sum = [1,2,3,4].inject(0) {|result, value| result + value}<br />
<strong>Scala</strong><br />
val sum = Array(1,2,3,4).foldLeft(0) ((result, value) => result + value)<br />
<strong>Groovy</strong><br />
sum = [1,2,3,4].inject(0) { result, value -> result + value }<br />
<strong>Python</strong><br />
sum = reduce(lambda result, value: result + value, [1,2,3,4])</code></p>
<p>One of the jobs of a good programmer<span id="more-286"></span> is to make their code readable and in this case by naming the variable sum it&#8217;s obvious what&#8217;s going on to the right so if you can simplify the anonymous function or use syntactic sugar to reduce the amount of code there&#8217;s a good chance you can improve the readability as follows:</p>
<p><code><strong>Ruby</strong><br />
sum = [1,2,3,4].inject(:+)<br />
<strong>Scala can either reduce the anonymous function</strong><br />
val sum = Array(1,2,3,4).reduceLeft(_+_)<br />
<strong>or in Scala 2.8 they added the sum method</strong><br />
val sum = Array(1,2,3,4).sum<br />
<strong>Groovy can't reduce the anonymous function but has a sum method</strong><br />
sum = [1,2,3,4].sum<br />
<strong>Python can't reduce the anonymous function but has a sum function</strong><br />
sum = sum([1,2,3,4])</code></p>
<p>Then even if the programmer reading the code is coming from another language and doesn&#8217;t know :+ or _+_ you&#8217;ll still have improved readability because they certainly understand how a sum is computed and can move past the line of code instead of having to read 3-4 lines of a for loop for something as simple as a summing operation. I love the balance of being very concise with the simple stuff so that I can be more verbose with the complex stuff, whereas in Java even the simple stuff is often extremely verbose.</p>
<p>There is of course the extreme of making your code too concise. Look no further than <a target="_blank" href="http://en.wikipedia.org/wiki/Write-only_language">write-only languages</a> like Perl to see where too much conciseness and obfuscation can lead to unmaintainable code.</p>
<p>This example is only trivial and somewhat contrived but I find that newer languages like Ruby and Scala give you significantly better tools to elegantly dial up or down the conciseness than Java or C# resulting in <em>less code + more readable code = easily maintainable code</em>.</p>
<p>As an example, I used just about every conciseness trick in the book I knew of when composing <a target="_blank" href="http://github.com/thuss/rpcfn-3-shortest_path">my submission</a> for the <a target="_blank" href="http://rubylearning.com/blog/2009/10/30/rpcfn-short-circuit-3/">3rd Ruby Challenge&#8217;s Shortest Path Algorithm</a> and I only discarded the ones that I thought obfuscated the intent. I like to think the reason my submission won was precisely because it was concise while still being readable. Writing that same algorithm with the same level of readability in Scala would be easy but in Java it would have tripled the lines of code hurting readability somewhat.</p>
]]></content:encoded>
			<wfw:commentRss>http://gabrito.com/post/code-readability-through-conciseness/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Selenium Continuous Integration Runner</title>
		<link>http://gabrito.com/post/selenium-continuous-integration-runner</link>
		<comments>http://gabrito.com/post/selenium-continuous-integration-runner#comments</comments>
		<pubDate>Sat, 10 Jan 2009 20:34:47 +0000</pubDate>
		<dc:creator>Todd Huss</dc:creator>
				<category><![CDATA[Agile Development]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Quality Assurance]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://gabrito.com/?p=227</guid>
		<description><![CDATA[At Common Sense Media I wanted to get some functional testing up and running that didn&#8217;t require a lot of user training for the QA folks. I also wanted those tests to run in our Rightscale/Amazon EC2 hosted Hudson continuous &#8230; <a href="http://gabrito.com/post/selenium-continuous-integration-runner">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://seleniumhq.org/" target="_blank"><img src="http://gabrito.com/wp-content/uploads/2009/01/selenium1.png" alt="selenium" title="selenium" width="200" height="181" class="alignleft size-full wp-image-226" /></a> At <a href="http://www.commonsensemedia.org/">Common Sense Media</a> I wanted to get some functional testing up and running that didn&#8217;t require a lot of user training for the QA folks. I also wanted those tests to run in our <a href="http://www.rightscale.com/">Rightscale</a>/<a href="http://aws.amazon.com/ec2/">Amazon EC2</a> hosted <a href="https://hudson.dev.java.net/">Hudson continuous integration server</a>. As a result I&#8217;ve published the:</p>
<p><a href="http://github.com/thuss/selenium-continuous-integration-runner/tree/master"> Selenium Selenese Continuous Integration Runner</a> </p>
<p>on GitHub in the hopes that it will save other people time when trying to get their Selenese tests running from a continuous integration server. It&#8217;s very simple but one thing I battled with was that I had to patch the selenium JAR to get it to work with Firefox 3.0. It should work fine in any continuous integration server regardless if it&#8217;s <a href="https://hudson.dev.java.net/">Hudson</a>, <a href="http://studios.thoughtworks.com/cruise-continuous-integration">Cruise</a>, <a href="http://cruisecontrol.sourceforge.net/">Cruise Control</a>, <a href="http://www.atlassian.com/software/bamboo/">Bamboo</a>, etc.</p>
<p>The functional testing products I&#8217;ve used that drive a real browser include <a href="http://www.automatedqa.com/">Test Complete (commercial)</a>, <a href="http://seleniumhq.org/">Selenium</a>, and <a href="http://wtr.rubyforge.org/">Watir</a>. I think all 3 do a good job but one thing I like about Selenium is that it&#8217;s dirt simple to get a user productive with the Selenium IDE Firefox plugin. However, that benefit is also the most limiting factor of the <a href="http://seleniumhq.org/">Selenium IDE</a> which is that to be able to re-open tests in Selenium IDE you have to save them as Selenese (which is the most limited of the testing languages that Selenium supports). Still, I think Selenese is a reasonable choice for a lot of organizations that need a moderately sophisticated functional test suite.</p>
]]></content:encoded>
			<wfw:commentRss>http://gabrito.com/post/selenium-continuous-integration-runner/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Standalone Migrations: Using Rails migrations in non Rails projects</title>
		<link>http://gabrito.com/post/standalone-migrations-using-rails-migrations-in-non-rails-projects</link>
		<comments>http://gabrito.com/post/standalone-migrations-using-rails-migrations-in-non-rails-projects#comments</comments>
		<pubDate>Tue, 23 Dec 2008 01:15:47 +0000</pubDate>
		<dc:creator>Todd Huss</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://gabrito.com/?p=194</guid>
		<description><![CDATA[Update 8/7/2010: Standalone migrations is now a gem (sudo gem install standalone_migrations) so disregard the outdated installation instructions below Update 7/8/2009: With the latest batch of contributed patches standalone migrations now works just like Rails migrations Update 12/26/2008: I switched &#8230; <a href="http://gabrito.com/post/standalone-migrations-using-rails-migrations-in-non-rails-projects">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://github.com/thuss/standalone-migrations/tree/master"><img src="http://gabrito.com/wp-content/uploads/2008/12/github.png" alt="Standalone Migrations" title="Standalone Migrations" width="157" height="60" class="alignleft" /></a><strong>Update 8/7/2010</strong>: Standalone migrations is now a gem (sudo gem install standalone_migrations) so disregard the outdated installation instructions below</p>
<p><strong>Update 7/8/2009</strong>: With the latest batch of contributed patches standalone migrations now works just like Rails migrations<br />
<strong>Update 12/26/2008</strong>: I switched standalone migrations to use a Rakefile instead of a Ruby script.</p>
<p>In my work managing websites I end up working in Ruby, Java, and PHP. In everything but Rails managing the schema requires rolling your own solution. As a result I&#8217;ve started using Rails migrations in non-Rails projects to manage the schema. It&#8217;s not much code but I figured others might benefit from it so I created a little Github project called <a target="_blank" href="http://github.com/thuss/standalone-migrations/tree/master">standalone migrations</a>. </p>
<p>It&#8217;s based on Lincoln Stoll&#8217;s blog post titled <a target="_blank" href="http://lstoll.net/2008/04/stand-alone-activerecord-migrations/">Stand-alone ActiveRecord migrations</a> and David Welton&#8217;s blog post titled <a target="_blank" href="http://journal.dedasys.com/2007/01/28/using-migrations-outside-of-rails">Using Migrations Outside of Rails</a>.</p>
<p>Assuming you have Ruby and Gem installed on your machine, here&#8217;s how to use it:</p>
<pre>
gem install -y activerecord rake mysql
wget http://github.com/thuss/standalone-migrations/zipball/master (or fetch it using <a target="_blank" href="http://git.or.cz/">git</a>)
unzip it, and mv to something like my_non_rails_project/db
cd my_non_rails_project/db/ (or wherever you put it)
cp config/database_sample.yml config/database.yml
vi config/database.yml
./new_migration some_user_story
vi migrations/*_some_user_story.rb
rake db:migrate (this applies your newly created migration)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://gabrito.com/post/standalone-migrations-using-rails-migrations-in-non-rails-projects/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Moving to 64 bit Ubuntu</title>
		<link>http://gabrito.com/post/moving-to-64-bit-ubuntu</link>
		<comments>http://gabrito.com/post/moving-to-64-bit-ubuntu#comments</comments>
		<pubDate>Fri, 14 Nov 2008 20:45:51 +0000</pubDate>
		<dc:creator>Todd Huss</dc:creator>
				<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://gabrito.com/?p=183</guid>
		<description><![CDATA[After 3 Ubuntu upgrades on my primary workhorse (a Lenovo Thinkpad z61t) I decided it was time for a fresh install to remove all the cruft. In the past I&#8217;ve always used 32 bit Ubuntu (even though my laptop is &#8230; <a href="http://gabrito.com/post/moving-to-64-bit-ubuntu">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ubuntu.com"><img class="alignleft" src="/files/ubuntu.jpg" alt="Ubuntu Logo" /></a>After 3 Ubuntu upgrades on my primary workhorse (a <a href="http://www.geek.com/articles/chips/lenovo-thinkpad-z61t-notebook-2007044/">Lenovo Thinkpad z61t</a>) I decided it was time for a fresh install to remove all the cruft. In the past I&#8217;ve always used 32 bit Ubuntu (even though my laptop is a 64 bit Core 2 duo) because of issues with the Flash plugin, Java plugin, and Skype. After backing up my files I bit the bullet and did a fresh install of <a href="http://releases.ubuntu.com/8.10/">64 bit Ubuntu Intrepid Ibex</a> and in the process also decided to give <a href="http://www.debian-administration.org/articles/388">XFS a shot instead of EXT3</a> as my primary filesystem.</p>
<p>I&#8217;m pleased to say that after 3 hours I had the install done and all of my software installed and working including Jetbrains IDEA, Netbeans, Skype, VirtualBox, Flash plugin, Java plugin, Web Developer Toolbar, and Firebug. Apparently things have gotten a little better for 64 bit Linux over the past year and a half! However, I&#8217;m still running into odd issues every now and again related to both Sun&#8217;s 64 bit Java (IDE <del>and Jetty</del> occasionally hangs) and the the Open JDK browser plugin which is still buggy. Hopefully future updates will help address these issues. Anyhow, I thought I&#8217;d throw out the links I used to get everything working:</p>
<p><strong>Fonts</strong><br />
<a href="http://www.ubuntu-unleashed.com/2008/05/howto-install-mac-fonts-on-ubuntu.html">Howto: Install Mac Fonts on Ubuntu</a><br />
<a href="http://stdout-dev-null.blogspot.com/2007/03/make-firefox-in-ubuntu-look-much-better.html">Make Firefox in Ubuntu look much better</a></p>
<p><strong>Skype</strong><br />
<a href="https://help.ubuntu.com/community/Medibuntu">Add the Medibuntu repository</a><br />
sudo apt-get install skype-static</p>
<p><strong>Flash plugin</strong><br />
<a href="http://www.cyberciti.biz/tips/install-flash-10-ubuntu-linux-64bit.html">Install Flash 10 Under Ubuntu Linux 64 bit Edition</a></p>
<p><strong>Java plugin</strong><br />
sudo apt-get install openjdk-6-jre icedtea-gcjwebplugin</p>
]]></content:encoded>
			<wfw:commentRss>http://gabrito.com/post/moving-to-64-bit-ubuntu/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>An interview with the authors of JRuby</title>
		<link>http://gabrito.com/post/an-interview-with-the-authors-of-jruby</link>
		<comments>http://gabrito.com/post/an-interview-with-the-authors-of-jruby#comments</comments>
		<pubDate>Tue, 23 Jan 2007 05:23:17 +0000</pubDate>
		<dc:creator>Todd Huss</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://gabrito.com/post/an-interview-with-the-authors-of-jruby</guid>
		<description><![CDATA[The Java Posse hosted a great podcast interview with the authors of JRuby: Charles Nutter and Thomas Enebo. Additionally you get to hear what Tor Norbye is up to with his work on NetBeans Ruby integration and it looks like &#8230; <a href="http://gabrito.com/post/an-interview-with-the-authors-of-jruby">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The Java Posse hosted a great <a href="http://javaposse.com/index.php?post_id=171709">podcast interview with the authors of JRuby</a>: <a href="http://headius.blogspot.com/">Charles Nutter</a> and <a href="http://www.bloglines.com/blog/ThomasEEnebo">Thomas Enebo</a>. Additionally you get to hear what Tor Norbye is up to with his work on <a href="http://blogs.sun.com/tor/entry/ruby_screenshot_of_the_week1">NetBeans Ruby integration</a> and it looks like there&#8217;s some nice code assist features in the works! Really good code assist is the thing I miss most when doing Ruby (in RadRails) as opposed to  Java (in IDEA).</p>
<p>It&#8217;s exciting to see the convergence of my two favorite languages coming along!</p>
]]></content:encoded>
			<wfw:commentRss>http://gabrito.com/post/an-interview-with-the-authors-of-jruby/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tab completion and history with irb and script/console</title>
		<link>http://gabrito.com/post/tab-completion-and-history-with-irb-and-scriptconsole</link>
		<comments>http://gabrito.com/post/tab-completion-and-history-with-irb-and-scriptconsole#comments</comments>
		<pubDate>Wed, 06 Dec 2006 17:46:08 +0000</pubDate>
		<dc:creator>Todd Huss</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://gabrito.com/post/tab-completion-and-history-with-irb-and-scriptconsole</guid>
		<description><![CDATA[One thing I love about Ruby (and really miss when working in Java) is its interactive command line interpreter irb (or script/console if you&#8217;re using Rails). I really wish irb had tab completion and saved history configured by default out &#8230; <a href="http://gabrito.com/post/tab-completion-and-history-with-irb-and-scriptconsole">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One thing I love about Ruby (and really miss when working in Java) is its interactive command line interpreter <a href="http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks">irb</a> (or <a href="http://wiki.rubyonrails.org/rails/pages/Console">script/console</a> if you&#8217;re using Rails). I really wish <strong>irb</strong> had tab completion and saved history configured by default out of the box. The good news is it&#8217;s easy to configure by creating a <strong>$HOME/.irbrc</strong> file with the following contents:<br />
<span id="more-165"></span></p>
<pre>
require 'irb/completion'
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
IRB.conf[:EVAL_HISTORY] = 1000
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = File::expand_path("~/.irbhistory")
</pre>
<p><!--adsense--></p>
<p>Now when I fire up <strong>irb</strong> or <strong>script/console</strong> I get full readline support including tab completion (for example type Time:: and hit tab), reverse command search (control-R), and saved command history so when I exit and restart my command history is still there!</p>
]]></content:encoded>
			<wfw:commentRss>http://gabrito.com/post/tab-completion-and-history-with-irb-and-scriptconsole/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Instantiating and populating a list or collection</title>
		<link>http://gabrito.com/post/instantiating-and-populating-a-list-or-collection</link>
		<comments>http://gabrito.com/post/instantiating-and-populating-a-list-or-collection#comments</comments>
		<pubDate>Tue, 21 Nov 2006 01:56:21 +0000</pubDate>
		<dc:creator>Todd Huss</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://gabrito.com/post/instantiating-and-populating-a-list-or-collection</guid>
		<description><![CDATA[In Java it always irks me when I have to create a collection and then populate it in separate steps as follows: List states = new ArrayList(); state.add(State.CA); state.add(State.WY); Then today I read about using an anonymous subclass with instance &#8230; <a href="http://gabrito.com/post/instantiating-and-populating-a-list-or-collection">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In Java it always irks me when I have to create a collection and then populate it in separate steps as follows:</p>
<pre>List states = new ArrayList();
state.add(State.CA);
state.add(State.WY);</pre>
<p>Then today I read about using an <a href="http://home.comcast.net/~pholser/writings/concisions.html">anonymous subclass with instance initializer</a> to initialize a collection which appeals to the block loving Rubyist in me:<br />
<span id="more-160"></span></p>
<pre>List states = new ArrayList() {{ add(State.CA); add(State.WY); }};</pre>
<p>Another approach shown to me by a new co-worker specific to Lists (that involves creating an extra array) but is also quite short is:</p>
<p><!--adsense--></p>
<pre>List states = Arrays.asList(new State[]{State.CA, State.WY});</pre>
<p><strong>Update:</strong> <a href="http://cime.net/~ricky/">Ricky Clarkson</a> pointed out the best solution so far in my opinion (requires JDK 5 or higher) using varargs and generics:</p>
<pre>List&lt;String&gt; list=Arrays.asList("rocks","my","world");</pre>
]]></content:encoded>
			<wfw:commentRss>http://gabrito.com/post/instantiating-and-populating-a-list-or-collection/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Upgrading to Spring 2.0 and Hibernate 3.2</title>
		<link>http://gabrito.com/post/upgrading-to-spring-20-and-hibernate-32</link>
		<comments>http://gabrito.com/post/upgrading-to-spring-20-and-hibernate-32#comments</comments>
		<pubDate>Fri, 20 Oct 2006 04:48:43 +0000</pubDate>
		<dc:creator>Todd Huss</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://gabrito.com/post/upgrading-to-spring-20-and-hibernate-32</guid>
		<description><![CDATA[Tonight I just completed the upgrade from Spring 1.2 and Hibernate 3.1 to Spring 2.0 and Hibernate 3.2 for work. I was expecting a rough upgrade but was pleasantly surprised how easily it went. Our entire unit and integration test &#8230; <a href="http://gabrito.com/post/upgrading-to-spring-20-and-hibernate-32">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Tonight I just completed the upgrade from Spring 1.2 and Hibernate 3.1 to <a href="http://static.springframework.org/spring/docs/2.0.x/reference/new-in-2.html">Spring 2.0</a> and <a href="http://www.hibernate.org/344.html">Hibernate 3.2</a> for <a href="http://www.greatschools.net">work</a>. I was expecting a rough upgrade but was pleasantly surprised how easily it went.<br />
<span id="more-158"></span><br />
Our entire unit and integration test suite which hits Spring and Hibernate pretty good runs in about the same amount of time so there doesn&#8217;t appear to be any significant performance penalty or improvement with the upgrade.</p>
<p><!--adsense--></p>
<p>I had one minor problem and it was that we connect to multiple databases so we have multiple session factories that interact with EhCache. Hibernates org.hibernate.cache.EhCacheProvider now expects one configuration per sesssion factory which I wasn&#8217;t too excited about given we have 51 databases (1 database per state plus Washington DC) and it&#8217;s been working fine for 2 years with one cache provider. The problem caused this exception:</p>
<pre>
 Invocation of init method failed; nested exception is java.lang.NullPointerException
    [java] Caused by: org.springframework.beans.factory.BeanCreationException:
       Error creating bean with name 'surveysSessionFactory' defined in class path resource
          [gs/data/dao/hibernate/applicationContext-hibernate.xml]:
          Invocation of init method failed;
          nested exception is java.lang.NullPointerException
    [java] Caused by: java.lang.NullPointerException
    [java] at net.sf.ehcache.CacheManager.detectAndFixDiskStorePathConflict(CacheManager.java:269)
    ...
</pre>
<p>However, I wasn&#8217;t the only person who had this problem so a quick search turned up that EhCache now offers the net.sf.ehcache.hibernate.SingletonEhCacheProvider and switching the hibernate.cache.provider_class property to this new provider solved the problem and allows us to continue using a single cache provider.</p>
]]></content:encoded>
			<wfw:commentRss>http://gabrito.com/post/upgrading-to-spring-20-and-hibernate-32/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Xalan XSL transformations in the 1.4 JDK can be VERY slow</title>
		<link>http://gabrito.com/post/xalan-xsl-transformations-in-the-14-jdk-can-be-very-slow</link>
		<comments>http://gabrito.com/post/xalan-xsl-transformations-in-the-14-jdk-can-be-very-slow#comments</comments>
		<pubDate>Sat, 14 Oct 2006 00:30:13 +0000</pubDate>
		<dc:creator>Todd Huss</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://gabrito.com/post/xalan-xsl-transformations-in-the-14-jdk-can-be-very-slow</guid>
		<description><![CDATA[At work as part of our XML data feed product we end up doing XSLT transformations on XML files starting a a few MB all the way up to several hundred MB. Using the 1.4.2 JDK it took over 4 &#8230; <a href="http://gabrito.com/post/xalan-xsl-transformations-in-the-14-jdk-can-be-very-slow">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>At work as part of our XML data feed product we end up doing XSLT transformations on XML files starting a a few MB all the way up to several hundred MB. Using the 1.4.2 JDK it took over <strong>4 days</strong> to do the XSL transformation on the largest file so over lunch one day we started brainstorming our troubleshooting approach. When we tried it on the 1.5 JDK the same transformation took a <strong>couple of minutes</strong> as opposed to 4 days. Talk about an improvement!<br />
<span id="more-157"></span><br />
However, I was thrown astray of the solution because we include a specific version of Xalan in the classpath so I assumed it was the JDK version that was the differentiator but when I ran it by <a href="http://jroller.com/page/nsikha">Naresh</a> he reminded me that Xalan is included in the JDK. </p>
<p><!--adsense--></p>
<p>If you&#8217;re using JAXP on a 1.5 JDK (where Xalan is now under com.sun.org.apache) or a 1.4 JDK (where Xalan is under org.apache) then the only way to override the version of Xalan is to put it before rt.jar in the bootclasspath. Sure enough, there appears to be some issue with Xalan in the 1.4.2 JDK where large XSL transformations are extremely slow!</p>
<p>Here&#8217;s what it looks like to get Java to use your own version of Xalan:</p>
<p>java -Xbootclasspath:xalan-2.X.X.jar:$JAVA_HOME/jre/lib/rt.jar &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://gabrito.com/post/xalan-xsl-transformations-in-the-14-jdk-can-be-very-slow/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Creating database test fixtures and the rails export fixtures plugin</title>
		<link>http://gabrito.com/post/creating-database-test-fixtures-and-the-rails-export-fixtures-plugin</link>
		<comments>http://gabrito.com/post/creating-database-test-fixtures-and-the-rails-export-fixtures-plugin#comments</comments>
		<pubDate>Wed, 17 May 2006 05:49:15 +0000</pubDate>
		<dc:creator>Todd Huss</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://gabrito.com/post/creating-database-test-fixtures-and-the-rails-export-fixtures-plugin</guid>
		<description><![CDATA[Being able to quickly and easily create test fixtures for your database is important yet it&#8217;s not always easy. There are basically 3 approaches I&#8217;ve seen used: 1. Use a MySQL or PostgreSQL dump that gets imported before the tests &#8230; <a href="http://gabrito.com/post/creating-database-test-fixtures-and-the-rails-export-fixtures-plugin">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Being able to quickly and easily create test fixtures for your database is important yet it&#8217;s not always easy. There are basically 3 approaches I&#8217;ve seen used:</p>
<p>1. Use a MySQL or PostgreSQL dump that gets imported before the tests are run. I&#8217;ve never seen this approach used with Oracle, most likely because it&#8217;s such a PITA to export to text (or at least it used to be)<br />
2. Just create the schema before the tests and then populate the test data in code<br />
3. Use a database test fixture tool such as the <a href="http://dbunit.sourceforge.net/">XML based DBUnit for Java</a> or <a href="http://ar.rubyonrails.org/classes/Fixtures.html">Ruby&#8217;s YAML based fixtures</a><br />
<span id="more-136"></span><br />
I have a strong preference for database test fixture tools because they work across databases (often a requirement at ISV&#8217;s) and generally offers tools to easily export fixtures in addition to importing them. However, the ability to export fixtures from your database to a fixture file is sometimes overlooked but it&#8217;s vitally important as populating those fixtures gets really time consuming if you need to type it all in. The most common use case I run into is when I pull rows of data from production into my local database and once I&#8217;m happy with the sample data want to export it into a fixture file.</p>
<p><!--adsense--></p>
<p>At GreatSchools we&#8217;re a Java shop and we use <a href="http://dbunit.sourceforge.net/">DBUnit</a> which does a fantastic job of exporting and importing database test fixtures. Now that I&#8217;m using Ruby on Rails on outside projects though I was starting to burn out having to manually write the fixtures.yml files by hand because Rails doesn&#8217;t offer an export facility out of the box. In this particular case I was parsing NOAA weather forecasts which I do using script/runner via cron to retrieve over HTTP and populate the database with. They can be fairly lengthy and I needed dozens of records for the tests and the thought of having to write the YAML fixtures file had me scared!</p>
<p>Sure enough after a little web searching I found <a href="http://dev.toolbocks.com/repository/file/plugins/export_fixtures/README">Chris McGrath and Nathaniel Brown&#8217;s export fixtures plugin</a> and I&#8217;m a happy camper again!</p>
<p>Here&#8217;s how you install it:<br />
<code><br />
script/plugin discover<br />
script/plugin install export_fixtures<br />
</code><br />
Then to use it I populate the tables in question with sample data and then run:</p>
<p><code>rake db:fixtures:export_for_tables TABLES=table1,table2</code></p>
<p>It&#8217;s a little shy on giving you feedback but once it completes you&#8217;ll find table1.yml and table2.yml in the test/fixtures directory with all of the data from your tables in it. They also have other options to <a href="http://dev.toolbocks.com/repository/file/plugins/export_fixtures/README">export data from another database such as production or export data selectively based on a query</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gabrito.com/post/creating-database-test-fixtures-and-the-rails-export-fixtures-plugin/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
