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

<channel>
	<title>Source Allies Blog &#187; Uncategorized</title>
	<atom:link href="http://blogs.sourceallies.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.sourceallies.com</link>
	<description>Technical and process thinking from Source Allies employees</description>
	<lastBuildDate>Fri, 03 Feb 2012 17:45:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Next Step in Agility</title>
		<link>http://blogs.sourceallies.com/2011/10/next-step-in-agility/</link>
		<comments>http://blogs.sourceallies.com/2011/10/next-step-in-agility/#comments</comments>
		<pubDate>Sat, 01 Oct 2011 14:08:32 +0000</pubDate>
		<dc:creator>David Kessler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=2480</guid>
		<description><![CDATA[I often find that teams that have adopted Agile practices quickly plateau.  They often start by scheduling a daily stand up, planning in iterations, take time for a retrospective, and modify their estimation process.  These are common first steps in the agile adoption process.  Teams have varied success and commitments to these [...]]]></description>
			<content:encoded><![CDATA[<p>I often find that teams that have adopted Agile practices quickly plateau.  They often start by scheduling a daily <a href="http://en.wikipedia.org/wiki/Stand-up_meeting">stand up</a>, planning in <a href="http://en.wikipedia.org/wiki/Iterative_and_incremental_development">iterations</a>, take time for a <a href="http://en.wikipedia.org/wiki/Agile_software_development#Software_development_life_cycle">retrospective</a>, and modify their estimation process.  These are common first steps in the agile adoption process.  Teams have varied success and commitments to these practices but nevertheless these are the low hanging fruits in the Agile adoption journey.<br />
<span id="more-2480"></span><br />
Once a team has plateaued, where do they go from there?  After eight years of leading Agile software development teams a consistent thread has emerged.  Teams should work to create an automated continuous deployment process.  I intentionally did not use the work <a href="http://en.wikipedia.org/wiki/Continuous_integration">continuous integration</a>(CI).  This is not to say that what I&#8217;m proposing does not involve continuous integration.  However the word has been misused by numerous teams. Many teams that I work with only use their CI build to run a few unit tests.  While this is an important first step it fails to address the systemic problem within our industry of integrating our products together.</p>
<p>If your team spends more than an afternoon deploying their product to a test region or to production then you need to start chipping away at this next step.  Agile software development emphasizes <a href="http://agilemanifesto.org/">working software</a>.  While this seems like a no-brainer, we often neglect the core issues that prevent our software from working.  The most significant one being that we often do not know our software does not work until it is too late.</p>
<p>The single most powerful change that you can bring to your software development team is continuous deployment.  What does this mean?  I&#8217;m not suggesting that you auto deploy to production.  I have not worked with an organization yet that is ready to make this leap of faith.  Instead I&#8217;m encouraging you to:</p>
<ol>
<li>automate your deployment process and run it every time your check in your code.</li>
<li>run a couple of user tests that walk through the most common end-to-end flows</li>
</ol>
<p>While this may seem fairly straight forward this is difficult to complete.  Much of this depends on your architecture, infrastructure and policies.  To illustrate this point let&#8217;s look at a project that I lead a couple of years ago.  In order to auto deploy our project and run test against our product we needed:</p>
<ol>
<li>to have admin privileges on 5 dedicated database.</li>
<li>to create the database from versioned scripts</li>
<li>to load test data in each database</li>
<li>to have an application server on our CI box.</li>
<li>to have a message queue on our CI box.</li>
<li>to have three web services deployed and running</li>
<li>to have a build process that can automatically build and deploy an EAR to the application server</li>
</ol>
<p>Policies, licensing and time are the largest barrier standing in the way of achieving this in any organization.  This example may be more or less complex than the needs on your project.  Nevertheless, in my experience working to break down these barriers is essential to delivering working software.  Being able to address deployment issues as they come up is much less stressful than standing in a cube after hours trying to figure out why this stupid app won&#8217;t work with managers asking if you are &#8220;done yet&#8221;.  </p>
<p>Policies can be changed if you track the amount of wasted time as it relates to deployment delays.  Licensing costs can be accounted for or avoided (open source) if managers understand the savings. And as far as time goes, I&#8217;m more willing to put some time up front so I don&#8217;t have to loose my nights and weekends at the end of the project.</p>
<p>I know that this is possible.  I have seen it work on numerous projects and team.  Take the next step in Agility and automate your deployment process.  Ensure that your software works by running a few end-to-end user tests.  The effort is worth it.  Your time and sanity is worth it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2011/10/next-step-in-agility/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Learning a new Language</title>
		<link>http://blogs.sourceallies.com/2011/09/learning-a-new-language/</link>
		<comments>http://blogs.sourceallies.com/2011/09/learning-a-new-language/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 16:18:17 +0000</pubDate>
		<dc:creator>David Kessler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=2453</guid>
		<description><![CDATA[I attended a No Fluff Just Stuff Symposium a few weeks ago.  One of the main emphasis during the weekend was learning new languages that are available on the JVM.  While there are a variety of reasons that we need to take time to learn new programming languages, one of the most profound [...]]]></description>
			<content:encoded><![CDATA[<p>I attended a <a href="http://nofluffjuststuff.com/home/main">No Fluff Just Stuff Symposium</a> a few weeks ago.  One of the main emphasis during the weekend was learning new languages that are available on the <a href="http://en.wikipedia.org/wiki/Java_Virtual_Machine">JVM</a>.  While there are a variety of reasons that we need to take time to learn new programming languages, one of the most profound is learning to think about problems differently.</p>
<h2>Paradigm Shift</h2>
<p>When I entered the development scene I was immersed in <a href="http://en.wikipedia.org/wiki/Object-oriented_programming">Object Oriented</a> programming.  As a result, I tend to think of good design in objects.  A few years ago I began to learn and apply <a href="http://groovy.codehaus.org/">Groovy</a>.  With <a href="http://en.wikipedia.org/wiki/Closure_%28computer_science%29">closures</a> I was able to bleed into the realm of <a href="http://en.wikipedia.org/wiki/Functional_programming">Functional</a> programming.  This gave me a small taste of a new paradigm.  I thought of new ways to solve problems that I couldn&#8217;t see with Java.  I can only imagine how much more I could learn if I developed exclusively in a Functional language for several months.<br />
<span id="more-2453"></span><br />
I tend to see two camps when it comes to learning new languages.  The first camp thinks that the language that they know is sufficient for solving all programming problems.  The second camp runs after the newest hot thing and divorces themselves from their old language.  Neither extreme is healthy.  We need to see languages as tools.  A hammer is not good for solving all problems.  Sure you might be able to turn a screw with the claw of a hammer but why would you.  We need to understand our problems first and select a language that solves it best.  </p>
<p>JVM languages allow us to make this decision at the last responsible moment.  We can select a JVM language that seems appropriate and begin coding.  If it becomes clear later that this language is not well suited to solve this problem then we can change our mind.  The JVM provides a single platform for us to use the best tool for the job.  We can even use multiple languages to develop one system.  The JVM is an amazing canvas for agility.</p>
<h2>Detour</h2>
<p>Now I want to take what may seem like a major detour.  However I would suggest that this does not stray all that far.  We need to extend our effort to become multilingual beyond the JVM.  As professionals we would benefit from learning the language of different business areas.  Management, Testers, and Business Analysts solve problems in different language paradigms.</p>
<p>Many developers begin to tune out as I mention management.  Feelings of frustration begin to take over.  We can tolerate BA&#8217;s and Testers for the most part but management is just a waste of time.  The pain and frustration from the past takes over and we just tune out.  We code in secret and try not to disturb the gods of management.  We avoid them and hopefully they will leave us alone.</p>
<p>While I&#8217;m not here to say that all management is just massively misunderstood and we need to forgive and forget, we do need to learn to communicate.  We often contribute to our own misery.  We are either silent or we speak in a language that makes no sense.  We need to learn their language.</p>
<h2>Speaking the Same Language</h2>
<p>Before I proceed let me make a very important side note.  Not all managers are open to an intelligent and rational discussions.  Some have given in to money and power and they just want to be right no matter the cost.  While this can be true, I think that there are many managers that can be reasonable.  The challenge is not intellectual but one of language.</p>
<p>How do managers think?  Well one simple way to find out is to listen to them.  What are they focused on?  What excites them?  What frustrates them?  But the most important question is why.  Why are they focused on certain things?  The question of why delves into the area of motivation.  What motivates management?  Sure we can go for the easy answer of money, but is that the whole story?  </p>
<h2>Expanding our Library</h2>
<p>Once you start listening I believe we need to move to education.  We need to add a few business books to our technical library.  Begin to understand the information that managers are focused on.  Take time to understand how they get information and how that effects their decisions.  And now it&#8217;s time for a big leap.  How can we provide information from our development effort that can influence management decisions.  Now I want to caution you.  This will not always work.  But if we are not speaking manager-eez then we can not expect to influence their decisions.  I see this same challenge in my marriage.  My wife doesn&#8217;t focus on the same things that I do.  Nevertheless, over time we&#8217;ve learned to speak each others language.  We work to bridge this divide because we &#8220;care&#8221; about each other.  I know I brought out a feeling word.  We can try to avoid the &#8220;F&#8221; word, but if we don&#8217;t care enough to take the first step to bridge the technical and management divide who will?</p>
<h2>Balancing Act</h2>
<p>Once you have a good understanding of how your management team makes decisions, you need to get the right information to them.  While every company and manager is different there tend to be some common ingredients in their decision making process.  The first ingredient is <a href="http://en.wikipedia.org/wiki/Return_on_Investment">return on investment</a> (ROI).  The second ingredient is generally <a href="http://en.wikipedia.org/wiki/Risk_management">risk management</a>.</p>
<p>As a developer these tend to make me irritated.  ROI appears to be something that can not be accurately measured and risk management just results in more work.  However these are things that we deal with in our personal lives all the time.  Marriage, 401K, children, cars, investments, homes all require us to consider ROI and risk.  After buying three homes and selling two I am painfully aware of ROI and the need for risk assessment.  Each purchase has different factors.  A starter home needs to be something that I can resell in a few years.  However starter homes often require a lot of maintenance and updating.  A retirement home needs to be built to last.  Similarly, every management decision has specific factors that drive the decision.  </p>
<p>In software development the major factors tend to be: time-to-market, timeliness, development cost, maintenance costs, usability, scalability, security and features.  The right product at the wrong time results in a useless product.  A great <a href="http://en.wikipedia.org/wiki/8-track_tape">8 track player</a> delivered in 1980 as the <a href="http://en.wikipedia.org/wiki/Cassette_tape">cassette tape</a> market was on the rise, would be a waste of money.  If you were one of the 70 million customers of Sony’s PlayStation that had their information stolen this year, all the other features became less important.  Developing software, or products, is not just a matter of putting the correct components together.  Good managers try to balance all the moving parts.</p>
<h2>Show me the Facts</h2>
<p>So how can we provide valuable information?  One vital piece of information is the project <a href="http://en.wikipedia.org/wiki/Burn_down_chart">burndown</a>.  A burndown projects the projected completion date based on the historical <a href="http://en.wikipedia.org/wiki/Velocity_%28software_development%29">velocity</a> and the size of the feature <a href="http://en.wikipedia.org/wiki/Scrum_%28development%29#Product_backlog">backlog</a>.  But marching towards the finish line does not always equate to a valuable product.  Regular demos to the customer allows us to calibrate the relevance and usability.  Tracking the feedback from these demos helps us measure the value of the current product.</p>
<p>Another factor to measure is the maintainability of a product.  As we set a development pace we need to determine if this pace is creating waste.  Managers have to weigh the cost of speedy development with the cost of long-term maintenance.  But without any data this decision can not be made. Are developers just wasting time trying to make a Rolls-Royce when we just need a Pinto?  We need facts not opinions to steer the ship of management.  Instead of pretending that I am an expert in this area I am going to recommend that you read two of Neal Ford&#8217;s articles on &#8220;Evolutionary architecture and emergent design&#8221;.  </p>
<ul>
<li><a href="http://www.ibm.com/developerworks/java/library/j-eaed17/index.html">Evolutionary architecture and emergent design: Environmental considerations for design, Part 1</a></li>
<li><a href="http://www.ibm.com/developerworks/java/library/j-eaed6/index.html">Evolutionary architecture and emergent design: Emergent design through metrics</a></li>
</ul>
<p>While the topic may be a little different from this blog these articles contain amazing insight on gathering, analyzing and visualizing <a href="http://en.wikipedia.org/wiki/Technical_debt">technical debt</a>.  Technical debt is that elusive beast that we feed when we, with the best intentions, just try to &#8220;get-er done&#8221;.  The fatter this beast gets the harder it is to make changes during the development process and during long-term maintenance.  In this case harder means more costly.  </p>
<h2>Summary</h2>
<p>As developers we are focused on language.  We use words to create software.  We translate business words into code.  We are in fact professional interpreters.  We use our multilingual skills to translate concepts into working software.  But when it comes to bridging the communication divide between software development and management decisions we often give up.  We try to use emotion pleas or technical words to effect change but people quickly stop listening.</p>
<p>As professional, multilingual, translators we need to focus our skills on effectively communicating with management.  We need to understand their domain and gather valuable and relevant information that can guide their decisions.  Instead of avoiding management we need to engage them.  We need to gather information that only we poses and translate it into information that makes sense to critical decision makers.  We need to become part of the solution instead of contributing to an overwhelming problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2011/09/learning-a-new-language/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Spring Injection with @Resource, @Autowired and @Inject</title>
		<link>http://blogs.sourceallies.com/2011/08/spring-injection-with-resource-and-autowired/</link>
		<comments>http://blogs.sourceallies.com/2011/08/spring-injection-with-resource-and-autowired/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 12:00:09 +0000</pubDate>
		<dc:creator>David Kessler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[@Autowired]]></category>
		<category><![CDATA[@Inject]]></category>
		<category><![CDATA[@Resource]]></category>
		<category><![CDATA[Injection]]></category>
		<category><![CDATA[ioc]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=2350</guid>
		<description><![CDATA[Overview
I&#8217;ve been asked several times to explain the difference between injecting Spring beans with &#8216;@Resource&#8217;, &#8216;@Autowired&#8217;, and &#8216;@Inject&#8217;.  While I received a few opinions from colleagues and read a couple of posts on this topic I didn&#8217;t feel like I had a complete picture.
Annotations


Annotation
Package
Source


@Resource
javax.annotation
Java


@Inject
javax.inject
Java


@Qualifier
javax.inject
Java


@Autowired
org.springframework.bean.factory
Spring



In order to explore the behavior of each annotation I fired [...]]]></description>
			<content:encoded><![CDATA[<h2>Overview</h2>
<p>I&#8217;ve been asked several times to explain the difference between injecting Spring beans with &#8216;@Resource&#8217;, &#8216;@Autowired&#8217;, and &#8216;@Inject&#8217;.  While I received a few opinions from colleagues and read a couple of posts on this topic I didn&#8217;t feel like I had a complete picture.</p>
<h4>Annotations</h4>
<table>
<tr>
<th>Annotation</th>
<th>Package</th>
<th>Source</th>
</tr>
<tr>
<td style="text-align:left; padding-left:5px;">@Resource</td>
<td style="text-align:left; padding-left:5px;">javax.annotation</td>
<td style="text-align:left; padding-left:5px;">Java</td>
</tr>
<tr>
<td style="text-align:left; padding-left:5px;">@Inject</td>
<td style="text-align:left; padding-left:5px;">javax.inject</td>
<td style="text-align:left; padding-left:5px;">Java</td>
</tr>
<tr>
<td style="text-align:left; padding-left:5px;">@Qualifier</td>
<td style="text-align:left; padding-left:5px;">javax.inject</td>
<td style="text-align:left; padding-left:5px;">Java</td>
</tr>
<tr>
<td style="text-align:left; padding-left:5px;">@Autowired</td>
<td style="text-align:left; padding-left:5px;">org.springframework.bean.factory</td>
<td style="text-align:left; padding-left:5px;">Spring</td>
</tr>
</table>
<p><br/><br />
In order to explore the behavior of each annotation I fired up <a href="http://www.springsource.com/developer/sts">Spring Tool Suite</a> and started debugging the code.  I used Spring 3.0.5.RELEASE in my research. The following is a summary of my findings.<br />
<span id="more-2350"></span></p>
<h2>The Code</h2>
<p>I wanted to know how &#8216;@Resource&#8217;, &#8216;@Autowired&#8217;, and &#8216;@Inject&#8217; resolved dependencies.  I created an interface called &#8216;Party&#8217; and created two implementations classes.  This allowed me to inject beans without using the concrete type.  This provided the flexibility I needed to determine how Spring resolves beans when there are multiple type matches.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> Party <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>&#8216;Person&#8217; is a component and it implements &#8216;Party&#8217;.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.sourceallies.person</span><span style="color: #339933;">;</span>
...
@<span style="color: #003399;">Component</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Person <span style="color: #000000; font-weight: bold;">implements</span> Party <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>&#8216;Organization&#8217; is a component and it implements &#8216;Party&#8217;.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.sourceallies.organization</span><span style="color: #339933;">;</span>
...
@<span style="color: #003399;">Component</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Organization <span style="color: #000000; font-weight: bold;">implements</span> Party <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I setup a Spring context that scans both of these packages for beans marked with &#8216;@Component&#8217;.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context:component-scan</span> <span style="color: #000066;">base-package</span>=<span style="color: #ff0000;">&quot;com.sourceallies.organization&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context:component-scan</span> <span style="color: #000066;">base-package</span>=<span style="color: #ff0000;">&quot;com.sourceallies.person&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<h2>Tests</h2>
<h3>Test 1: Ambiguous Beans</h3>
<p>In this test I injected a &#8216;Party&#8217; bean that has multiple implementations in the Spring context.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Resource
<span style="color: #000000; font-weight: bold;">private</span> Party party<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Autowired
<span style="color: #000000; font-weight: bold;">private</span> Party party<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Inject
<span style="color: #000000; font-weight: bold;">private</span> Party party<span style="color: #339933;">;</span></pre></div></div>

<p><strong><em>In all three cases a &#8216;NoSuchBeanDefinitionException&#8217; is thrown.  While this exception&#8217;s name implies that no beans were found, the message explains that two beans were found.  All of these annotations result in the same exception.</em></strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">beans</span>.<span style="color: #006633;">factory</span>.<span style="color: #006633;">NoSuchBeanDefinitionException</span><span style="color: #339933;">:</span> 
No unique bean of type <span style="color: #009900;">&#91;</span>com.<span style="color: #006633;">sourceallies</span>.<span style="color: #006633;">Party</span><span style="color: #009900;">&#93;</span> is defined<span style="color: #339933;">:</span> 
expected single matching bean but found <span style="color: #cc66cc;">2</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>organization, person<span style="color: #009900;">&#93;</span></pre></div></div>

<h3>Test 2: Field Name</h3>
<p>In this test I named the Party field person.  By default beans marked with &#8216;@Component&#8217; will have the same name as the class.  Therefore the name of the class &#8216;Person&#8217; is person.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Resource
<span style="color: #000000; font-weight: bold;">private</span> Party person<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Autowired
<span style="color: #000000; font-weight: bold;">private</span> Party person<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Inject
<span style="color: #000000; font-weight: bold;">private</span> Party person<span style="color: #339933;">;</span></pre></div></div>

<p>&#8216;@Resource&#8217; can also take an optional &#8216;name&#8217; attribute.  This is equivalent to the &#8216;@Resource&#8217; code above.  In this case the field variable name remains &#8216;party&#8217;.  There is no equivalent syntax for &#8216;@Autowired&#8217; or &#8216;@Inject&#8217;.  Instead you would have to use a &#8216;@Qualifier&#8217;.  This syntax will be covered later.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Resource<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;person&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">private</span> Party party<span style="color: #339933;">;</span></pre></div></div>

<p><strong><em>All four of these styles inject the &#8216;Person&#8217; bean.</em></strong></p>
<h3>Test 3: Field Type</h3>
<p>In this test I changed the type to be a &#8216;Person&#8217;.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Resource
<span style="color: #000000; font-weight: bold;">private</span> Person party<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Autowired
<span style="color: #000000; font-weight: bold;">private</span> Person party<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Inject
<span style="color: #000000; font-weight: bold;">private</span> Person party<span style="color: #339933;">;</span></pre></div></div>

<p><strong><em>All of these annotations inject the &#8216;Person&#8217; bean.</em></strong></p>
<h3>Test 4: Default Name Qualifier</h3>
<p>In this test I use a &#8216;@Qualifier&#8217; annotation to point to the default name of the &#8216;Person&#8217; component.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Resource
@Qualifier<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;person&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">private</span> Party party<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Autowired
@Qualifier<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;person&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">private</span> Party party<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Inject
@Qualifier<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;person&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">private</span> Party party<span style="color: #339933;">;</span></pre></div></div>

<p><strong><em>All of these annotations inject the &#8216;Person&#8217; bean.</em></strong></p>
<h3>Test 5: Qualified Name</h3>
<p>I added a &#8216;@Qualifier&#8217; annotation to the &#8216;Person&#8217; class</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.sourceallies.person</span><span style="color: #339933;">;</span>
...
@<span style="color: #003399;">Component</span>
@Qualifier<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;personBean&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Person <span style="color: #000000; font-weight: bold;">implements</span> Party <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In this test I use a &#8216;@Qualifier&#8217; annotation to point to the qualified name of the &#8216;Person&#8217; component.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Resource
@Qualifier<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;personBean&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">private</span> Party party<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Autowired
@Qualifier<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;personBean&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">private</span> Party party<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Inject
@Qualifier<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;personBean&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">private</span> Party party<span style="color: #339933;">;</span></pre></div></div>

<p><strong><em>All of these annotations inject the &#8216;Person&#8217; bean.</em></strong></p>
<h3>Test 6: List of Beans</h3>
<p>In this test I inject a list of beans.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Resource
<span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>Party<span style="color: #339933;">&gt;</span> parties<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Autowired
<span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>Party<span style="color: #339933;">&gt;</span> parties<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Inject
<span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>Party<span style="color: #339933;">&gt;</span> parties<span style="color: #339933;">;</span></pre></div></div>

<p><strong><em>All of these annotations inject 2 beans into the list.  This can also be accomplished with a &#8216;@Qualifier&#8217;.  Each bean marked with a specific qualifier will be added to the list.</em></strong></p>
<h3>Test 7: Conflicting messages</h3>
<p>In this test I add a bad &#8216;@Qualifier&#8217; and a matching field name.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Resource
@Qualifier<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;bad&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">private</span> Party person<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Autowired
@Qualifier<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;bad&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">private</span> Party person<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Inject
@Qualifier<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;bad&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">private</span> Party person<span style="color: #339933;">;</span></pre></div></div>

<p><strong><em>In this case the field marked with &#8216;@Resource&#8217; uses the field name and ignores the &#8216;@Qualifier&#8217;.  As a result the &#8216;Person&#8217; bean is injected.</em></strong></p>
<p><strong><em>However the &#8216;@Autowired&#8217; and &#8216;@Inject&#8217; field throw a &#8216;NoSuchBeanDefinitionException&#8217; error because it can not find a bean that matches the &#8216;@Qualifier&#8217;.</em></strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"> org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">beans</span>.<span style="color: #006633;">factory</span>.<span style="color: #006633;">NoSuchBeanDefinitionException</span><span style="color: #339933;">:</span> 
No matching bean of type <span style="color: #009900;">&#91;</span>com.<span style="color: #006633;">sourceallies</span>.<span style="color: #006633;">Party</span><span style="color: #009900;">&#93;</span> found <span style="color: #000000; font-weight: bold;">for</span> dependency<span style="color: #339933;">:</span> 
expected at least <span style="color: #cc66cc;">1</span> bean which qualifies as autowire candidate <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #000000; font-weight: bold;">this</span> dependency. 
<span style="color: #006633;">Dependency</span> annotations<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>@org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">beans</span>.<span style="color: #006633;">factory</span>.<span style="color: #006633;">annotation</span>.<span style="color: #006633;">Autowired</span><span style="color: #009900;">&#40;</span>required<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>,
@org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">beans</span>.<span style="color: #006633;">factory</span>.<span style="color: #006633;">annotation</span>.<span style="color: #006633;">Qualifier</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">=</span>bad<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<h2>Conclusions</h2>
<p>With the exception of test 2 &#038; 7 the configuration and outcomes were identical.  When I looked under the hood I determined that the &#8216;@Autowired&#8217; and &#8216;@Inject&#8217; annotation behave identically.  Both of these annotations use the <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.html">&#8216;AutowiredAnnotationBeanPostProcessor&#8217;</a> to inject dependencies. &#8216;@Autowired&#8217; and &#8216;@Inject&#8217; can be used interchangeable to inject Spring beans.  However the &#8216;@Resource&#8217; annotation uses the <a href="http://static.springsource.org/spring/docs/3.1.0.M2/javadoc-api/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.html">&#8216;CommonAnnotationBeanPostProcessor&#8217;</a> to inject dependencies.  Even though they use different post processor classes they all behave nearly identically.  Below is a summary of their execution paths.</p>
<p><strong>@Autowired and @Inject</strong></p>
<ol>
<li>Matches by Type</li>
<li>Restricts by Qualifiers</li>
<li>Matches by Name</li>
</ol>
<p><strong>@Resource</strong></p>
<ol>
<li>Matches by Name</li>
<li>Matches by Type</li>
<li>Restricts by Qualifiers (ignored if match is found by name)</li>
</ol>
<p>While it could be argued that &#8216;@Resource&#8217; will perform faster by name than &#8216;@Autowired&#8217; and &#8216;@Inject&#8217; it would be negligible.  This isn&#8217;t a sufficient reason to favor one syntax over the others.  I do however favor the &#8216;@Resource&#8217; annotation for it&#8217;s concise notation style.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Resource<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;person&quot;</span><span style="color: #009900;">&#41;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Autowired
@Qualifier<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;person&quot;</span><span style="color: #009900;">&#41;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Inject
@Qualifier<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;person&quot;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>You may argue that they can be equal concise if you use the field name to identify the bean name.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Resource
<span style="color: #000000; font-weight: bold;">private</span> Party person<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Autowired
<span style="color: #000000; font-weight: bold;">private</span> Party person<span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Inject
<span style="color: #000000; font-weight: bold;">private</span> Party person<span style="color: #339933;">;</span></pre></div></div>

<p>True enough, but what happens if you want to <a href="http://en.wikipedia.org/wiki/Code_refactoring">refactor</a> your code?  By simply renaming the field name you&#8217;re no longer referring to the same bean.   I recommend the following practices when wiring beans with annotations.</p>
<p><strong>Spring Annotation Style Best Practices</strong></p>
<ol>
<li>Explicitly name your component [@Component("beanName")]</li>
<li>Use &#8216;@Resource&#8217; with the &#8216;name&#8217; attribute [@Resource(name="beanName")]</li>
<li>Avoid &#8216;@Qualifier&#8217; annotations unless you want to create a list of similar beans.  For example you may want to mark a set of rules with a specific &#8216;@Qualifier&#8217; annotation.  This approach makes it simple to inject a group of rule classes into a list that can be used for processing data.</li>
<li>Scan specific packages for components [context:component-scan base-package="com.sourceallies.person"].  While this will result in more component-scan configurations it reduces the chance that you&#8217;ll add unnecessary components to your Spring context.</li>
</ol>
<p>Following these guidelines will increase the readability and stability of your Spring annotation configurations.</p>
<h2>Related Links</h2>
<p><a href="/2011/06/testing-spring-wiring/"> Testing Spring Wiring</a><br />
<a href="http://beanoh.org"> Beanoh Spring Wiring Test Framework</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2011/08/spring-injection-with-resource-and-autowired/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Creating an Open Source Project</title>
		<link>http://blogs.sourceallies.com/2011/07/creating-an-open-source-project/</link>
		<comments>http://blogs.sourceallies.com/2011/07/creating-an-open-source-project/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 05:00:11 +0000</pubDate>
		<dc:creator>David Kessler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=2118</guid>
		<description><![CDATA[Open Sourcing Software
I&#8217;ve been using open source software for many years, but I&#8217;ve never open sourced my own project.  This blog is a record of my experience as I start this journey.   The resulting project can be found at http://beanoh.org.
Where
First I had to decide where to store the code.  There are several [...]]]></description>
			<content:encoded><![CDATA[<h1>Open Sourcing Software</h1>
<p>I&#8217;ve been using open source software for many years, but I&#8217;ve never open sourced my own project.  This blog is a record of my experience as I start this journey.   The resulting project can be found at <a href="http://beanoh.org">http://beanoh.org</a>.</p>
<h2>Where</h2>
<p>First I had to decide where to store the code.  There are several popular (<a href="http://en.wikipedia.org/wiki/Comparison_of_open_source_software_hosting_facilities#Popularity">Comparison of open source software hosting</a>) open source hosting options. I chose GitHub (<a href="http://github.com">github.com</a>) because I already had an account and I&#8217;m comfortable using Git.  Furthermore, GitHub provides intuitive tools that make it easy to manage a project.  I can setup an <a href="https://github.com/blog/674-introducing-organizations">organization</a> so multiple <a href="http://www.sourceallies.com">Source Allies</a> employees can have commit rights on this project.  GitHub also has an integrated <a href="https://github.com/blog/411-github-issue-tracker">issue and feature tracking system</a> that connects commits with tickets.  Overall I am very impressed with GitHub.</p>
<p><span id="more-2118"></span></p>
<h2>License</h2>
<p>Before I push my code into GitHub I need to choose a liscense.  This seems very overwhelming.  I&#8217;m not a lawyer so how can I understand what each license provides?  I started by searching for comparison charts.   Out of these results I found the following comparisons helpful:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Comparison_of_free_software_licenses">Comparison of free software licenses</a></li>
<li><a href="http://www.shafqatahmed.com/WindowsLiveWriter/OpenSourceLicenseComparison.png">Open Source License Comparison</a></li>
<li><a href="http://knol.google.com/k/open-source-licenses-for-dummies#">open source licenses for dummies</a></li>
</ul>
<p>I feel like I understand the differences a little better, but I would like to know what other open source projects are using. I found a list of the &#8220;Top 20 Most Commonly Used Licenses in Open Source Projects&#8221; (<a href="http://www.blackducksoftware.com/oss/licenses">http://www.blackducksoftware.com/oss/licenses</a>). With the comparisons and the ranking I am leaning towards the GNU General Public License (GPL) and the GNU Lesser General Public License (LGPL).</p>
<p>I went to &#8216;gnu.org&#8217; to research these licenses and I stumbled across a page called <a href="http://www.gnu.org/licenses/why-not-lgpl.html">Why you shouldn&#8217;t use the Lesser GPL for your next library</a>.  It says, &#8220;The choice of license makes a big difference: using the Lesser GPL permits use of the library in proprietary programs; using the ordinary GPL for a library makes it available only for free programs.&#8221;  In my mind this is a reason to use the &#8220;Lesser&#8221; license.  I want to provide an open source project that can be used in any product.  The &#8220;Lesser&#8221; license provides more to the community.   In all fairness it is worth mentioning that the ordinary GPL is designed to encourage developers to open source the software that uses these libraries.  In my case I want to make my library available to anyone.</p>
<p>Now that I have decided on the license I am going to put the following disclaimer at the top of every file:</p>
<blockquote><p>Copyright (c) 2011 Source Allies</p>
<p>This library is free software; you can redistribute it and/or<br />
modify it under the terms of the GNU Lesser General Public<br />
License as published by the Free Software Foundation;<br />
version 3.0.</p>
<p>This library is distributed in the hope that it will be useful,<br />
but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br />
Lesser General Public License for more details.</p>
<p>You should have received a copy of the GNU Lesser General Public<br />
License along with this library; if not, visit<br />
<a href="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt">http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt</a>.</p></blockquote>
<p>I also need to include a license.txt file at the root of my project that contains the full text of the <a href="http://www.gnu.org/licenses/lgpl.txt">LGPL</a>.</p>
<p>Make sure you get the license in place before you start distributing or using the jar with third party organizations.  In the case of consulting the client may end up owning the product if it is not licensed properly.  Why go to so much trouble to open source code just to have the right lost to a third party organization?</p>
<h2>Setup GitHub</h2>
<p>I already have a GitHub account, but I want to setup an organization to manage a team of developers.  I am able to create an organization under my personal &#8216;Account Settings&#8217; under &#8216;Organizations&#8217;.  I clicked the &#8216;Create Organization&#8217; button and followed the wizard.  For more information visit <a href="https://github.com/blog/674-introducing-organizations">https://github.com/blog/674-introducing-organizations</a>.</p>
<h2>Collaboration</h2>
<p>I am curious how open source projects manage changes from non-committers.  I found a great article at GitHub that explains how most teams collaborate within their site (<a href="http://help.github.com/pull-requests">http://help.github.com/pull-requests</a>).  In short, contributors outside of the core development team submit &#8220;Pull Requests&#8221;.  The project administrator(s) review these requests and decide if they want to merge them back into the code base.  In my experience Git merging is fairly painless.  This model allows anyone in the world the opportunity to contribute, while preserving the owners right to control the flow of changes.  Too many chefs in the kitchen will ruin the food.</p>
<h2>U-turn</h2>
<p>I started looking for &#8220;How To&#8221; open source software articles and books.   I didn&#8217;t find very many resources.  Everyone talks about how to use  open source, but very few people talk about how to effectively open  source your own software.  Eventually I ran accross &#8220;Producing Open  Source Software: How to Run a Successful Free Software Project&#8221; by Karl  Fogel (<a href="http://producingoss.com/producingoss.pdf">http://producingoss.com/producingoss.pdf</a>).  This book is a collection of insights from a major contributor to the open source project Subersion (<a href="http://subversion.apache.org/">http://subversion.apache.org</a>).   I gravitated to this book because it is free.  Apparently Karl believes  software and books should be available at no charge .</p>
<p>In the  first chapter Fogel suggestes that 90 to 95% of all open source projects  fail.  As the founding committer of Subversion, Karl has a little bit of  experience leading a wildly successful open source project.  &#8220;This book  is about avoiding failure. It examines not only how to do things right,  but how to do them wrong, so you can recognize and correct problems  early.&#8221; (p. 10)  So it is time to look at my mistakes so far.</p>
<p>First,  I have not selected a &#8220;good name&#8221; (p. 21-22).  So what does &#8220;good&#8221;  mean.  The project names that I talk about are the ones that I  remember.  I am drawn to word plays like Mockito (mockito.org) which is a  play on the drink Mojito.  When I heard it I remembered two  things, the punny name and it&#8217;s purpose of mocking.</p>
<p>Second, I  need to develop a &#8220;clear mission&#8221; (p. 22 &#8211; 23).  I have to admit that  this idea of a mission statement is overwhelming to me.  In order to put  myself to sleep I googled a few corporate mission statements.  Without  referring back to their statements I would not be able to tell you what  they were.  Ultimately they stated that they were super awesome  organizations focused on making money.  Nevertheless, what is a good and  useful mission statement?  Karl describes it as a &#8220;quick description&#8221;.   A statement that helps the customer decide in 30 seconds if they are  interested in your project.  He recommends that this statement be  &#8220;prominently placed on the front  page, preferably right under the project&#8217;s name.&#8221; (p.22)  If we take a  look at Mockito again they  state, right under their name, that it is  &#8220;simpler &amp; better mocking&#8221;  (mockito.org).  Traditionally I would consider this a tagline and not a  mission statement.  Nevertheless, I know several company&#8217;s taglines  but I don&#8217;t know a single &#8220;mission statement&#8221;.  So what the heck, why  split hairs?</p>
<p>While it seems strange, the third thing is to &#8220;state that the  project is free&#8221;. (p. 22-23).  I had to visit several open source  project homepages to find an example of this.  I did find the  phrase &#8220;open source&#8217; in the first two sentences at  http://subversion.apache.org.  This does not seem to be a common  practice, but it doesn&#8217;t take much effort to put the words &#8220;open  source&#8221; in the description of the project.</p>
<p>Fourth, I need to take  time to create clear documentation (p. 26-29).  This just takes time.   The obvious first step is a Getting Started page.   What&#8217;s more difficult is writing this  from the perspective of someone that knows nothing about my product.  Fogel suggests that you do not have to wait until you have comprehensive documentation.  On the other hand, just write down some basic information.  It does not matter if it is incomplete.  Focus on helping new users get your product running.</p>
<h2>New Direction</h2>
<p>After reading this I need to slow down and make sure that we put our best foot forward.  We need a good name, logo, and well designed website.  I need to clearly state what this software does.   I need to put  together some basic documentation that is easy to read and understand.</p>
<p>After some discussion we decided to setup a logo contest on <a href="https://99designs.com/">https://99designs.com</a>.   This was very easy to setup and we got some amazing designs.  I also  went through every class and added javadocs.  I put together some  short screen casts with Camtasia (<a href="http://www.techsmith.com/camtasia/">http://www.techsmith.com/camtasia/</a>).   This took a few tries, but the results were well worth it.  Now I&#8217;m  working on integrating all of this documentation into an intuitive and  effective website design.</p>
<p>As a software developer it is easy for  me to focus on the technical aspects of my software and neglect the  presentation.  While this may not be my initial focus I  found that as a consumer I evaluate other projects in a few seconds  based on how their websites looks.  If I feel like it is interesting I  start click through their site.  If I don&#8217;t &#8220;get it&#8221; in a few clicks I  move on.  This evaluation period is extended if I have a recommendation  from a friend or colleague.  Nevertheless, I make snap judgments on  aesthetics, not on the substance of the project.</p>
<p>If I know this  about myself, then I need to make a reasonable investment in the initial  presentation of this software.   Even though our project will be  distributed freely, we decided to spend money on the design to make sure  our presentation matches the quality of our software.  Unfortunately it costs money to provide a quality open source product.</p>
<h2>Conclusions</h2>
<p>I  have to admit that I have been avoiding this journey for quite a  while.  Between the licensing and the project administration I felt a  bit overwhelmed.  Nevertheless, I am starting with a small pilot project  that has focused and limited functionality.  I&#8217;m sure that there will  be a lessons learned blog that will emerge out of this experience as  time goes on.  Until then have fun sharing your code with the world and check out Source Allies newest open source project at <a href="http://beanoh.org">beanoh.org</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2011/07/creating-an-open-source-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving to a new home</title>
		<link>http://blogs.sourceallies.com/2011/04/moving-to-a-new-home/</link>
		<comments>http://blogs.sourceallies.com/2011/04/moving-to-a-new-home/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 02:36:05 +0000</pubDate>
		<dc:creator>Sudhakar Ramasamy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=2125</guid>
		<description><![CDATA[As of May 2nd I will no longer be employed at Source Allies. My blog has a new home at http://blog.sudr.info. Feel free to follow me there.
]]></description>
			<content:encoded><![CDATA[<p>As of May 2nd I will no longer be employed at Source Allies. My blog has a new home at <a href="http://blog.sudr.info">http://blog.sudr.info</a>. Feel free to follow me there.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2011/04/moving-to-a-new-home/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rethinking the DAO-Service layer relationship</title>
		<link>http://blogs.sourceallies.com/2011/04/rethinking-the-dao-service-layer-relationship/</link>
		<comments>http://blogs.sourceallies.com/2011/04/rethinking-the-dao-service-layer-relationship/#comments</comments>
		<pubDate>Fri, 08 Apr 2011 17:34:25 +0000</pubDate>
		<dc:creator>Tim Bierbaum</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=2058</guid>
		<description><![CDATA[Lately I have been thinking that the standard service-calling-the-dao-layer architecture hasn&#8217;t been working out as well as I would hope.  The applications I have been working on have been using Spring and Hibernate with a dao object per model object.  While this does provide a good separation between the two, I have been [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I have been thinking that the standard service-calling-the-dao-layer architecture hasn&#8217;t been working out as well as I would hope.  The applications I have been working on have been using Spring and Hibernate with a dao object per model object.  While this does provide a good separation between the two, I have been finding it increasingly difficult to write good tests for the service layer as the project matures.  Past experience has shown that if writing tests is difficult, then it just isn&#8217;t done.  Follow along as I think about possible ways to address this issue.<br />
<span id="more-2058"></span><br />
Let&#8217;s look at what I consider to be the &#8217;standard&#8217; service layer object.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ServiceExample1 <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> FooDAO fooDAO<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> BarDAO barDAO<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> searchForFooAndBar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// do some stuff</span>
		<span style="color: #666666; font-style: italic;">//</span>
&nbsp;
		fooDAO.<span style="color: #006633;">searchForFoo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// do some more stuff</span>
		<span style="color: #666666; font-style: italic;">// </span>
&nbsp;
		barDAO.<span style="color: #006633;">searchForBar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// finish up doing stuff</span>
		<span style="color: #666666; font-style: italic;">//</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> createANewFoo<span style="color: #009900;">&#40;</span>Foo foo<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		fooDAO.<span style="color: #006633;">createFoo</span><span style="color: #009900;">&#40;</span>foo<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> createANewBar<span style="color: #009900;">&#40;</span>Bar bar<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		barDAO.<span style="color: #006633;">createBar</span><span style="color: #009900;">&#40;</span>bar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>A couple of methods are defined, and they use two difference dao objects.  Writing a test for the searchForFooAndBar method would currently involve providing alternative implementations for both the FooDAO and BarDAO objects.  While this initially wouldn&#8217;t be too difficulty, it is easy to imagine how the number of dao dependencies could grow as the project goes on.  It could also cause problems since we wouldn&#8217;t know which methods in the dao needed to be stubbed out or mocked for testing.  I also worry that it would be too easy to test implementation instead of behavior.  A test failure would be reported if the service changed which dao methods were called.</p>
<p>Another issue I&#8217;ve run into is not knowing which dao&#8217;s are involved in a method when writing the test.  My initial thought was to not have the service object maintain references to the dao objects, but instead have each method require them as method parameters.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ServiceExample2 <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> searchForFooAndBar<span style="color: #009900;">&#40;</span>FooDAO fooDAO, BarDAO barDAO<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// do some stuff</span>
		<span style="color: #666666; font-style: italic;">//</span>
&nbsp;
		fooDAO.<span style="color: #006633;">searchForFoo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// do some more stuff</span>
		<span style="color: #666666; font-style: italic;">// </span>
&nbsp;
		barDAO.<span style="color: #006633;">searchForBar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// finish up doing stuff</span>
		<span style="color: #666666; font-style: italic;">//</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> createANewFoo<span style="color: #009900;">&#40;</span>FooDAO fooDAO, Foo foo<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		fooDAO.<span style="color: #006633;">createFoo</span><span style="color: #009900;">&#40;</span>foo<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> createANewBar<span style="color: #009900;">&#40;</span>BarDAO barDAO, Bar bar<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		barDAO.<span style="color: #006633;">createBar</span><span style="color: #009900;">&#40;</span>bar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p> Looking over this code, I didn&#8217;t care for it from the start.  Maybe if the service layer objects were finer grained.  Instead of three methods in the service from our first example, maybe there should be 3 service classes.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> searchForFooAndBar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// do some stuff</span>
		<span style="color: #666666; font-style: italic;">//</span>
&nbsp;
		fooDAO.<span style="color: #006633;">searchForFoo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// do some more stuff</span>
		<span style="color: #666666; font-style: italic;">// </span>
&nbsp;
		barDAO.<span style="color: #006633;">searchForBar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// finish up doing stuff</span>
		<span style="color: #666666; font-style: italic;">//</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I think this would help fix the problem of having too many dao references, but I still wasn&#8217;t sure I liked the dependency on the dao&#8217;s themselves.  That brought me to the final solution I thought of, which involves creating an interface for each method that defines the operations it requires to be provided.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> FooCreationAdapter <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> createFoo<span style="color: #009900;">&#40;</span>Foo foo<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> BarCreationAdapter <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> createBar<span style="color: #009900;">&#40;</span>Bar bar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> SearchAdapter <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> searchForFoo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> searchForBar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Service <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> searchForFooAndBar<span style="color: #009900;">&#40;</span>SearchAdapter searchAdapter<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// do some stuff</span>
		<span style="color: #666666; font-style: italic;">//</span>
&nbsp;
		searchAdapter.<span style="color: #006633;">searchForFoo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// do some more stuff</span>
		<span style="color: #666666; font-style: italic;">// </span>
&nbsp;
		searchAdapter.<span style="color: #006633;">searchForBar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// finish up doing stuff</span>
		<span style="color: #666666; font-style: italic;">//</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> createANewFoo<span style="color: #009900;">&#40;</span>FooCreationAdapter adapter, Foo foo<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		adapter.<span style="color: #006633;">createFoo</span><span style="color: #009900;">&#40;</span>foo<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> createANewBar<span style="color: #009900;">&#40;</span>BarCreationAdapter adapter, Bar bar<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		adapter.<span style="color: #006633;">createBar</span><span style="color: #009900;">&#40;</span>bar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>While I feel this is the cleanest solution that would be the easiest to test, I really don&#8217;t think it is practical on a project level.  Does anyone have a solution that has worked well for them?</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2011/04/rethinking-the-dao-service-layer-relationship/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Greasemonkey</title>
		<link>http://blogs.sourceallies.com/2011/02/greasemonkey/</link>
		<comments>http://blogs.sourceallies.com/2011/02/greasemonkey/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 19:07:11 +0000</pubDate>
		<dc:creator>David Kessler</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=1730</guid>
		<description><![CDATA[Greasemonkey is an extension for Firefox that leverages javascript to modify the look and functionality of a page.  At first glance this tool looks like a neat toy.  However, this tool came in quite handy at one of our clients recently.
Our client was tracking their daily status on a whiteboard in a conference [...]]]></description>
			<content:encoded><![CDATA[<p>Greasemonkey is an extension for Firefox that leverages javascript to modify the look and functionality of a page.  At first glance this tool looks like a neat toy.  However, this tool came in quite handy at one of our clients recently.</p>
<p>Our client was tracking their daily status on a whiteboard in a conference room.  A corporate memo was sent out banning the exclusive use of whiteboards for teams.  As a result we turned to our web-based tracking tool.  Unfortunately their whiteboard equivalent was clunky and inadequate.  I spent a few hours putting together a Greasemonkey script that altered the look of this page to mimic our old whiteboard.  These changes helped ease this transition.<br />
<span id="more-1730"></span><br />
Let&#8217;s walk through a simple example to change the behavior of the base Google search page.</p>
<ol>
<li> Download and install Greasemonkey from <a href="https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/">https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/</a></li>
<li> Navigate to <a href="http://www.google.com">www.google.com</a> </li>
<li> Tools &#8211; &gt; Greasemonkey -&gt; New User Script&#8230;</li>
<li> Enter a name</li>
<li> Enter a namespace (This is provided so your scripts do not clash with others)</li>
<li> Verify that the Includes contain &#8216;http://www.google.com/&#8217;</li>
<li> A new js file will open in your default text editor.</li>
<li> The script will contain a comment that reflects the values that you entered</li>
<li> Add the following code</li>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">GM_addStyle<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\</span>
    body{<span style="color: #000099; font-weight: bold;">\</span>
        background-image:url('http://upload.wikimedia.org/wikipedia/en/d/d3/Gm_icon.png');<span style="color: #000099; font-weight: bold;">\</span>
    }<span style="color: #000099; font-weight: bold;">\</span>
&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<li> GM_addStyle is method provided by the Greasemonkey API. (<a href='http://wiki.greasespot.net/Greasemonkey_Manual:API' target="_blank">http://wiki.greasespot.net/Greasemonkey_Manual:API</a>)</li>
<li> Save the script and refresh &#8216;www.google.com&#8217;</li>
<li> You should see grease monkeys all over the page.</li>
<li> Now add the following code</li>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;I have been modified by Greasemonkey.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<li> Save the script and refresh &#8216;www.google.com&#8217;</li>
<li> You should see an alert box with the text above.</li>
</ol>
<p>While this is a trivial example you can begin to imagine the possibilities.  One of my colleagues used greasemonkey to modify a monitoring page.  Before his modification it took three clicks to get the detailed information.  We used this page every day all day to monitor our tests.  After we installed his greasemonkey script we could just click on a new link that was generated.  This seems like a trivial example, but we found that a number of these modifications helped us be more efficient and improved our quality of life.  As a developer I hate repetitive tasks.  I have a deep desire to automate everything.  Greasemonkey empowers us to make the World Wide Web our own.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2011/02/greasemonkey/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Transactions Our Invisible Allies</title>
		<link>http://blogs.sourceallies.com/2011/01/transactions-our-invisible-allies/</link>
		<comments>http://blogs.sourceallies.com/2011/01/transactions-our-invisible-allies/#comments</comments>
		<pubDate>Fri, 28 Jan 2011 17:33:56 +0000</pubDate>
		<dc:creator>David Kessler</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[JUnit]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[transaction]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=1712</guid>
		<description><![CDATA[Transactions are an essential component in enterprise software development.  When your application works properly you rarely think about transactions.  However, when things go wrong debugging transactions can be quite challenging.  Instead of being reactive we need to proactively test our transactions.
When I first got into the software industry I was a manual [...]]]></description>
			<content:encoded><![CDATA[<p>Transactions are an essential component in enterprise software development.  When your application works properly you rarely think about transactions.  However, when things go wrong debugging transactions can be quite challenging.  Instead of being reactive we need to proactively test our transactions.</p>
<p>When I first got into the software industry I was a manual tester.  Those years of repetition and tedium drove me to the world of coding and automation.  As a software developer I am committed to automated testing.  If a feature is worth coding it is worth testing.  Automated tests have positioned me to be proactive instead of reactive.  Nevertheless, transactions are quite challenging to test.<br />
<span id="more-1712"></span></p>
<p>In order to test a transaction you must control three steps.</p>
<ol>
<li>Successfully make a change within a transaction.</li>
<li>Cause an exception to be thrown within the same transaction.</li>
<li>Verify that the change in step one was rolled-back.</li>
</ol>
<p>Step two is generally the hardest step to control within a test.</p>
<p>There are two main ways to create an exception.  The first, and less complicated way, is to throw the exception within your code.  This works great if you have a transaction that encompasses multiple steps within a method.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Transactional
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> batchUpdate<span style="color: #009900;">&#40;</span><span style="color: #003399;">List</span> people<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>Person person <span style="color: #339933;">:</span> people<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		repository.<span style="color: #006633;">save</span><span style="color: #009900;">&#40;</span>person<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		log.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Saved person: &quot;</span> <span style="color: #339933;">+</span> person.<span style="color: #006633;">name</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>To test this you could write the following JUnit test.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Resource
BatchProcessor batchProcessor<span style="color: #339933;">;</span>
&nbsp;
@Resource
PersonRepository personRepository<span style="color: #339933;">;</span>
&nbsp;
@Test
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testBatchUpdate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003399;">List</span> people <span style="color: #339933;">=</span> <span style="color: #003399;">Arrays</span>.<span style="color: #006633;">asList</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Bob&quot;</span><span style="color: #009900;">&#41;</span>, 
                          <span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Mary&quot;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Ben&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertEquals</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, personRepository.<span style="color: #006633;">findAllPoeple</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	batchProcessor.<span style="color: #006633;">batchUpdate</span><span style="color: #009900;">&#40;</span>people<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertEquals</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span>, personRepository.<span style="color: #006633;">findAllPoeple</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
@Test
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testBatchUpdateRollback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	batchProcessor.<span style="color: #006633;">setLogger</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> StubExplodingLogger<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003399;">List</span> people <span style="color: #339933;">=</span> <span style="color: #003399;">Arrays</span>.<span style="color: #006633;">asList</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Bob&quot;</span><span style="color: #009900;">&#41;</span>, 
                              <span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Mary&quot;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Ben&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertEquals</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, personRepository.<span style="color: #006633;">findAllPoeple</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">try</span><span style="color: #009900;">&#123;</span>
		batchProcessor.<span style="color: #006633;">batchUpdate</span><span style="color: #009900;">&#40;</span>people<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">fail</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">RuntimeException</span> e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;boom&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertEquals</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, personRepository.<span style="color: #006633;">findAllPoeple</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> StubExplodingLogger <span style="color: #000000; font-weight: bold;">extends</span> Logger<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> countDown<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> StubExplodingLogger<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> countDown<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;explodingLogger&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">countDown</span> <span style="color: #339933;">=</span> countDown<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> info<span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>countDown <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">RuntimeException</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test explosion - BOOM!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;tick&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		countDown<span style="color: #339933;">--;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In this example you inject a fake logger that explodes on the second call.  This is an ideal implementation for testing transactions and makes our test fairly straightforward.  However the test for the repository save transaction is more complicated.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Transactional
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> save<span style="color: #009900;">&#40;</span>Person person<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//save the person</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The test for this method would look something like this.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Test
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testPersonRepositorySaveRollback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertEquals</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, personRepository.<span style="color: #006633;">findAllPoeple</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">try</span><span style="color: #009900;">&#123;</span>
		personRepository.<span style="color: #006633;">save</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Bob&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">fail</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertEquals</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, personRepository.<span style="color: #006633;">findAllPoeple</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In this case we have to rely on the database to throw an exception.  This means that our application allows us to send data to the database that is in a bad state.  In the past I have opened up a hole in my validation that allowed me to send bad data to the database.  This is an irresponsible approach.  There are two approaches that solve this issue while preserving the integrity of your application.</p>
<p>The first way is to simply test the configuration.  It is fairly straight forward to verify that the method is marked with @Transactional and the framework is wrapping this with a transaction.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Resource
PersonRepository personRepository<span style="color: #339933;">;</span>
&nbsp;
@Test
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testTransactionalConfiguration<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">//verify the save method is marked with @Transactional</span>
    <span style="color: #003399;">Method</span> method <span style="color: #339933;">=</span> 
         PersonRepository.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getDeclaredMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;save&quot;</span>, Person.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">Annotation</span> annotation <span style="color: #339933;">=</span> method.<span style="color: #006633;">getAnnotation</span><span style="color: #009900;">&#40;</span>Transactional.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertNotNull</span><span style="color: #009900;">&#40;</span>annotation<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//verify PersonRepository is a proxy</span>
    <span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertTrue</span><span style="color: #009900;">&#40;</span>personRepository.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.
                                <span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">contains</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;$$EnhancerByCGLIB$$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>However this approach fails to test the effect.  It verifies that it is configured to work, but it fails to verify that it truly works.</p>
<p>The second approach is to temporarily modify the database constraints within a test to cause a failure.  The simplest modification is to setup a database constraint that will not allow the state &#8220;AL&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Before
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    jdbcTemplate.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ALTER TABLE State&quot;</span> <span style="color: #339933;">+</span>
		                <span style="color: #0000ff;">&quot;ADD CONSTRAINT test_constraint &quot;</span> <span style="color: #339933;">+</span>
                                <span style="color: #0000ff;">&quot;CHECK (State &lt;&gt; 'AL');&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
@Test
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testPersonRepositorySaveRollback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertEquals</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, personRepository.<span style="color: #006633;">findAllPoeple</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">try</span><span style="color: #009900;">&#123;</span>
                Address address <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Address<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;100 Street&quot;</span>, 
                                                   <span style="color: #0000ff;">&quot;Mobile&quot;</span>, <span style="color: #0000ff;">&quot;AL&quot;</span>, <span style="color: #0000ff;">&quot;36601&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		personRepository.<span style="color: #006633;">save</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Bob&quot;</span>, address<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">fail</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertEquals</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, personRepository.<span style="color: #006633;">findAllPoeple</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
@Test
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testPersonRepositorySaveRollback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertEquals</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, personRepository.<span style="color: #006633;">findAllPoeple</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        Address address <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Address<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;200 Street&quot;</span>, <span style="color: #0000ff;">&quot;Des Moines&quot;</span>, 
                                                  <span style="color: #0000ff;">&quot;IA&quot;</span>, <span style="color: #0000ff;">&quot;50044&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	personRepository.<span style="color: #006633;">save</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Mary&quot;</span>, address<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertEquals</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, personRepository.<span style="color: #006633;">findAllPoeple</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
@After
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> tearDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    jdbcTemplate.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ALTER TABLE State&quot;</span> <span style="color: #339933;">+</span>
		              <span style="color: #0000ff;">&quot;DROP CONSTRAINT test_constraint;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This allows you to test that people with other states are committed and that people that are in the state of &#8220;AL&#8221; are rolled-back.  It is important that this constraint is added in the @Before setup method and removed in the @After teardown method.</p>
<p>I have lost too many hours of my life tracking down strange bugs that were ultimately related to missing or improperly configured transactions.  Transactions are mission critical.  They only get attention when they do not work.  Furthermore, the cleanup of fragmented data can be crippling to an organization.</p>
<p>As professionals we must be committed to writing automated tests.  This is especially true for mission critical features like transactions.  Transactions are rarely explicitly stated in requirements.  They are almost never directly tested by manual testers.  And they are very expensive when they are missing or fail to work properly in production.  They are our invisible allies.  We need to make them first class citizens in our tests.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2011/01/transactions-our-invisible-allies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Ubuntu: A Trial and Error Account</title>
		<link>http://blogs.sourceallies.com/2010/05/installing-ubuntu-a-trial-and-error-account/</link>
		<comments>http://blogs.sourceallies.com/2010/05/installing-ubuntu-a-trial-and-error-account/#comments</comments>
		<pubDate>Fri, 07 May 2010 18:04:12 +0000</pubDate>
		<dc:creator>Ryan  Day</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=1509</guid>
		<description><![CDATA[Recently I decided it was time to grab up a spare computer that I could use for tinkering as well as back up files from my other machine in the event that it goes down. The one big thing I wanted to do was to install a Linux OS and experience everything that comes with [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I decided it was time to grab up a spare computer that I could use for tinkering as well as back up files from my other machine in the event that it goes down. The one big thing I wanted to do was to install a Linux OS and experience everything that comes with it. This would be my first time installing a Linux OS. I chose to install <a href="http://www.ubuntu.com/" target="_blank">Ubuntu</a> since it is the most widely used and has the most extensive documentation and help available.</p>
<p><strong>The Download</strong><br />
When I bought this machine it had a fresh install of Windows XP and came with the recovery disk which was excellent because I had to use it multiple times before I got things just the way I wanted them. Since this computer didn’t have any files I didn’t have to worry about backing anything up but it would be a must if considering putting Ubuntu on an everyday machine. To install Ubuntu you need the install CD. Ubuntu community can mail you one if you so request online, but why not be a DIYer and burn it yourself? I downloaded the Ubuntu 9.10 Desktop version for a graphical install and then went straight to burning it onto a CD. This was a mistake. I didn’t figure that the piece of the installation instructions regarding running the checksum was all that important, but it absolutely is. If the download is the least bit wrong the installation will not work. I burned several CDs of a bad image. Eventually I followed the installation documentation more closely and actually downloaded winMd5Sum. With this free tool I was able to compare the checksum of the downloaded image with the correct checksum from the <a href="https://help.ubuntu.com/community/UbuntuHashes" target="_blank">Ubuntu site</a>. It took several attempts and switching to a Canadian mirror before getting a successful download. Finally I could burn it to a disc.</p>
<p><span id="more-1509"></span></p>
<p><strong>Burning the Disc</strong><br />
The download comes as an image with an “.iso” extension. I had never burned an image before so I followed the Ubuntu advice to download the free Infra Recorder. The actual burning of the image to the disc couldn’t have been easier. Following the Ubuntu instructions I quickly had an Ubuntu install disc. I inserted it into my computer and restarted it so it could boot from the disc and headed straight to the install options. Here is where I went wrong for the second time by skipping a small part of the install instructions. Instead of using the “Install” option on the disc I should have first chose, “Check the disc for defects.”  After a few failed installs and a bunch of wasted time, choosing the “Check for defects” option finally revealed that while my download was successful, my burn did not translate to the disc just right. Burning another disc or two finally yielded some successful results.</p>
<p><strong>Installing</strong><br />
There are many ways to install Ubuntu. It can be installed as the sole operating system on the computer, as a virtual OS inside of Windows, or even as a side-by-side dual boot with Windows. I was attempting the latter. When trying to achieve a dual boot installation the hard drive must be partitioned so that each OS can reside in its own territory. With Windows on the machine I first dabbled in the computer management menu to try to clear space for Ubuntu, but then while installing it was difficult to interpret the partitioning. My solution was to reformat the hard drive so that Windows again occupied the whole hard drive and then use the installer disc to set up the partitions. I think this is the best option because you get a very good visual of how your hard drive is split up and you’ll have to go through the setup menu anyway so it saves you time from toiling in a Windows configuration. Other items in the installation process are very easy such as choosing language, naming the computer and setting up a user account. With the install completed, the next time the computer starts there will be a choice to start Ubuntu or Windows which is the whole idea of a dual-booting system.</p>
<p>In Conclusion<br />
Installing Ubuntu, especially in a dual-boot situation, can be a daunting task. Although my experience exemplified Murphy’s Law it is a very do-able process. Looking back, I could have saved a ton of time had I followed the online instructions more carefully and verified the download and burn of the image. Bottom line though is that the instructions and documentation are great resources and there are plenty of forums and YouTube <a href="http://www.youtube.com/results?search_query=how+to+install+ubuntu&amp;aq=f" target="_blank">videos</a> also documenting the process. With the volume of help out there I wouldn’t worry about lacking experience like myself, just jump in, read up and take your time.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2010/05/installing-ubuntu-a-trial-and-error-account/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Musings of a SpringOne 2009 Attendee – Day 4</title>
		<link>http://blogs.sourceallies.com/2010/03/musings-of-a-springone-2009-attendee-%e2%80%93-day-4/</link>
		<comments>http://blogs.sourceallies.com/2010/03/musings-of-a-springone-2009-attendee-%e2%80%93-day-4/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 16:00:53 +0000</pubDate>
		<dc:creator>Sudhakar Ramasamy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Conference]]></category>
		<category><![CDATA[SpringOne]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=535</guid>
		<description><![CDATA[This is the last and final part on my SpringOne 2009 experience. It&#8217;s late catching up to the 3 earlier posts but it&#8217;s here now. This post summarizes the sessions I attended from day 4 and wraps up with a summary of my take aways. If you want to catch up here are the three [...]]]></description>
			<content:encoded><![CDATA[<p>This is the last and final part on my SpringOne 2009 experience. It&#8217;s late catching up to the 3 earlier posts but it&#8217;s here now. This post summarizes the sessions I attended from day 4 and wraps up with a summary of my take aways. If you want to catch up here are the three earlier posts:</p>
<ol>
<li><a href="http://blogs.sourceallies.com/2009/10/musings-of-a-springone-2009-attendee-day-1">Musings of a SpringOne 2009 Attendee Day 1</a></li>
<li><a href="http://blogs.sourceallies.com/2009/10/musings-of-a-springone-2009-attendee-day-2">Musings of a SpringOne 2009 Attendee Day 2</a></li>
<li><a href="http://blogs.sourceallies.com/2009/10/musings-of-a-springone-2009-attendee-day-3">Musings of a SpringOne 2009 Attendee Day 3</a></li>
</ol>
<p>Read on for day 4.</p>
<p><span id="more-535"></span></p>
<h2><a href="http://www.springone2gx.com/conference/new_orleans/2009/10/session?id=15408">OSGi and Groovy Jump Start</a></h2>
<p>The presentation started with a <a href="http://www.youtube.com/watch?v=eTRM5n3khw8">5 minute youtube video</a> preview which I thought was pretty innovative.</p>
<p>The first half was around what is OSGi, some of which I&#8217;ve had experience with. I did pick up on a few key concepts that I didn&#8217;t know i wasn&#8217;t communicating earlier in my own presentations on OSGi.</p>
<p>We covered how a groovy POGO has groovy types in the public API. So if your groovy bundle has the groovylib in it&#8217;s classpath then it has to export the groovy package. Also when using Groovy in OSGi, if possible use POJOs for your applications type system since POGOs force you to expose couple groovy types in the bundle&#8217;s API.</p>
<p>The examples were done using <a href="http://www.gradle.org/">gradle</a> and this was my first live example of using gradle. This is a key benefit of conferences &#8212; being exposed to technologies you may otherwise not have the time to take a peek at.</p>
<p>I liked how the presenter took the path of not making things look complex but rather simplifying the concepts. He did this with concepts such as the  OSGi bundle lifecycle.</p>
<p>Some of the tools covered in this session were:</p>
<ul>
<li>bnd to create a groovy manifest</li>
<li>osgi bundle for gradle uses bnd</li>
<li>junit4osgi</li>
</ul>
<h2><a href="http://www.springone2gx.com/conference/new_orleans/2009/10/session?id=16462">Expand your business with Groovy &#8211; Case Study</a></h2>
<p>This session was a case study on how a monolithic application was extended to provide customizations using groovy. A major customer had approached  HypericQ wanting a custom dashboard.</p>
<p>HypericQ developed a architecture around attach point&#8217;s which are places within the UI where plugins can connect to.</p>
<p>Custom UI was provided by gsp templates for customer specific dashboards.</p>
<p>Groovy templates was used as the templating framework that allowed clients to build their own using GSP  pages.</p>
<p>A Web Services API was provided as part of the core platform that enabled several benefits:<br />
- hqapi command line interaction<br />
- allows integration testing of the application<br />
- embedding a groovy console inside the application<br />
- console gives you a HQL way to query the domain and not worry about the end customers database environment</p>
<p>The talk was an interesting exercise in how a dynamic plugin architecture could be implemented. <a href="http://docs.codehaus.org/display/GROOVY/Groovy+Categories">Groovy categories</a> was heavily used to enable this.</p>
<h2><a href="http://www.springone2gx.com/conference/new_orleans/2009/10/session?id=15779">Re-factoring a Spring Application for SOA using Spring technologies in 40 min</a></h2>
<p>The current focus of SOA is really software architecture. SOA is neither static nor predictable. The architectural pattern of any application must be reflective of the business. SOA is preparing the stuff that is critical to your business to stand the test of time. </p>
<p>Architecture involves the courage to be wrong while minimizing the impact of being wrong. It is about making educated decisions between speed and perfection. The longer it takes to deliver the software the higher the client&#8217;s expectations of that software is.</p>
<p>The foundation of SOA is highly cohesive, loosely coupled modules. One must practice</p>
<ol>
<li>strategy first programming</li>
<li>process life-cycle dynamics</li>
<li>process collaboration</li>
<li>loose coupling promotes a network based architecture over a hierarchical one &#8211; composition over inheritance</li>
</ol>
<p>SOA and OSGi enable embracing change by making versioning a runtime concept.</p>
<p>There is an argument to be made for deploying a process as a whole in BPEL. But what about flexible orchestration via simple messaging. We were given the American football analogy. Each play is scripted, but between plays we need to adjust strategy to meet the overall goal. </p>
<p>Modern event driven architecture was mentioned as a composite process linked together in a linear fashion through the use of rule based pathing.</p>
<p>The second half of this talk was the Spring booking demo from Spring Web Flow project. There are 3 OSGi bundles:</p>
<ol>
<li>war bundle</li>
<li>service bundle</li>
<li>datasource bundle</li>
</ol>
<p>The demo was using STS and it&#8217;s DM Server tooling. The entire development workflow was very seamless with SpringSource having done an awesome job of the tooling.</p>
<p>We saw an example of a transparent failover. So there is a need to take down the primary database for maintenance work without taking the application down. A backup datasource bundle is started and the primary datasource bundle is stopped. The datasource bundle is a simple datasource definition and an osgi service with ranking. Because of a higher rank the backup datasource bundle takes precendence and the primary datasource bundle can be safely stopped. Bundles can also take advantage of filtering besides ranking. </p>
<p>Spring Integration builds on pipes and filters. You can expose OSGi services as pipes. It provides the ability to change the behavior of a modularized application by changing how the modules are hooked up in the XML as opposed to modifying source code or in cases where the source code is not available.</p>
<h2>Conference Wrap Up</h2>
<p>Here are my key take aways:</p>
<ul>
<li>It is time for Grails</li>
<li>Need to investigate Spring Faces</li>
<li><a href="http://www.owasp.org/index.php/Category:OWASP_WebGoat_Project">Webgoat</a></li>
<li>Spring Web Flow</li>
<li>Spring Integration</li>
<li>Spring DM Server</li>
</ul>
<p>Overall it was a very productive conference and I would recommend it for anyone looking to attend it next year.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2010/03/musings-of-a-springone-2009-attendee-%e2%80%93-day-4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

