<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Eric Hauser's Blog</title>
	
	<link>http://erichauser.net</link>
	<description>J2EE, .NET, and general technology</description>
	<lastBuildDate>Fri, 30 Oct 2009 01:36:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/EricHausersBlog" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Grails Tip: Colored output</title>
		<link>http://feedproxy.google.com/~r/EricHausersBlog/~3/1YVxl0B1zko/</link>
		<comments>http://erichauser.net/2009/10/29/grails-tip-colored-output/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 01:31:02 +0000</pubDate>
		<dc:creator>ehauser</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[J2EE]]></category>

		<guid isPermaLink="false">http://erichauser.net/2009/10/29/grails-tip-colored-output/</guid>
		<description><![CDATA[I really enjoy coding in Grails.  When working with dynamic languages, there is always a bit more uncertainty to what the type of particular variable is – especially when calling code that someone else has written.  Now, you can always just fire up the debugger to find out but often times it is overkill.  Groovy [...]]]></description>
			<content:encoded><![CDATA[<p>I really enjoy coding in Grails.  When working with dynamic languages, there is always a bit more uncertainty to what the type of particular variable is – especially when calling code that someone else has written.  Now, you can always just fire up the debugger to find out but often times it is overkill.  Groovy has great support for finding out all about your object using dump(), inspect(), and toString() usually returns something useful from a GDK class.  Usually a quick println is just the right thing for me to figure out what is going on, and then I remove the statement.</p>
<p>The problem with a quick println is that it is often difficult to quickly differentiate your log lines from that of Grails or Hibernate.  Of course you can turn those log levels off, but always like to see the SQL Hibernate is generating during development.  In order to make my logging stand out, I have started adding this to BootStrap.groovy:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> def init = { servletContext -&gt;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060">   2:</span>     ...</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060">   3:</span>     Object.metaClass.printlnRed = { s -&gt;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum4" style="color: #606060">   4:</span>         def ansi = <span style="color: #0000ff">new</span> Ansi(Ansi.Attribute.BRIGHT, Ansi.Color.RED, Ansi.Color.BLACK);</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum5" style="color: #606060">   5:</span>         ansi.outln(s);</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum6" style="color: #606060">   6:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum7" style="color: #606060">   7:</span>     ...</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum8" style="color: #606060">   8:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>This will allow me to call “printlnRed ‘Some String’ from any Groovy object in my Grails application.  The Ansi class comes from the LGPL licensed <a href="http://code.google.com/p/jlibs/">jibs</a> library.  Of course you will want to find out what colors work the best for you.  Don’t forget to remove your println’s – you don’t want to clutter up your code for others.  If it is something worth keeping in the application, use Log4J instead.  You can still get colors by configuring your appenders to use Ansi colors as well – there are numerous examples of how to do this including one in Ant.  FYI, I doubt this works in Windows.</p>
]]></content:encoded>
			<wfw:commentRss>http://erichauser.net/2009/10/29/grails-tip-colored-output/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://erichauser.net/2009/10/29/grails-tip-colored-output/</feedburner:origLink></item>
		<item>
		<title>ant2maven: Easy migration from Ant to Maven with Nexus</title>
		<link>http://feedproxy.google.com/~r/EricHausersBlog/~3/3mtfaIjGL4s/</link>
		<comments>http://erichauser.net/2009/10/26/ant2maven-easy-migration-from-ant-to-maven-with-nexus/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 01:00:22 +0000</pubDate>
		<dc:creator>ehauser</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://erichauser.net/2009/10/26/ant2maven-easy-migration-from-ant-to-maven-with-nexus/</guid>
		<description><![CDATA[In the scope of a much larger project I am working on, I needed to convert a large number of Ant builds to Maven.  Having done this in the past, I know that it is certainly a tedious process – particularly regarding depending resolution.  So, I decided to make an attempt at scripting that process [...]]]></description>
			<content:encoded><![CDATA[<p>In the scope of a much larger project I am working on, I needed to convert a large number of Ant builds to Maven.  Having done this in the past, I know that it is certainly a tedious process – particularly regarding depending resolution.  So, I decided to make an attempt at scripting that process and ant2maven was born:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> usage: groovy ant2maven.groovy</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060">   2:</span>  -?,--help                 Prints help</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060">   3:</span>  -a,--antfile <span style="color: #0000ff">&lt;</span><span style="color: #800000">a</span><span style="color: #0000ff">&gt;</span>          The ant build file, defaults to build.xml</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum4" style="color: #606060">   4:</span>  -aid,--artifactId <span style="color: #0000ff">&lt;</span><span style="color: #800000">aid</span><span style="color: #0000ff">&gt;</span>   The artifactId of the new project, defaults to</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum5" style="color: #606060">   5:</span>                            current directory</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum6" style="color: #606060">   6:</span>  -g,--groovy               Enable groovy support</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum7" style="color: #606060">   7:</span>  -gid,--groupId <span style="color: #0000ff">&lt;</span><span style="color: #800000">gid</span><span style="color: #0000ff">&gt;</span>      The groupId of the new project</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum8" style="color: #606060">   8:</span>  -n,--name <span style="color: #0000ff">&lt;</span><span style="color: #800000">n</span><span style="color: #0000ff">&gt;</span>             The name of the new project, defaults to</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum9" style="color: #606060">   9:</span>                            current directory</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum10" style="color: #606060">  10:</span>  -o,--output <span style="color: #0000ff">&lt;</span><span style="color: #800000">o</span><span style="color: #0000ff">&gt;</span>           Name of the POM file, defaults to pom.xml</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum11" style="color: #606060">  11:</span>  -p,--paths <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span>            The ant paths to parse</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum12" style="color: #606060">  12:</span>  -t,--testpaths <span style="color: #0000ff">&lt;</span><span style="color: #800000">t</span><span style="color: #0000ff">&gt;</span>        The ant paths to parse for the test scope</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum13" style="color: #606060">  13:</span>  -u,--nexusurl <span style="color: #0000ff">&lt;</span><span style="color: #800000">u</span><span style="color: #0000ff">&gt;</span>         Base URL for Nexus repository to search against</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum14" style="color: #606060">  14:</span>  -v,--version <span style="color: #0000ff">&lt;</span><span style="color: #800000">v</span><span style="color: #0000ff">&gt;</span>          The version of the new project, defaults to</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum15" style="color: #606060">  15:</span>                            1.0-SNAPSHOT</pre>
<p><!--CRLF--></div>
</div>
<p>The script requires at least two parameters, the groupId you want for your generated POM and the name of the Ant path that you want to convert to Maven dependencies.  An Ant path normally looks something like this:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">path</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">="build.classpath"</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060">   2:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">fileset</span> <span style="color: #ff0000">dir</span><span style="color: #0000ff">="./lib/"</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060">   3:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">include</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="xbean-spring-3.4.jar"</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum4" style="color: #606060">   4:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">include</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="camel-*-2.0.0.jar"</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum5" style="color: #606060">   5:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">include</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="spring-*.jar"</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum6" style="color: #606060">   6:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">include</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="jetty-*.jar"</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum7" style="color: #606060">   7:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">include</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="mysql-connector*.jar"</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum8" style="color: #606060">   8:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">include</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="log4j*.jar"</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum9" style="color: #606060">   9:</span>   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">fileset</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum10" style="color: #606060">  10:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">path</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>There are a number of ways that you can define your paths in Ant, and you may not even have an Ant path defined, i.e. you have directly define your path under a &lt;javac /&gt; task.  In those cases, you can just create a path and copy your elements for the script to work.</p>
<p>Once the script finds your dependencies, it searches the public <a href="http://repository.sonatype.org/">Nexus repository</a> using the <a href="https://docs.sonatype.com/display/Nx/Nexus+Rest+API">REST API</a> to find all of your dependencies. The script also attempts to reduce your POM bloat by not listing repeating transitive dependencies as dependencies in your pom.  If the script cannot find a particular dependency, it will go ahead and list it commented out in your POM so that you can resolve it.  Since the public Nexus repository does not have all Maven repositories that you are probably using (Java.net, JBoss, etc), I would recommend setting up your own Nexus instance to achieve the best results.  You can also upload any of your corporate dependencies to your Nexus repository so that they can be resolved by the script as well.</p>
<p>I hacked this together quickly over a few hours this weekend, so there are lots of room for improvements:</p>
<ul>
<li>Better error handling when things go wrong</li>
<li>Automatically install missing artifacts to your own Nexus repository</li>
<li>Suggest dependencies by name when the checksum search fails</li>
<li>Add excludes when two artifacts have conflicting version of transitive dependencies</li>
</ul>
<p>One thing to note is that when you start the script for the first time, it may appear unresponsive.  That is because Groovy is downloading the necessary <a href="http://groovy.codehaus.org/Grape">Grapes</a> for the script – so be patient on the first run.</p>
<p>I have made the script available at <a href="http://github.com/ewhauser/ant2maven">GitHub</a>, so feel free to fork for improvements.</p>
]]></content:encoded>
			<wfw:commentRss>http://erichauser.net/2009/10/26/ant2maven-easy-migration-from-ant-to-maven-with-nexus/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://erichauser.net/2009/10/26/ant2maven-easy-migration-from-ant-to-maven-with-nexus/</feedburner:origLink></item>
		<item>
		<title>XML Declaration with Groovy markup builders</title>
		<link>http://feedproxy.google.com/~r/EricHausersBlog/~3/ERXsQHvOCgw/</link>
		<comments>http://erichauser.net/2009/10/18/xml-declaration-with-groovy-markup-builders/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 21:14:16 +0000</pubDate>
		<dc:creator>ehauser</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://erichauser.net/2009/10/18/xml-declaration-with-groovy-markup-builders/</guid>
		<description><![CDATA[Groovy builders are great for consuming and creating formats like JSON and XML.&#160; However, I could not easily find an example how to write out an XML document with the XML declaration using the MarkupBuilder.&#160; To do this, you need to use the StreaingMarkupBuilder instead.&#160; Here’s an example that returns the last 10 transactions as [...]]]></description>
			<content:encoded><![CDATA[<p>Groovy builders are great for consuming and creating formats like JSON and XML.&#160; However, I could not easily find an example how to write out an XML document with the XML declaration using the MarkupBuilder.&#160; To do this, you need to use the StreaingMarkupBuilder instead.&#160; Here’s an example that returns the last 10 transactions as XML from a Grails controller:</p>
<div id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> def index = {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>     def xml = <span style="color: #0000ff">new</span> groovy.xml.StreamingMarkupBuilder()</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     xml.encoding = <span style="color: #006080">&quot;UTF-8&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     render xml.bind {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>         mkp.xmlDeclaration()</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>         Transactions {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>             Transaction.findAllByDate(<span style="color: #0000ff">new</span> Date(), [max: 10, sort: <span style="color: #006080">&quot;date&quot;</span>, order: <span style="color: #006080">&quot;desc&quot;</span>).each {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>                 Transaction {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>                     ID(it.id)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>                     Date(it.date)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>                     Total(it.total)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>                 } </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>             }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>         }    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span>     }.toString()</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>&#160;</p>
<p>With this, you will get a nice well formed XML document:</p>
<div id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;?</span><span style="color: #800000">xml</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">=&quot;1.0&quot;</span>?<span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">Transactions</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">Transaction</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">ID</span><span style="color: #0000ff">&gt;</span>193710<span style="color: #0000ff">&lt;/</span><span style="color: #800000">TD</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">Date</span><span style="color: #0000ff">&gt;</span>2009-10-18 17:09:24<span style="color: #0000ff">&lt;/</span><span style="color: #800000">Date</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">Total</span><span style="color: #0000ff">&gt;</span>123.12<span style="color: #0000ff">&lt;/</span><span style="color: #800000">Total</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Transaction</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>     ...</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Transactions</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://erichauser.net/2009/10/18/xml-declaration-with-groovy-markup-builders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://erichauser.net/2009/10/18/xml-declaration-with-groovy-markup-builders/</feedburner:origLink></item>
		<item>
		<title>Groovy and Camel for Monitoring ActiveMQ</title>
		<link>http://feedproxy.google.com/~r/EricHausersBlog/~3/f7AXZlGiGiM/</link>
		<comments>http://erichauser.net/2009/08/27/groovy-and-camel-for-monitoring-activemq/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 01:27:04 +0000</pubDate>
		<dc:creator>ehauser</dc:creator>
				<category><![CDATA[Camel]]></category>
		<category><![CDATA[J2EE]]></category>

		<guid isPermaLink="false">http://erichauser.net/2009/08/27/groovy-and-camel-for-monitoring-activemq/</guid>
		<description><![CDATA[ I often have the need communicate with backend systems for simple tasks, but do not want to end up going to all of the trouble of creating an application.&#160; For database, I used to just use Perl and DBI for simple tasks, but even setting up DBI can be some work depending on your [...]]]></description>
			<content:encoded><![CDATA[<p> I often have the need communicate with backend systems for simple tasks, but do not want to end up going to all of the trouble of creating an application.&#160; For database, I used to just use Perl and DBI for simple tasks, but even setting up DBI can be some work depending on your database server.&#160; What I really like is being able to quickly write a script in a single file and run it with no setup necessary &#8212; that is what makes Groovy and Camel with <a href="http://groovy.codehaus.org/Grape">Grape</a> such a great combination.</p>
<p>Let’s look at a simple script for monitoring ActiveMQ advisory messages:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum1" style="color: #606060">   1:</span> <span style="color: #0000ff">import</span> org.apache.camel.*;</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum2" style="color: #606060">   2:</span> <span style="color: #0000ff">import</span> org.apache.camel.impl.*</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum3" style="color: #606060">   3:</span> <span style="color: #0000ff">import</span> org.apache.camel.language.groovy.*</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum4" style="color: #606060">   4:</span> <span style="color: #0000ff">import</span> org.apache.camel.component.activemq.*</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum5" style="color: #606060">   5:</span> <span style="color: #0000ff">import</span> org.apache.activemq.camel.component.*</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum6" style="color: #606060">   6:</span> <span style="color: #0000ff">import</span> org.apache.log4j.*</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum7" style="color: #606060">   7:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum8" style="color: #606060">   8:</span> @Grab(group=<span style="color: #006080">'org.apache.camel'</span>, module=<span style="color: #006080">'camel-groovy'</span>, version=<span style="color: #006080">'2.0-M2'</span>)</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum9" style="color: #606060">   9:</span> @Grab(group=<span style="color: #006080">'org.apache.camel'</span>, module=<span style="color: #006080">'camel-jms'</span>, version=<span style="color: #006080">'2.0-M2'</span>)</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum10" style="color: #606060">  10:</span> @Grab(group=<span style="color: #006080">'org.apache.camel'</span>, module=<span style="color: #006080">'camel-core'</span>, version=<span style="color: #006080">'2.0-M2'</span>)</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum11" style="color: #606060">  11:</span> @Grab(group=<span style="color: #006080">'org.apache.activemq'</span>, module=<span style="color: #006080">'activemq-all'</span>, version=<span style="color: #006080">'5.2.0'</span>)</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum12" style="color: #606060">  12:</span> @Grab(group=<span style="color: #006080">'org.apache.activemq'</span>, module=<span style="color: #006080">'activemq-camel'</span>, version=<span style="color: #006080">'5.2.0'</span>)</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum13" style="color: #606060">  13:</span> <span style="color: #0000ff">class</span> Routes <span style="color: #0000ff">extends</span> GroovyRouteBuilder {</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum14" style="color: #606060">  14:</span>   <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> configure(){</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum15" style="color: #606060">  15:</span>         def log = { exchange -&gt; <span style="color: #0000ff">if</span> (exchange) println exchange } as Processor;</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum16" style="color: #606060">  16:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum17" style="color: #606060">  17:</span>         from(<span style="color: #006080">&quot;activemq:queue:ActiveMQ.Advisory.&gt;&quot;</span>).</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum18" style="color: #606060">  18:</span>           process(log);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum19" style="color: #606060">  19:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum20" style="color: #606060">  20:</span> }</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum21" style="color: #606060">  21:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum22" style="color: #606060">  22:</span> def camelCtx = <span style="color: #0000ff">new</span> DefaultCamelContext()</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum23" style="color: #606060">  23:</span> camelCtx.addComponent(<span style="color: #006080">&quot;activemq&quot;</span>, ActiveMQComponent.activeMQComponent(<span style="color: #006080">&quot;tcp://127.0.0.1:61616&quot;</span>))</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum24" style="color: #606060">  24:</span> camelCtx.addRoutes(<span style="color: #0000ff">new</span> Routes())</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum25" style="color: #606060">  25:</span> camelCtx.start()</pre>
<p><!--CRLF--></div>
</div>
<div>&#160;</div>
<p>All you have to do is save this to a file and run “groovy Script.groovy” – no uploading JAR files or classpath setup required thanks to Grape.&#160; You can see in the script how simple it is to define a Camel processor using Groovy coercion.&#160; With a few modifications, I also use this script as a base for draining dead letter queues, moving message from one queue to another, etc.</p>
<p>Of course, just printing out <a href="http://activemq.apache.org/advisory-message.html">advisory messages</a> is not all that useful.&#160; Say you want to get notified by email when there is a slow consumer.&#160; Just add dependencies for the necessary mail JARs and and change your route:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum1" style="color: #606060">   1:</span> from(<span style="color: #006080">&quot;activemq:queue:ActiveMQ.Advisory.SlowConsumer.*&quot;</span>).</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum2" style="color: #606060">   2:</span>   mail(<span style="color: #006080">&quot;smtp://monitor-list@mycompany.mailserver&quot;</span>)</pre>
<p><!--CRLF--></div>
</div>
<p>With all of the different Camel <a href="http://camel.apache.org/component.html">components</a>, there are a lot of things you can do with the information – send an IM, log to a database, or write to a file.</p>
]]></content:encoded>
			<wfw:commentRss>http://erichauser.net/2009/08/27/groovy-and-camel-for-monitoring-activemq/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://erichauser.net/2009/08/27/groovy-and-camel-for-monitoring-activemq/</feedburner:origLink></item>
		<item>
		<title>NHibernate Profiler now supports Hibernate</title>
		<link>http://feedproxy.google.com/~r/EricHausersBlog/~3/cAWSb1TqtAM/</link>
		<comments>http://erichauser.net/2009/05/18/nhibernate-profiler-now-supports-hibernate/#comments</comments>
		<pubDate>Tue, 19 May 2009 03:28:59 +0000</pubDate>
		<dc:creator>ehauser</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[J2EE]]></category>

		<guid isPermaLink="false">http://erichauser.net/2009/05/18/nhibernate-profiler-now-supports-hibernate/</guid>
		<description><![CDATA[I have had the privilege of doing some work for Ayende for the past month to add support for Hibernate to his excellent NHibernate Profiler.&#160; What does this mean exactly?&#160; Well, Hibernate is now supported as a first class citizen in the profiler.&#160; We have tried to make sure that there is a 1:1 feature [...]]]></description>
			<content:encoded><![CDATA[<p>I have had the privilege of doing some work for <a href="http://ayende.com/blog/">Ayende</a> for the past month to add support for Hibernate to his excellent <a href="http://nhprof.com/">NHibernate Profiler</a>.&#160; What does this mean exactly?&#160; Well, Hibernate is now supported as a first class citizen in the profiler.&#160; We have tried to make sure that there is a 1:1 feature mapping between the NHibernate and Hibernate support.&#160; I am happy to report that all applicable warnings and information that you receive for NHibernate is also displayed for Hibernate.&#160; There are of course differences between NHibernate and Hibernate &#8212; such as Hibernate does not support statement level batching options, multiquery, or future queries – which is reflected in the documentation.</p>
<p>Since many developers use Hiberante with Spring, we have tried to make Spring integration as seamless as possible.&#160; If you are using&#160; Hibernate with Spring, configuring your application to be profiled is as simple adding a JAR and a custom attribute to your Spring configuration.&#160; Here you can see where I have added support for profiling to an Appfuse demo project:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum1" style="color: #606060">   1:</span> <span style="color: #008000">&lt;!-- Hibernate SessionFactory --&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum2" style="color: #606060">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">bean</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;sessionFactory&quot;</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&quot;org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum3" style="color: #606060">   3:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">property</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;dataSource&quot;</span> <span style="color: #ff0000">ref</span><span style="color: #0000ff">=&quot;dataSource&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum4" style="color: #606060">   4:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">property</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;configLocation&quot;</span> <span style="color: #ff0000">value</span><span style="color: #0000ff">=&quot;classpath:hibernate.cfg.xml&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum5" style="color: #606060">   5:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">property</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;hibernateProperties&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum6" style="color: #606060">   6:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">value</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum7" style="color: #606060">   7:</span>             hibernate.dialect=${hibernate.dialect}</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum8" style="color: #606060">   8:</span>             hibernate.query.substitutions=true 'Y', false 'N'</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum9" style="color: #606060">   9:</span>             hibernate.cache.use_second_level_cache=true</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum10" style="color: #606060">  10:</span>             hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum11" style="color: #606060">  11:</span>         <span style="color: #0000ff">&lt;/</span><span style="color: #800000">value</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum12" style="color: #606060">  12:</span>         <span style="color: #008000">&lt;!-- Turn batching off for better error messages under PostgreSQL --&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum13" style="color: #606060">  13:</span>         <span style="color: #008000">&lt;!-- hibernate.jdbc.batch_size=0 --&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum14" style="color: #606060">  14:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">property</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum15" style="color: #606060">  15:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">hprof:profiler</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum16" style="color: #606060">  16:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">bean</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>&#160;</p>
<p>This, of course, is just one of the many different ways that you can <a href="http://www.nhprof.com/Learn/GettingStartedHibernate">configure the profiler</a>.&#160; Here is a screenshot of me profiling an Appfuse application.&#160; The top few sessions are profiling unit tests and the remaining sessions (with the URLs) are profiling the web application:</p>
<p><a href="http://erichauser.net/wp-content/uploads/nhprofappfuse.jpg"><img title="nhprof-appfuse" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="427" alt="nhprof-appfuse" src="http://erichauser.net/wp-content/uploads/nhprofappfuse-thumb.jpg" width="644" border="0" /></a>&#160;</p>
<p>Currently, the product is in closed beta and we are looking for beta testers.&#160; If you are interested, then please contact either Ayende through his blog and he will get you all setup.&#160; Other places you can provide feedback are the <a href="http://groups.google.com/group/nhprof">user group</a> and the <a href="http://nhprof.uservoice.com/">feedback site</a>.&#160; Although I may be a little biased, I think this application can add a lot of value for anyone who is using NHibernate and Hibernate.</p>
]]></content:encoded>
			<wfw:commentRss>http://erichauser.net/2009/05/18/nhibernate-profiler-now-supports-hibernate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://erichauser.net/2009/05/18/nhibernate-profiler-now-supports-hibernate/</feedburner:origLink></item>
		<item>
		<title>Unit tests are production code</title>
		<link>http://feedproxy.google.com/~r/EricHausersBlog/~3/1szF5wz3qJI/</link>
		<comments>http://erichauser.net/2009/05/16/unit-tests-are-production-code/#comments</comments>
		<pubDate>Sat, 16 May 2009 16:21:14 +0000</pubDate>
		<dc:creator>ehauser</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://erichauser.net/2009/05/16/unit-tests-are-production-code/</guid>
		<description><![CDATA[I was recently talking with a coworker who said that they write their unit tests in Groovy because unit tests are not production code so the language does not matter.&#160; Of course, I think Groovy is a fine choice for producation applications, but I am ignoring that point for the purposes of this post.&#160; I [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently talking with a coworker who said that they write their unit tests in Groovy because unit tests are not production code so the language does not matter.&#160; Of course, I think Groovy is a fine choice for producation applications, but I am ignoring that point for the purposes of this post.&#160; I could not disagree with my coworkers comments more.&#160; Unit tests are as important as your code itself.&#160; I do not think that comment needs more explanation than that, only that I find it interesting that many people still see unit tests as a second class citizen in a code base.</p>
<p>The other interesting thing is that the current goal is to get 80% unit tests passing on all projects (the projects that I work on have 100% all the time, otherwise I would lose my mind).&#160; This is a strategy I disagree with.&#160; Let’s say that over time your project has gotten to a state where you only have 50% of the unit tests passing.&#160; As far as I am concerned, this is equivalent to having 0% of the tests passing.&#160; Why?&#160; Because developers see tests in two colors: red and green.&#160; You will quickly find that the 50% will continue to down because no one is actually noticing that they are breaking tests as they are making code changes.&#160; On a few large projects I have worked on, I have seen where a single failing unit test quickly becomes 20.&#160; </p>
<p>Assuming that because of business goals and quantity of tests to fix, that just fixing all of the tests immediately is not an option.&#160; A much better strategy, in my opinion, would be to ignore the tests that are failing and say that all projects must have 100% unit tests passing.&#160; Then, make your goal to be to work your way down from 50% ignored tests to 0% ignored tests over a reasonable period of time.&#160; </p>
]]></content:encoded>
			<wfw:commentRss>http://erichauser.net/2009/05/16/unit-tests-are-production-code/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://erichauser.net/2009/05/16/unit-tests-are-production-code/</feedburner:origLink></item>
		<item>
		<title>Ultimate Developer Rig 2009</title>
		<link>http://feedproxy.google.com/~r/EricHausersBlog/~3/mEjEpuGrtDQ/</link>
		<comments>http://erichauser.net/2009/02/05/ultimate-developer-rig-2009/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 02:58:13 +0000</pubDate>
		<dc:creator>ehauser</dc:creator>
				<category><![CDATA[Hardware]]></category>

		<guid isPermaLink="false">http://erichauser.net/2009/02/05/ultimate-developer-rig-2009/</guid>
		<description><![CDATA[&#160;
My company has decided to close its facility here in Indianapolis, so I am currently job hunting.&#160; Its turns out that suddenly finding a bunch of free time on your hands is bad for the wallet.&#160; It also does not help that a large number of engineers in our office now have very little to [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>My company has decided to close its facility here in Indianapolis, so I am currently job hunting.&#160; Its turns out that suddenly finding a bunch of free time on your hands is bad for the wallet.&#160; It also does not help that a large number of engineers in our office now have very little to do for the next 60 days but talk about things like computer hardware (in between interviews of course).&#160; My machine at home is close to being three years old, so I have decided that it is fully depreciated.&#160; Inspired by the likes of <a href="http://www.hanselman.com/blog/TheCodingHorrorUltimateDeveloperRigThrowdownPart2.aspx">Scott Hanselmann</a> and <a href="http://www.jameskovacs.com/blog/UltimateDeveloperRigKovacsEdition.aspx">James Kovacs</a> I have decided to build my own Ultimate Devloper Rig and write about it.</p>
<h3>The System</h3>
<p>&#160;</p>
<p><strong>Case &#8211; Antec P182</strong></p>
<p>Pretty original choice, huh?&#160; I really wanted to buy the <a href="http://www.techspot.com/review/133-coolermaster-haf-932/">Cooler Master HAF 932</a> after reading the review, but then I went to Fry&#8217;s.&#160; Here is the size comparison between the P182 and the 932:</p>
<p>&#160;<img title="p182_vs_haf392" height="800" alt="p182_vs_haf392" src="http://erichauser.net/wp-content/uploads/p182_vs_haf392.jpg" width="600" /></p>
<p>&#160;</p>
<p>I was a little concerned that the 932 might not fit under my desk so I went with the P182.&#160; My other concern was that the the amount of fans in the Cooler Master would&#160; make the noise level of the case unacceptable, but a coworker of mine has one and he says that it is not that bad.&#160; If you are not overclocking your machine, you probably do not even need to hook all of the fans in that case up.</p>
<p>&#160;<strong>Processor &#8211; Intel Core i7 920 </strong></p>
<p><strong></strong></p>
<p>When I first starting looking, I assumed that I would be going with a Core 2 Quad system.&#160; If you go Core i7, you are going to pay a lot more for the motherboard, processor, and RAM, right?&#160; Turns out that you won’t be paying quite the premium you would have paid 3 months ago.&#160; My office is located right across the street from Fry&#8217;s and they had an great deal on the Core i7 920 &#8211; $229.&#160; NewEgg&#8217;s current price for a i7 920 is $289.99 and an entry level quad core processor, the Q8300, is currently running $189.99.&#160; If you look at the <a href="http://www.techspot.com/review/124-intel-core-i7-920-940-965/">benchmarks </a>for the Core i7 920 vs. say the Core 2 Quad Q9650 (currently $339), the 920 performs significantly better in a lot of benchmarks and slightly better in some others.&#160; Also, the i7 is a quad core processor with hyper threading (2 threads per core) which means that the operating system will think that the processor has 8 cores.</p>
<p>&#160;<strong>Motherboard &#8211; ASUS P6T Deluxe LGA 1366 Intel X58 ATX</strong></p>
<p> The motherboard is definately the place where going with the i7 will hurt you on price.&#160; On average, X58 motherboards are about twice as expensive as their comparable P45 counterparts.&#160; In fact, some of the prices for the Core 2 boards are moving closer to 3 times cheaper.&#160; If you think of your machine as a one time sunk cost, then saving $150-$200 on a motherboard is fairly significant.&#160; However, if you are planning on upgraded your processor and RAM a couple of years down the road, you definately do not want to be stuck with a motherboard that only supports Core 2 processors and DDR2 RAM.</p>
<p> After reading some reviews on the current choices for i7 motherboards, I decided to go with the ASUS board.&#160; The board has features such as dual Gigabit LAN, power on bios, 8 SATA ports, 6 DIMM slots, and 3 PCI express slots.&#160; This board supports both Crossfire and SLI &#8212; so you have flexibility in which video card manufacturer you go with.&#160; My choice really came down between this board and the Gigabyte GA-EX58-UD4P.&#160; You could probably save yourself an extra $50-$75 bucks by going with this board or the cheaper ASUS if you don&#8217;t want all the bells and whistles of the P6T Deluxe.</p>
<p>&#160;<strong>Power Supply &#8211; CORSAIR 650TX 650W</strong></p>
<p> After picking my motherboard, I moved on to the power supply.&#160; It is important to make sure that your PSU is certified for both SLI and Crossfire, and this one is.&#160; It has connectors for eight SATA drives.&#160; NewEgg had a really good deal on this particular PSU after instant and mail-in rebates ($79), and I could not find anyone with anything bad to say about it when searching.&#160; </p>
<p>&#160;<strong>RAM &#8211; G.SKILL 6GB (3xGB) DDR3 1333 Triple Channel Memory</strong></p>
<p> Since there are so many different options for RAM, I decided to use the poll the audience approach for choosing.&#160; I searched for &quot;DDR3 1333 triple channel 6GB&quot; on NewEgg and looked at the results.&#160; There about 10 options, all within $20-$30 of each other.&#160; I decided to go with the G.SKILL because it was inexpensive, had the most reviews, and had a 84% excellent rating.</p>
<p>&#160;<strong>Boot Drive &#8211; Western Digital VelociRaptor WD3000HLFS 3000 GB 10,000 RPM</strong></p>
<p> This is the item that I thought about the most.&#160; It is probably going to be a few months before there is some good data on reliability and performance for SSDs.&#160; I was actually reading a <a href="http://www.anandtech.com/guides/showdoc.aspx?i=3510">i7 builder&#8217;s guide</a> on AnandTech this morning (which incidentally came out after I made my purchases) and it says that they are working on reviewing the latest cheaper SSD drives.&#160; You can get a 64GB GSKILL SSD for $139 or a 128GB for $234.&#160; Even a 64 GB drive would give you plenty of room as a boot drive.&#160; The Intel X25-M SSDs currently boost much higher read times than the cheaper SSDs and they are significantly more expensive, 80 GB for $339, than the cheaper models.&#160; So, I decided to go with the tried and true VelociRaptor &#8230; for now.</p>
<p>&#160;<strong>Storage Drive &#8211; Samsung Spinpoint F1 HD103UJ 1TB 7200 RPM</strong></p>
<p> Again, I spent some time thinking about what to do for storage and I considered setting up a RAID array for data drives.&#160; However, I did not want to put a huge investment into storage in case we see SSD drives that significantly outperform HDD (and are affordable) in the near future, in which case my VelociRaptor would be fine for holding my data.</p>
<p> I do image backups of all of my drives, so data loss is not a real concern for me.&#160;&#160; 7200 RPM drives are a dime a dozen, so brand does not really matter that much here.</p>
<p>&#160;<strong>Video Card &#8211; EVGA 512-P3-N975-AR GeForce 9800GT 512 MB</strong>&#160;</p>
<p>This is one area where you will probably want to do differently than what I did.&#160; I am not really into playing games on my computer so I do not really care about the video card that much.&#160; The previous generation video card will do just fine for Visual Studio so I am skimping on this item to save about $100.&#160; In reality, I could probably go with a cheaper card that works just as good, but I couldn&#8217;t bring myself to buy the cheapest cards available.&#160; </p>
<p>For anyone who plays games, I would recommend the MSI R4870-T2D1G Radeon HD 4870 1GB per the AnandTech guide.&#160; For about a hundred dollars more than my card, you get a card with a 1GB of RAM that is based on the newer chipset from ATI.&#160; With most 4870 X2 boards costing about double what that card will cost you, that card is definately a better buy.&#160; One video card will do fine for me since it has dual DVI for my two Dell 2407WFP (24&quot; widescreen) monitors.</p>
<p><strong>CPU Cooler – Stock</strong></p>
<p> Really?&#160; No after market cooler you say?&#160; I am not planning on overclocking the system so I don&#8217;t see a need for the after market cooler.&#160; I am planning on doing some testing when I get the system setup, so I will let you know what the temperatures are like.&#160; Using this same thought process, I am going to go with the stock case fans and see what happen as well.&#160; Maybe I will be wrong and find out that the temperatures are unacceptable; and I&#8217;ll have to get a shiny aftermarket cooler and some new case fans.&#160; But nobody ever really discusses what happens with the stock gear, so I think it will be an interesting experiment.</p>
<h3>Totals</h3>
<p>&#160;</p>
<table cellspacing="0" cellpadding="2" width="764" border="1">
<tbody>
<tr>
<td valign="top" width="127">
<p><strong>Component</strong></p>
</td>
<td valign="top" width="527">
<p><strong>Item</strong></p>
</td>
<td valign="top" width="108">
<p><strong>Price</strong></p>
</td>
</tr>
<tr>
<td valign="top" width="127">
<p>Case</p>
</td>
<td valign="top" width="527">
<p><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16811129025">Antec P182 Gun Metal Black 0.8mm cold rolled steel ATX Mid Tower Computer Case &#8211; Retail</a></p>
</td>
<td valign="top" width="151">
<p>$129.99</p>
</td>
</tr>
<tr>
<td valign="top" width="127">
<p>CPU</p>
</td>
<td valign="top" width="527">
<p><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16819115202">Intel Core i7 920 Nehalem 2.66GHz 4 x 256KB L2 Cache 8MB L3 Cache LGA 1366 130W Quad-Core Processor &#8211; Retail</a></p>
</td>
<td valign="top" width="151">
<p>$229.99</p>
</td>
</tr>
<tr>
<td valign="top" width="127">
<p>Motherboard</p>
</td>
<td valign="top" width="527">
<p><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16813131346">ASUS P6T Deluxe LGA 1366 Intel X58 ATX Intel Motherboard &#8211; Retail</a></p>
</td>
<td valign="top" width="151">
<p>$299.99</p>
</td>
</tr>
<tr>
<td valign="top" width="127">
<p>RAM</p>
</td>
<td valign="top" width="527">
<p><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16820231230">G.SKILL 6GB (3 x 2GB) 240-Pin DDR3 SDRAM DDR3 1333 (PC3 10666) Triple Channel Kit Desktop Memory &#8211; Retail</a></p>
</td>
<td valign="top" width="151">
<p>$139.99</p>
</td>
</tr>
<tr>
<td valign="top" width="127">
<p>Video Card</p>
</td>
<td valign="top" width="527">
<p><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16814130380">EVGA 512-P3-N975-AR GeForce 9800 GT 512MB 256-bit GDDR3 PCI Express 2.0 x16 HDCP Ready SLI Supported Video Card &#8211; Retail</a></p>
</td>
<td valign="top" width="151">
<p>$129.99</p>
</td>
</tr>
<tr>
<td valign="top" width="127">
<p>PSU</p>
</td>
<td valign="top" width="527">
<p><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16817139005">CORSAIR CMPSU-650TX 650W ATX12V / EPS12V SLI Ready CrossFire Ready 80 PLUS Certified Active PFC Compatible with Core i7 Power Supply &#8211; Retail</a></p>
</td>
<td valign="top" width="151">
<p>$94.99</p>
</td>
</tr>
<tr>
<td valign="top" width="127">
<p>Boot drive</p>
</td>
<td valign="top" width="527">
<p><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16822136322">Western Digital VelociRaptor WD3000HLFS 300GB 10000 RPM 16MB Cache SATA 3.0GB/s Hard Drive &#8211; OEM</a></p>
</td>
<td valign="top" width="151">
<p>$229.99</p>
</td>
</tr>
<tr>
<td valign="top" width="127">
<p>Secondary drive</p>
</td>
<td valign="top" width="527">
<p><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16822152102">SAMSUNG Spinpoint F1 HD103UJ 1TB 7200 RPM 32MB Cache SATA 3.0Gb/s Hard Drive &#8211; OEM</a><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16822152102"></a></p>
</td>
<td valign="top" width="151">
<p>$99.99</p>
</td>
</tr>
<tr>
<td valign="top" width="127">
<p>DVD Drive</p>
</td>
<td valign="top" width="527">
<p><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16827106228">LITE-ON Black 20X DVD+R 8X DVD+RW 8X DVD+R DL 20X DVD-R 6X DVD-RW 12X DVD-RAM 16X DVD-ROM 48X CD-R 32X CD-RW 48X CD-ROM 2MB Cache IDE 20X DVD±R DVD Burner &#8211; OEM</a></p>
<h4></h4>
<dl>
<dd></dd>
</dl>
<dl></dl>
</td>
<td valign="top" width="151">
<p>$21.99</p>
</td>
</tr>
<tr>
<td valign="top" width="527" colspan="2">
<p style="text-align: right">Subtotal:</p>
</td>
<td valign="top" width="151">
<p>$1376.91</p>
</td>
</tr>
<tr>
<td valign="top" width="527" colspan="2">
<p style="text-align: right">Mail-in Rebates:</p>
</td>
<td valign="top" width="151">
<p>$65.00</p>
</td>
</tr>
<tr>
<td valign="top" width="527" colspan="2">
<p style="text-align: right">Total:</p>
</td>
<td valign="top" width="151">
<p>$1311.91</p>
</td>
</tr>
</tbody>
</table>
<p>About $1300 for the system is not a bad price at all.&#160; You could probably get a very similar system for around $1000 if you go with a Core 2 Quad system.</p>
<h3>Benchmarks</h3>
<p>&#160;</p>
<p>Assuming I get all the components in the mail, get the system built, and everything works properly; I will post some benchmarks next week.&#160; I will probably get some stats on how long it takes to build and run the unit tests for Castle, but I would also like to find a big project that uses MSBuild so that I can test some times using its parallel build support (NAnt does not support this).&#160; If there are any suggestions on some other pointless benchmarks, let me know. =)</p>
]]></content:encoded>
			<wfw:commentRss>http://erichauser.net/2009/02/05/ultimate-developer-rig-2009/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://erichauser.net/2009/02/05/ultimate-developer-rig-2009/</feedburner:origLink></item>
		<item>
		<title>Javascript compression for Monorail</title>
		<link>http://feedproxy.google.com/~r/EricHausersBlog/~3/9QpvG7I1enw/</link>
		<comments>http://erichauser.net/2009/01/27/javascript-compression-for-monorail/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 20:56:43 +0000</pubDate>
		<dc:creator>ehauser</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Castle]]></category>

		<guid isPermaLink="false">http://erichauser.net/2009/01/27/javascript-compression-for-monorail/</guid>
		<description><![CDATA[Last year, Hammett posted a blog entry on combining Javascript files into a single file using Monorail.  I was looking to enhance the code so that it would minify Javascript and CSS files on the fly, so I took his original code and enhanced it.  Alex Henderson was also looking for the same functionality, so [...]]]></description>
			<content:encoded><![CDATA[<p>Last year, Hammett posted a <a href="http://hammett.castleproject.org/?p=310">blog entry</a> on combining Javascript files into a single file using Monorail.  I was looking to enhance the code so that it would minify Javascript and CSS files on the fly, so I took his original code and enhanced it.  <a href="http://blog.bittercoder.com/">Alex Henderson</a> was also looking for the same functionality, so he contributed to the patch as well.  You can download it here:  <a href="http://support.castleproject.org/projects/MR/issues/view/MR-ISSUE-457">http://support.castleproject.org/projects/MR/issues/view/MR-ISSUE-457</a></p>
<p>The new component uses a <a href="http://www.codeplex.com/YUICompressor/">.NET port of the Yahoo! UI Library Compressor that is available on Codeplex</a>.  The component worked great, but they did not have a strongly signed version of the library release.  I made a request and they quickly turned out a release that same day, which was awesome response time.</p>
<p>You can now have all of your Javascript and CSS combined for you on the fly by using the component:</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   1:</span> #blockcomponent(BuildJS with <span style="color: #006080">"key=layout"</span>)</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   2:</span>     $jsBuilder.Add(<span style="color: #006080">"Content/css/main.css"</span>)</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   3:</span>     $jsBuilder.Add(<span style="color: #006080">"Content/css/someOther.css"</span>)</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   4:</span>     $jsBuilder.Add(<span style="color: #006080">"Content/js/prototype.js"</span>)</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   5:</span>     $jsBuilder.Add(<span style="color: #006080">"Content/js/someOther.js"</span>)</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   6:</span> #end</pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://erichauser.net/2009/01/27/javascript-compression-for-monorail/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://erichauser.net/2009/01/27/javascript-compression-for-monorail/</feedburner:origLink></item>
		<item>
		<title>Automatic assembly versioning with TeamCity</title>
		<link>http://feedproxy.google.com/~r/EricHausersBlog/~3/gQc7w8cXKOE/</link>
		<comments>http://erichauser.net/2009/01/27/automatic-build-numbers-with-teamcity/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 20:56:28 +0000</pubDate>
		<dc:creator>ehauser</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[TeamCity]]></category>

		<guid isPermaLink="false">http://erichauser.net/2009/01/27/automatic-build-numbers-with-teamcity/</guid>
		<description><![CDATA[Although there are a number of good continuous integration servers out there, TeamCity is one of my favorites.  It has great support for .NET &#8212; supporting MSBuild, NAnt, Solution builds, NUnit, MSTest, and FxCop.  The price is right if you have less than 20 users and 20 build configurations – free.  I was also able [...]]]></description>
			<content:encoded><![CDATA[<p>Although there are a number of good continuous integration servers out there, TeamCity is one of my favorites.  It has great support for .NET &#8212; supporting MSBuild, NAnt, Solution builds, NUnit, MSTest, and FxCop.  The price is right if you have less than 20 users and 20 build configurations – free.  I was also able to a plugin to integrate with our issue tracking systems in a couple of hours timespan (my Spring MVC experience definately helped though).</p>
<p>One of thing that you want to do with a release build is automatically increment your version numbers.  Most approaches to this problem recommend using MSBuild to autogenerate the AssemblyInfo.cs file.  Although that certainly works, I prefer not to have to do that for every project.  Instead, each of our projects references a single CommonAssemblyInfo.cs file.</p>
<p>When TeamCity builds a release build, it is configured to the IncrementVersion task:</p>
<div>
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">Project</span> <span style="color: #ff0000">xmlns</span><span style="color: #0000ff">="http://schemas.microsoft.com/developer/msbuild/2003"</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   2:</span>     ...</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   3:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">Target</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">="UnrestrictedExecutionPolicy"</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   4:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">Exec</span> <span style="color: #ff0000">Command</span><span style="color: #0000ff">="powershell set-executionPolicy unrestricted&amp;quot;"</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   5:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Target</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   6:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">Target</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">="IncrementVersion"</span> <span style="color: #ff0000">DependsOnTargets</span><span style="color: #0000ff">="UnrestrictedExecutionPolicy"</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   7:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">Exec</span> <span style="color: #ff0000">Command</span><span style="color: #0000ff">="PowerShell .\incrementVersion.ps1 $(build_vcs_number_1)"</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   8:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Target</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   9:</span>     ...</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  10:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Project</span><span style="color: #0000ff">&gt;</span></pre>
</div>
</div>
<p>The $(build_vcs_number_1) property tells TeamCity to the current revision number from the first source repository attached – in my case SVN &#8212; to the project (most projects will only have one repository attached).  Then, we execute a simple Powershell script to replace the file version number:</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   1:</span> $buildNumber = $args[0]</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   2:</span> (Get-Content ..\src\CommonAssemblyInfo.cs) | Foreach-Object {$_ -replace <span style="color: #006080">"(\d\.\d\.\d)\.\d*"</span>, <span style="color: #006080">"`$1.$buildNumber"</span>} | Set-Content ..\src\CommonAssemblyInfo.cs</pre>
</div>
</div>
<p>If you are more comfortable using a MSBuild task for regex replacement, there is a RegexReplace task that is part of the <a href="http://msbuildtasks.tigris.org/">MSBuild Community Tasks</a>.  For my build, we do not need any other custom tasks, so it was preferable to just use a simple PS script.</p>
]]></content:encoded>
			<wfw:commentRss>http://erichauser.net/2009/01/27/automatic-build-numbers-with-teamcity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://erichauser.net/2009/01/27/automatic-build-numbers-with-teamcity/</feedburner:origLink></item>
		<item>
		<title>ActiveRecord Flush Control</title>
		<link>http://feedproxy.google.com/~r/EricHausersBlog/~3/OR9IoQ9j-ZM/</link>
		<comments>http://erichauser.net/2009/01/27/activerecord-flush-control/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 20:56:18 +0000</pubDate>
		<dc:creator>ehauser</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Active Record]]></category>
		<category><![CDATA[Castle]]></category>
		<category><![CDATA[ActiveRecord]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://erichauser.net/2009/01/27/activerecord-flush-control/</guid>
		<description><![CDATA[There are a lot of times in your application where you will load a lot of entities in a single session (to display a lot of data on a page, build a report, etc).  Since you are not planning on doing a mutable operation on an entity, there is a big saving that you can [...]]]></description>
			<content:encoded><![CDATA[<p>There are a lot of times in your application where you will load a lot of entities in a single session (to display a lot of data on a page, build a report, etc).  Since you are not planning on doing a mutable operation on an entity, there is a big saving that you can get from not flushing the session.  To get an idea on everything that happens when you do a flush, check out the <a href="https://nhibernate.svn.sourceforge.net/svnroot/nhibernate/trunk/nhibernate/src/NHibernate/Event/Default/AbstractFlushingEventListener.cs">AbstractionFlushingEventListener</a> from the NHibernate source.</p>
<p>If you are using explicit SessionScope’s, not flushing the session is trivial:</p>
<div>
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   1:</span> <span style="color: #0000ff">using</span> (<span style="color: #0000ff">new</span> SessionScope(FlushAction.Never))</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   2:</span> {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   3:</span>     repository.DoSomeReadOperation();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   4:</span> }</pre>
</div>
</div>
<p>This will execute the operation without flushing the session at the end.</p>
<p>Another way to control this behavior is by using an interceptor.  For example, if you are using the Castle’s Automated Transaction Facility, you probably already have a way of determining whether or not your methods do mutable operations by their transaction attributes.  You can then use an interceptor to control flushing:</p>
<div>
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> UnitOfWorkInterceptor : IInterceptor</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   2:</span> {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   3:</span>     <span style="color: #0000ff">private</span> <span style="color: #0000ff">readonly</span> ITransactionManager transactionManager;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   4:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   5:</span>     <span style="color: #008000">/// &lt;summary&gt;</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   6:</span>     <span style="color: #008000">/// Initializes a new instance of the &lt;see cref="UnitOfWorkInterceptor"/&gt; class.</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   7:</span>     <span style="color: #008000">/// &lt;/summary&gt;</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">   8:</span>     <span style="color: #008000">/// &lt;param name="transactionManager"&gt;The transaction manager.&lt;/param&gt;</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">   9:</span>     <span style="color: #0000ff">public</span> UnitOfWorkInterceptor(ITransactionManager transactionManager)</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  10:</span>     {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  11:</span>         <span style="color: #0000ff">this</span>.transactionManager = transactionManager;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  12:</span>     }</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  13:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  14:</span>     <span style="color: #cc6633">#region</span> Implementation of IInterceptor</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  15:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  16:</span>     <span style="color: #008000">/// &lt;summary&gt;</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  17:</span>     <span style="color: #008000">/// Intercepts the specified invocation.</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  18:</span>     <span style="color: #008000">/// &lt;/summary&gt;</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  19:</span>     <span style="color: #008000">/// &lt;param name="invocation"&gt;The invocation.&lt;/param&gt;</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  20:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> Intercept(IInvocation invocation)</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  21:</span>     {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  22:</span>         ITransaction transaction = transactionManager.CurrentTransaction;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  23:</span>         FlushAction flushAction = transaction == <span style="color: #0000ff">null</span> ? FlushAction.Never : FlushAction.Config;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  24:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  25:</span>         ActiveRecordUnitOfWork.Before(flushAction);</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  26:</span>         invocation.Proceed();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  27:</span>         ActiveRecordUnitOfWork.After();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  28:</span>     }</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  29:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060">  30:</span>     <span style="color: #cc6633">#endregion</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060">  31:</span> }</pre>
</div>
</div>
<p>Note that in this example, interceptor ordering is important.  If you register the unit of work interceptor before the transaction interceptor in the ATM facility, then transactionManager.CurrentTransaction will always return null.  (The ActiveRecordUnitOfWork class in the above example is just a facade for controlling the session in a thread local as discussed in this post <a href="http://erichauser.net/2008/08/06/activerecord-session-scope-and-wcf-redux/">http://erichauser.net/2008/08/06/activerecord-session-scope-and-wcf-redux/</a>).  If you do not want to tie your flushing to transactions, then you can always create your own metadata and read that metadata at runtime in the interceptor.  The ATM facility code is a great example of how to inspect metadata on initialization and use that metadata in your interceptor.</p>
<p>Hopefully, this little trick will some increased performance for your queries that return a lot of results.</p>
]]></content:encoded>
			<wfw:commentRss>http://erichauser.net/2009/01/27/activerecord-flush-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://erichauser.net/2009/01/27/activerecord-flush-control/</feedburner:origLink></item>
	</channel>
</rss>
