<?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>Xebia Blog &#187; Andrew Phillips</title>
	<atom:link href="http://blog.xebia.com/author/aphillips/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.xebia.com</link>
	<description>Software development done right!</description>
	<lastBuildDate>Wed, 01 Feb 2012 00:30:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Why Application Release Automation needs a Release and an Operations view</title>
		<link>http://blog.xebia.com/2012/02/01/why-application-release-automation-needs-a-release-and-an-operations-view/</link>
		<comments>http://blog.xebia.com/2012/02/01/why-application-release-automation-needs-a-release-and-an-operations-view/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 00:30:00 +0000</pubDate>
		<dc:creator>Andrew Phillips</dc:creator>
				<category><![CDATA[Continuous Delivery]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Methodology]]></category>
		<category><![CDATA[Middleware]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Xebia Labs]]></category>
		<category><![CDATA[application release automation]]></category>
		<category><![CDATA[continuous delivery]]></category>
		<category><![CDATA[devops]]></category>

	<!-- AutoMeta Start -->
	<category>myapplication</category>
	<category>myapplication</category>
	<category>perspectives</category>
	<category>prod</category>
	<category>devops</category>
	<category>delivery</category>
	<category>owned</category>
	<category>pipeline</category>
	<category>myapplication</category>
	<category>myapplication</category>
	<category>perspectives</category>
	<category>prod</category>
	<category>devops</category>
	<category>delivery</category>
	<category>owned</category>
	<category>pipeline</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/?p=8559</guid>
		<description><![CDATA[As the interface between Development and Operations, Application Release Management1 handles information that is highly relevant to your Release and Operations teams. Selecting an Application Release Automation solution that provides insight and analytics from both perspectives is thus a key component of an effective DevOps strategy. Here, we explain how Deployit&#8216;s Infrastructure and new Release [...]]]></description>
			<content:encoded><![CDATA[<p>As the interface between Development and Operations, Application Release Management<sup>1</sup> handles information that is highly relevant to your Release and Operations teams. Selecting an Application Release Automation solution that provides insight and analytics from <em>both</em> perspectives is thus a key component of an effective DevOps strategy.</p>
<p>Here, we explain how <a href="http://www.xebialabs.com/tour" target="_new">Deployit</a>&#8216;s Infrastructure and new Release Overview features help you achieve this goal.<br />
<span id="more-8559"></span></p>
<h3>Continuous Delivery &#038; the Release Perspective</h3>
<p>In today&#8217;s highly competitive economic environment, the need to bring new features to market quickly, flexibly and reliably is paramount &#8211; a goal that is ultimately the aim of the main IT trends Cloud, Agile and DevOps.</p>
<p>Continuous Delivery &#8211; extending <a href="/2010/10/12/deployment-automation-vs-build-automation/" target="_new">Continuous Integration</a> to  automatically transition applications down the <em>Dev-Test-Acc-Prod</em> delivery pipeline &#8211; is a key component of this strategy. In order to be able to effectively implement this, your ARA solution needs to allow your developers &#8211; or, in larger organisations, release or DevOps teams, to quickly and efficiently answer questions such as:</p>
<ul>
<li><strong>How far is <em>MyApplication</em> down the road to Production?</strong></li>
<li><strong>When will <em>MyApplication</em> take the next step down the road?</strong></li>
<li><strong>What do I still need to do before that next step can be taken<sup>2</sup>?</strong></li>
</ul>
<p><img src="http://blog.xebialabs.com/wp-content/uploads/2012/01/two-perspectives-release1.png" alt="" title="two-perspectives-release" class="aligncenter size-full wp-image-8347" /></p>
<p>Ideally, this dashboard would also allow you to plan <em>MyApplication</em>&#8216;s next step and calculate the estimated go-live data, perhaps even based on an analysis of previews versions of <em>MyApplication</em>.</p>
<h3>(Virtual) Environment Management &#038; the Operations Perspective</h3>
<p>From an Operations point of view, an individual application is only a small part of the picture. Across your <em>Dev-Test-Acc-Prod</em> landscape, you will need to track <em>all</em> applications vying for these environments, to manage potentially conflicting resource requests, plan environment maintenance activities and the like.</p>
<p>Since these environments are often owned and managed by different teams and certainly have varying service levels, you will also want to limit your view to one or a subset of these environments at a time.</p>
<p>Your Operations or DevOps teams need to know:</p>
<ul>
<li><strong>Which application versions are currently deployed to my environment(s), or were deployed at a certain point in time?</strong></li>
<li><strong>Which components do these applications consist of? On which middleware and infrastructure systems are these components deployed?</strong></li>
<li><strong>What are the current values of any properties or settings for these components? Which environment-specific customizations have been applied?</strong></li>
</ul>
<p><img src="http://blog.xebialabs.com/wp-content/uploads/2012/01/two-perspectives-ops1.png" alt="" title="two-perspectives-release" class="aligncenter" /></p>
<p>Cloud and the on-demand environments it enables will eventually replace the rigid <em>Dev-Test-Acc-Prod</em> distinction<sup>3</sup>. Nevertheless, the ability to present an environment-centric view will still be required, since virtual environments will still be owned by different groups or teams. Indeed, such a perspective will be even <em>more</em> important if you want to effectively combat &#8220;virtual sprawl&#8221;.</p>
<p>While the coming generations of &#8220;true&#8221; cloud architectures will hopefully reduce the shared resource conflicts that greatly complicate much of today&#8217;s <em>Dev-Test-Acc-Prod</em> management, databases, legacy systems and external payment providers are not likely to disappear anytime soon.</p>
<p>In fact, Facebook, Twitter and other social elements of your future business services may even <em>increase</em> the number of shared resources you need to manage!</p>
<h3>Incorporating ARA Data in the Service Delivery Picture</h3>
<p>Whilst your ARA solution should be your &#8220;go-to&#8221; platform for answers about how your applications and environments relate, it is equally important to consider when this data might be more effectively embedded in a broader service delivery picture. </p>
<p>For example, your ARA platform is not a good candidate for providing a release calendar, since it is not aware of much of the information that is relevant in this context, such as CAB<sup>4</sup> meeting schedules, business sign-off dates or operational maintenance windows.</p>
<p>It is thus important to ensure that your ARA solution can make its data accessible via APIs such as RSS feeds, iCal calendars and other APIs, to enable effective integrations with the rest of your service delivery tooling.</p>
<h3>Conclusion</h3>
<p>The right Application Release Automation platform gives your Delivery and Operations teams fast, accurate insight into your application environments and delivery pipeline. </p>
<p>Choosing a solution like <a href="http://www.xebialabs.com/tour" target="_new">Deployit</a> with focused Operations and Delivery overviews as well as open APIs for easy integration into your overall Service Delivery dashboards and reports greatly enhances the accessibility and effectiveness of your application release management.</p>
<div style="background-color: #efeeea; border: 1px solid #AAAAAA; margin: 0.8em; padding: 0.4em; font-size: 85%;"><strong>Footnotes</strong></p>
<ol>
<li>a.k.a. <em>Deployment Automation</em> &#8211; choose your favourite <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
<li>For instance, certain blocking release conditions, such as test sign-off, may still need to be met.</li>
<li>and have long done so in many forward-looking organisations</li>
<li><a href="http://en.wikipedia.org/wiki/Change_Advisory_Board" target="_new"><strong>C</strong>hange <strong>A</strong>dvisory <strong>B</strong>oard</a></li>
</ol>
</div>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2012/02/01/why-application-release-automation-needs-a-release-and-an-operations-view/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2012%2F02%2F01%2Fwhy-application-release-automation-needs-a-release-and-an-operations-view%2F&amp;title=Why%20Application%20Release%20Automation%20needs%20a%20Release%20%3Cem%3Eand%3C%2Fem%3E%20an%20Operations%20view" id="wpa2a_2"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2012/02/01/why-application-release-automation-needs-a-release-and-an-operations-view/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Taking Application Release Automation to the Next Level</title>
		<link>http://blog.xebia.com/2011/11/29/taking-application-release-automation-to-the-next-level/</link>
		<comments>http://blog.xebia.com/2011/11/29/taking-application-release-automation-to-the-next-level/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 18:54:29 +0000</pubDate>
		<dc:creator>Andrew Phillips</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Middleware]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Xebia Labs]]></category>
		<category><![CDATA[application release automation]]></category>
		<category><![CDATA[continuous deployment]]></category>
		<category><![CDATA[deployment automation]]></category>

	<!-- AutoMeta Start -->
	<category>standardisation</category>
	<category>outs</category>
	<category>intelligence</category>
	<category>adopters</category>
	<category>generation</category>
	<category>standardisation</category>
	<category>outs</category>
	<category>intelligence</category>
	<category>adopters</category>
	<category>generation</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/?p=8147</guid>
		<description><![CDATA[Whether the driver is Agile, Cloud or DevOps1, or a &#8220;plain old&#8221; efficiency drive or process improvement initiative, forward-thinking organisations are currently looking for ways to improve their application release processes through automation. In an area where manual activities are still all too common, it&#8217;s unsurprising that the initial focus has been on automating the [...]]]></description>
			<content:encoded><![CDATA[<p>Whether the driver is Agile, Cloud or DevOps<sup>1</sup>, or a &#8220;plain old&#8221; efficiency drive or process improvement initiative, forward-thinking organisations are currently looking for ways to improve their application release processes through automation. In an area where manual activities are still all too common, it&#8217;s unsurprising that the initial focus has been on automating the deployment <em>execution</em> &#8211; moving all the bits to the right places.</p>
<p>What early adopters have learnt is that, at the enterprise scale, automating release execution quickly introduces a new bottleneck in today&#8217;s dynamic IT environments: continuous management of the deployment plan definition. A new generation of application release automation (ARA) tooling avoids this pitfall by leveraging intelligence to automate deployment <em>planning</em> as well as execution.<br />
<span id="more-8147"></span></p>
<h3>The State of ARA</h3>
<div style="padding: 5px; float: right;">
<img src="http://blog.xebialabs.com/wp-content/uploads/2011/11/ara_next_level-11.jpg" alt="" title="ara_next_level-1" width="200" height="159" class="alignnone size-full wp-image-6003" />
</div>
<p>Given how strongly our IT industry is dedicated to the automation of processes, it is nothing short of amazing how much of the deployment of <em>our own solutions</em> depends on manual actions coordinated more or less effectively between large groups of people.<br />
Indeed, a recent analyst report noted that the majority of large enterprises were still relying on manual application release processes or on in-house scripting understood by only a small number of specialists, operated as a black box that &#8211; hopefully &#8211; will do its job and will most likely necessitate a painful troubleshooting session if it doesn&#8217;t.</p>
<p>With key IT trends such as Agile, Cloud and DevOps dramatically ramping up the frequency of application releases in order to increase responsiveness to business needs and provide more and better services to customers, it&#8217;s clear that this situation cannot continue. </p>
<p>Thinking of today&#8217;s common release processes, it is also hardly surprising that the initial drive has been to automate the actual <a href="http://blog.xebialabs.com/2010/12/20/deployment-automation-vs-server-provisioning/" target="_new">rollout of the application</a> itself: copying the files to the target machines, restarting the servers, running the SQL against the DB etc. Using a defined workflow to organise these activities makes lots of sense: fewer failures, no more missing steps or steps executed in the wrong order, no more typos, better visualization etc.</p>
<h3>Lessons from the First Generation</h3>
<div style="padding: 5px; float: right;">
<img src="http://blog.xebialabs.com/wp-content/uploads/2011/11/ara_next_level-2.png" alt="" title="ara_next_level-2" width="200" height="143" class="alignnone size-full wp-image-6001" />
</div>
<p>Ironically, using one of these first generation ARA tools at an enterprise scale quickly made it obvious to early adopters how much effort is required to maintain the substantial number of workflow definitions that quickly accumulate to support full deployments, partial upgrades, rollbacks, environment scale-outs etc. across an enterprise application portfolio.</p>
<p>Of course, this is not a new challenge: ask anyone who has had to update 100 build job definitions in a continuous integration tool to change a compilation parameter, or 100 test plans in an automated testing setup to accommodate a different target browser, just how time-consuming and error-prone this type of maintenance is.</p>
<p>It&#8217;s not as though these modifications are <em>unique per process</em>. They tend to be <u>systematic</u> changes that reflect changes to the overall deployment strategy and/or context. The issue is that these first-generation tools, where all the deployment <em>intelligence</em> is stored in the power user&#8217;s brain, simply do not have enough internal <em>knowledge</em> of the structure of deployment to assist effectively.</p>
<h3>The Next Level of Application Release Automation</h3>
<div style="padding: 5px; float: right;">
<img src="http://blog.xebialabs.com/wp-content/uploads/2011/11/ara_next_level-3.jpg" alt="" title="ara_next_level-3" width="200" height="189" class="alignnone size-full wp-image-6004" />
</div>
<p>A new generation of Application Release Automation includes this intelligence. These advanced tools<sup>2</sup> no longer require hand-holding by your power users every step of the way, and encode knowledge of deployment best practices and strategies to automate the planning <em>and</em> execution of deployments.<sup>3</sup></p>
<p>No pre-provided strategy can be a 100% fit in an enterprise environment, so the strategies must be configurable, of course. Once your power users have fine-tuned them, however, all the individual deployment plans &#8211; initial installations, full and partial upgrades, downgrades, undeployments, scale-outs etc&#8230;easily hundreds across an application portfolio &#8211; are automatically tailored to your scenario.</p>
<p>This becomes even more efficient the fewer deployment strategies are in play, so these tools also motivate and reward increased standardisation of deployment procedures, in itself a valuable business goal. In fact, with a suitable interface and integrations into the development pipeline you essentially have an enterprise <a href="http://en.wikipedia.org/wiki/Cloud_computing#Platform" target="_new">Platform as a Service</a>, potentially on a private or hybrid cloud.</p>
<h3>Conclusions</h3>
<p>With adoption of Application Release Automation rapidly on the increase, a new generation of solutions are appearing that automate deployment planning as well as execution.<br />
Based on the challenges experienced in scaling the first generation of ARA tools to enterprise levels, these next generation solutions are designed to eliminate &#8220;continuous expert hand-holding&#8221;, promote standardisation and allow organisations to create a &#8220;software factory&#8221; that continuously delivers business value.</p>
<div style="background-color: #efeeea; border: 1px solid #AAAAAA; margin: 0.8em; padding: 0.4em; font-size: 85%;"><strong>Footnotes</strong></p>
<ol>
<li>My spelling preference is <u>still</u> for &#8220;Devops&#8221; since the whole point is, after all, that Dev and Ops are <em>no longer</em> regarded as separate, but hey&#8230; <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
<li>like XebiaLabs&#8217; <a href="http://www.xebialabs.com/tour" target="_new">Deployit</a></li>
<li><a href="http://blog.xebialabs.com/2011/05/03/deployment-is-the-new-build-part-1/" target="_new">This advance</a> closely mirrors the development of build frameworks from tools like <a href="https://ant.apache.org/" target="_new">Ant</a> to today&#8217;s industry standards like <a href="https://maven.apache.org/" target="_new">Maven</a> and on to the next generation of <a href="http://www.gradle.org/" target="_new">Gradle</a>, <a href="https://github.com/harrah/xsbt/wiki/" target="_new">SBT</a> and others.</li>
</ol>
</div>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2011/11/29/taking-application-release-automation-to-the-next-level/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2011%2F11%2F29%2Ftaking-application-release-automation-to-the-next-level%2F&amp;title=Taking%20Application%20Release%20Automation%20to%20the%20Next%20Level" id="wpa2a_4"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2011/11/29/taking-application-release-automation-to-the-next-level/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Release Automation: The Missing Step in Release Management</title>
		<link>http://blog.xebia.com/2011/08/03/release-automation-the-missing-step-in-release-management/</link>
		<comments>http://blog.xebia.com/2011/08/03/release-automation-the-missing-step-in-release-management/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 05:31:10 +0000</pubDate>
		<dc:creator>Andrew Phillips</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Xebia Labs]]></category>
		<category><![CDATA[release automation]]></category>
		<category><![CDATA[release management]]></category>

	<!-- AutoMeta Start -->
	<category>8230</category>
	<category>industries</category>
	<category>release</category>
	<category>automation</category>
	<category>critical</category>
	<category>considerations</category>
	<category>scalability</category>
	<category>outline</category>
	<category>8230</category>
	<category>industries</category>
	<category>release</category>
	<category>automation</category>
	<category>critical</category>
	<category>considerations</category>
	<category>scalability</category>
	<category>outline</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/?p=7243</guid>
		<description><![CDATA[Across all industries, the services delivered by business applications have become an essential part of an enterprise&#8217;s customer offering. Bringing new features to market quickly is thus a critical factor in determining a company&#8217;s success. In this post (an extended version of which is available as a whitepaper), we will outline today&#8217;s Release Management challenges [...]]]></description>
			<content:encoded><![CDATA[<p>Across all industries, the services delivered by business applications have become an essential part of an enterprise&#8217;s customer offering. Bringing new features to market quickly is thus a critical factor in determining a company&#8217;s success.</p>
<p>In this post (an extended version of which is <a href="http://www.xebialabs.com/DeploymentAutomation_Whitepaper" target="_new">available as a whitepaper</a>), we will outline today&#8217;s Release Management challenges and discuss the need for Release Automation. </p>
<p>We&#8217;ll identify key considerations for successful solutions and highlight why &#8220;Zero-Maintenance&#8221; is a critical requirement for Release Automation that provides the scalability required in an agile landscape and enables the delivery of continuous business value.</p>
<p><a href="http://blog.xebialabs.com/2011/08/03/release-automation-the-missing-step-in-release-management/" class="more-link">(more&#8230;)</a></p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2011/08/03/release-automation-the-missing-step-in-release-management/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2011%2F08%2F03%2Frelease-automation-the-missing-step-in-release-management%2F&amp;title=Release%20Automation%3A%20The%20Missing%20Step%20in%20Release%20Management" id="wpa2a_6"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2011/08/03/release-automation-the-missing-step-in-release-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integration testing CloudBees&#8217; RUN@cloud</title>
		<link>http://blog.xebia.com/2011/08/03/integration-testing-cloudbees-runcloud/</link>
		<comments>http://blog.xebia.com/2011/08/03/integration-testing-cloudbees-runcloud/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 05:30:50 +0000</pubDate>
		<dc:creator>Andrew Phillips</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Google AppEngine]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Middleware]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[jclouds]]></category>

	<!-- AutoMeta Start -->
	<category>tweetstore</category>
	<category>cloudbees</category>
	<category>cloudbees</category>
	<category>jclouds</category>
	<category>idletimer</category>
	<category>staxsdkappserver</category>
	<category>googledevserver</category>
	<category>timer</category>
	<category>tweetstore</category>
	<category>cloudbees</category>
	<category>cloudbees</category>
	<category>jclouds</category>
	<category>idletimer</category>
	<category>staxsdkappserver</category>
	<category>googledevserver</category>
	<category>timer</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/?p=7040</guid>
		<description><![CDATA[As part of the preparations for the recent 1.0.0 release of jclouds, I was tidying up the existing Tweetstore demo application as well as porting it to CloudBees&#8217; Tomcat-based RUN@cloud platform. A key part of the test harness for the original versions of Tweetstore that run on the Google App Engine is the neat GoogleDevServer [...]]]></description>
			<content:encoded><![CDATA[<p>As part of the preparations for the recent <a href="http://anyweight.blogspot.com/2011/06/jclouds-100-is-out.html" target="_new">1.0.0 release</a> of <a href="http://www.jclouds.org/" target="_new">jclouds</a>, I was tidying up the existing <a href="http://anyweight.blogspot.com/2009/10/save-your-tweets-forever-with-jclouds.html" target="_new">Tweetstore</a> demo application as well as <a href="http://tweetstore.jclouds.cloudbees.net" target="_new">porting it</a> to CloudBees&#8217; Tomcat-based <a href="http://www.cloudbees.com/run.cb" target="_new">RUN@cloud</a> platform.</p>
<p>A key part of the test harness for the <a href="https://jclouds-tweetstore.appspot.com/" target="_new">original</a> <a href="https://jclouds-tweetstore-spring.appspot.com/" target="_new">versions</a> of Tweetstore that run on the <a href="https://code.google.com/appengine/docs/whatisgoogleappengine.html" target="_new">Google App Engine</a> is the neat <a href="https://github.com/jclouds/jclouds/blob/master/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java" target="_new">GoogleDevServer</a> class. Basically, it&#8217;s a clever wrapper around the <tt>KickStart</tt> class used under the covers by the <a href="https://code.google.com/appengine/downloads.html#Google_App_Engine_SDK_for_Java" target="_new">GAE SDK tools</a> that allows you to specify the SDK location, address, port and WAR file (or expanded WAR directory) to run.<br />
Better still, it can programmatically be shut down cleanly, making it ideal for integration test runs<sup>1</sup>.</p>
<p>For CloudBees, I was thus looking to put together a similar <a href="https://github.com/jclouds/jclouds/blob/master/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/RunAtCloudServer.java" target="_new">RunAtCloudServer</a>. It proved more challenging than expected&#8230;<sup>2</sup><br />
<span id="more-7040"></span></p>
<h3>Just spawn a container already?</h3>
<p>Both the <a href="http://www.kindleit.net/maven_gae_plugin/" target="_new">maven-gae-plugin</a> and the <a href="https://cloudbees.zendesk.com/entries/421064-maven-guide" target="_new">bees-maven-plugin</a> allow you to spawn a local GAE or RUN@cloud server simulation, of course. These can easily be integrated into your Maven build, for instance as part of your <tt>pre-integration-test</tt> setup. So why not just stick with that?</p>
<p>Well, for some scenarios that can be perfectly sufficient. For Tweetstore, having an inline server that cleanly shuts down allows us to:</p>
<ul>
<li>run integration tests alongside unit tests from an IDE without having to remember to start an external process</li>
<li>debug the application running in the server on demand, without having to mess with remote debuggers or figure out a way to <em>sometimes</em> get the Maven plugins to start in debug mode</li>
<li>work some conditional magic with the server arguments</li>
</ul>
<p>If your project&#8217;s requirements are similar, an inline server might be a good option. And luckily, the code&#8217;s already been written!</p>
<h3>Hangin&#8217; around</h3>
<div style="padding: 5px; float: right;"><img src="http://blog.xebia.com/wp-content/uploads/2011/06/zombies.png" alt="" title="zombies" width="266" height="173" class="alignnone size-full wp-image-7044" /></div>
<p>The <a href="https://cloudbees.zendesk.com/entries/414109-cloudbees-sdk" target="_new">RUN@cloud SDK&#8217;s</a> version of <tt>KickStart</tt> is the <tt>StaxSdkAppServer</tt><sup>3</sup>. Figuring out the correct arguments for the <tt>launchServer</tt> factory method wasn&#8217;t too hard, so I hooked up a <tt>StaxSdkAppServer</tt> and kicked off the test. </p>
<p>Started like a charm! Then the test finished and&#8230;just hung on in there. Over in the trusty debugger<sup>4</sup>, I could see not one, but <em>two</em> zombie threads still running. The design was based on a &#8220;shutdown-by-JVM-kill&#8221; scenario, I guess.</p>
<h3>Assassins and other Ninja Tricks</h3>
<p>The first of the two threads is a <a href="http://download.oracle.com/javase/6/docs/api/java/util/Timer.html" target="_new">Timer</a> that something called the <tt>WebAppEngine</tt> uses to do&#8230;well, who knows? In any case, we can get a reference to it with a decent handful of reflection and <a href="http://download.oracle.com/javase/6/docs/api/java/util/Timer.html#cancel()" target="_new">cancel</a> it. Easy enough.</p>
<p>Our remaining zombie is a bit more elusive, unfortunately. It&#8217;s a thread spawned by an instance of the <tt>RequestMonitorValve</tt> class in a manner analogous to</p>
<pre class="brush: java; title: ; notranslate">
new Thread(idleTimer, &quot;requestMonitor&quot;).start();
</pre>
<p>So no reference, and no way of interrupting it. However, the <tt>idleTimer</tt> <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Runnable.html" target="_new">Runnable</a> <em>is</em> referenced <em><u>and</u></em> repeatedly calls a handler as part of its execution. How about injecting a handler that throws an exception to end the thread?</p>
<p>Nice idea, but it turns out the thread really doesn&#8217;t want to die that way:</p>
<pre class="brush: java; title: ; notranslate">
while(true) {
    try {
        // do stuff
        if(callbackClient != null)
            callbackClient.updateStatus(state);
    } catch(Exception e) {
        // increment some error counters
    }

    try {
        Thread.sleep(statusIntervalSecs * 1000);
    } catch(InterruptedException interruptedexception) { }
}
</pre>
<p>So I&#8217;ve had to go one better and throw a <a href="http://download.oracle.com/javase/6/docs/api/java/lang/ThreadDeath.html" target="_new">ThreadDeath</a> <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Error.html" target="_new">error</a> instead. Urgh.</p>
<h3>Now you see it, now you don&#8217;t?</h3>
<p>The remaining gotcha involves injecting the catchily-named <tt>KillerCallback</tt> into the <tt>idleTimer</tt>. Even using reflection, this is a elementary concurrency failure because without a <a href="http://java.sun.com/docs/books/jls/third_edition/html/memory.html#64058" target="_new">synchronized-with relationship</a><sup>5</sup> between injecting the new handler and invocation of the handler by <tt>idleTimer</tt>, there is no guarantee the new handler will actually be visible to the thread we&#8217;re trying to stop.</p>
<p>Such a relationship <em>could</em> be established if the &#8220;assassin&#8221; was injected <em>before</em> the thread that runs <tt>idleTimer</tt> starts. Unless we want to override library classes, that would mean setting it after creating but before starting the <tt>StaxSdkAppServer</tt><sup>6</sup>&#8230;which unfortunately doesn&#8217;t work either because the instances referencing <tt>idleTimer</tt> are only created when the server starts.</p>
<h3>So?</h3>
<p>So, for now the potential concurrency issue is documented and we hope for the best <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  No problems observered so far&#8230;</p>
<div style="background-color: #EFEEEA; border: 1px solid #AAAAAA; margin: 0.8em; padding: 0.4em; font-size: 85%;">
<strong>Footnotes</strong></p>
<ol>
<li>The <a href="http://www.kindleit.net/maven_gae_plugin/" target="_new">maven-gae-plugin</a> is another nice option for <em>starting</em> the SDK&#8217;s local GAE simulation. The advantage of <tt>GoogleDevServer</tt> is that it also <em>stops</em> cleanly, can be run from your IDE and also allows you to add additional files to the WAR before starting. Tweetstore uses that to include login credentials to various cloud storage providers &#8211; not the kind of thing you&#8217;re likely to want to store in Github <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
<li>but see <a href="http://www.youtube.com/watch?v=cKO0RrM7LvI" target="_new"><strong>here</strong></a></li>
<li>CloudBees <a href="http://www.cloudbees.com/acquisitions/stax/" target="_new">acquired Stax</a> in December 2010</li>
<li><em>This</em> is when being able to run from an IDE really comes into its own!</li>
<li>as provided e.g. by <strong><tt>volatile</tt></strong></li>
<li>Actually, the code uses an almost exact clone called <a href="https://github.com/jclouds/jclouds/blob/master/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/StaxSdkAppServer2.java" target="_new">StaxSdkAppServer2</a> that simply splits creating the server instance from starting it.</li>
</ol>
</div>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2011/08/03/integration-testing-cloudbees-runcloud/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2011%2F08%2F03%2Fintegration-testing-cloudbees-runcloud%2F&amp;title=Integration%20testing%20CloudBees%26%238217%3B%20RUN%40cloud" id="wpa2a_8"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2011/08/03/integration-testing-cloudbees-runcloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jar-with-deps don&#8217;t like META-INF/services</title>
		<link>http://blog.xebia.com/2011/07/20/jar-with-deps-dont-like-meta-infservices/</link>
		<comments>http://blog.xebia.com/2011/07/20/jar-with-deps-dont-like-meta-infservices/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 11:33:45 +0000</pubDate>
		<dc:creator>Andrew Phillips</dc:creator>
				<category><![CDATA[Build tools]]></category>
		<category><![CDATA[Gradle]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Xebia Labs]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[spi]]></category>

	<!-- AutoMeta Start -->
	<category>deps</category>
	<category>mergedir</category>
	<category>gradle</category>
	<category>truezip</category>
	<category>truezip</category>
	<category>checker</category>
	<category>overthere</category>
	<category>runtimedeps</category>
	<category>deps</category>
	<category>mergedir</category>
	<category>gradle</category>
	<category>truezip</category>
	<category>truezip</category>
	<category>checker</category>
	<category>overthere</category>
	<category>runtimedeps</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/?p=7218</guid>
		<description><![CDATA[Recently, I was preparing a connection checker for Deployit&#8217;s powerful remote execution framework Overthere. To make the checker, as compact as possible, I put together a jar-with-deps1 for distribution. Tests and trial runs from the IDE worked, so I was expected the dry-run of the distribution to be a quick formality. Instead: boom! Turns out [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I was preparing a <a href="https://github.com/demobox/overthere-connection-checker/" target="_new">connection checker</a> for <a href="http://www.xebialabs.com/tour" target="_new">Deployit&#8217;s</a> powerful remote execution framework <a href="https://github.com/xebialabs/overthere" target="_new">Overthere</a>. To make the checker, as compact as possible, I put together a <a href="http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#jar-with-dependencies" target="_new">jar-with-deps</a><sup>1</sup> for distribution.<br />
Tests and trial runs from the IDE worked, so I was expected the dry-run of the distribution to be a quick formality. Instead: <em>boom!</em><br />
Turns out that one of the libraries used by Overthere, <a href="http://truezip.java.net/" target="_new">TrueZIP</a> &#8211; or indeed any code that utilizes Java&#8217;s <a href="http://download.oracle.com/javase/6/docs/technotes/guides/jar/jar.html#Service%20Provider" target="_new">SPI mechanism</a><sup>2</sup> &#8211; doesn&#8217;t play well with the <em>jar-with-deps</em> idea.<span id="more-7218"></span></p>
<h3>Seeing Double</h3>
<p>TrueZIP uses a <tt>de.schlichtherle.truezip.fs.spi.FsDriverService</tt> provider configuration file in <tt>META-INF/services</tt> to register drivers for various archive formats, and the checker was failing because one of the required drivers wasn&#8217;t being loaded, even though the code was correctly included in the <em>jar-with-deps</em>.</p>
<p>The <tt>duplicate</tt> option of Ant&#8217;s <a href="http://ant.apache.org/manual/Tasks/jar.html" target="_new">Jar task</a><sup>3</sup> and Gradle issue <a href="http://issues.gradle.org/browse/GRADLE-1050" target="_new">1050</a>, which talks about merging files during archive creation, hint at what the problem is: once packaged up in a single <em>jar-with-deps</em> archive, only one of TrueZIP&#8217;s provider configuration files was being found.</p>
<h3>Maven, Gradle and Java</h3>
<p>Once I examined the <em>jar-with-deps</em> <a href="https://github.com/demobox/jar-with-deps-vs-spi/blob/master/pom.xml" target="_new">constructed by Maven</a><sup>4</sup>, it was pretty clear why: the JAR only <em>contains</em> one of the configuration files &#8211; looks like the first one encountered in my case, but that may be non-deterministic. Presumably, this happens because Maven uses a temporary directory to prepare the archive contents, which of course can&#8217;t hold multiple files of the same name.</p>
<p><a href="https://github.com/demobox/jar-with-deps-vs-spi/blob/master/build.gradle" target="_new">With Gradle</a><sup>5</sup>, things are a bit more interesting because the archive does indeed contain all the configuration files &#8211; the ZIP format supports duplicate entries<sup>6</sup>. However, <a href="http://download.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html#getResources(java.lang.String)" target="_new">ClassLoader.getResources</a> doesn&#8217;t play along, so again only one entry is found.</p>
<h3>There Can Be Only One</h3>
<p>Basically, it seems that merging the affected files is the only feasible way around this. Here&#8217;s a possible Gradle snippet<sup>7</sup>:</p>
<pre class="brush: groovy; title: ; notranslate">
task jarWithDeps(type: Jar, dependsOn: classes) {
	mergeDir = &quot;${buildDir}/merge&quot;
	// might need a lazy var in a multi-module project where deps are inherited
	runtimeDeps = configurations.runtime.collect { zipTree(it) }

	doFirst {
		new File(mergeDir).delete()
		mergeFiles(mergeDir, runtimeDeps, file-to-merge)
		// ... possibly other files too
	}

	// this project's classes and all deps
	from sourceSets*.classesDir
	from(runtimeDeps) {
		exclude file-to-merge
	}
	from mergeDir
}

private def mergeFiles(targetDir, fileTrees, relativePath) {
  // prepare the merge
  mergedFile = new File(&quot;${targetDir}/${relativePath}&quot;)
  new File(mergedFile.parent).mkdirs()

  fileTrees*.matching({ include &quot;**/${relativePath}&quot; })*.each {
    mergedFile &lt;&lt; it.bytes
  }
}
</pre>
<p>Unfortunately, I haven&#8217;t been able to find a similar option for the <a href="http://maven.apache.org/shared/maven-archiver/" target="_new">Maven Archiver</a>, but I guess there must be <em>something</em> out there in the Maven ecosystem <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><em>Edited 21/07/2011 to add:</em> The <a href="https://github.com/demobox/jar-with-deps-vs-spi/" target="_new">sample code</a> now includes possible solutions suggested in comments. Run <tt>gradle clean jarWithDeps2</tt>, <tt>mvn clean package -Pwith-shade-plugin</tt> or <tt>mvn clean package -Pwith-keystone-plugin</tt><sup>8</sup> to try them out.<br />
<em>Edited 25/07/2011 to add:</em> You can now also run <tt>mvn clean package -Pwith-services-handler</tt> to see how the Assembly plugin&#8217;s <a href="http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#class_containerDescriptorHandler" target="_new"><tt>&lt;containerDescriptorHandlers&gt;</tt></a> can take care of this too.</p>
<div style="background-color: #EFEEEA; border: 1px solid #AAAAAA; margin: 0.8em; padding: 0.4em; font-size: 85%;">
<strong>Footnotes</strong></p>
<ol>
<li>A.k.a. &#8220;farJar&#8221;. For an equivalent Gradle task definition, see <a href="http://docs.codehaus.org/display/GRADLE/Cookbook#Cookbook-Creatingafatjar" target="_new">here</a>.</li>
<li>See <a href="http://blog.xebia.com/2011/02/multispi-consuming-service-provider-interfaces-in-2011/" target="_new">MultiSPI</a> for an approach that provides more flexibility and &#8220;modern alternatives&#8221; for service providers.</li>
<li>Note that the <a href="http://download.oracle.com/javase/6/docs/technotes/tools/solaris/jar.html#options" target="_new">jar utility</a> itself <em>doesn&#8217;t</em> provide a similar option.</li>
<li>run <tt>mvn clean package</tt></li>
<li>run <tt>gradle clean jarWithDeps</tt></li>
<li>although the <a href="http://download.oracle.com/javase/6/docs/api/java/util/zip/ZipOutputStream.html" target="_new">ZipOutputStream</a> evidently wasn&#8217;t <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4406823" target="_new">too happy</a> with them and, judging by the 1.6.0_20 implementation, will still throw a <tt>ZipException</tt></li>
<li>Would be interesting to try to do the merging at JAR construction time, perhaps by keeping &#8220;merge-so-far(s)&#8221; in the <tt>mergeDir</tt> and using <a href="http://www.gradle.org/current/docs/dsl/org.gradle.api.tasks.bundling.Jar.html#org.gradle.api.tasks.bundling.Jar:eachFile%28groovy.lang.Closure%29" target="_new"><tt>eachFile</tt></a> to replace the unmerged files and update the &#8220;merge-so-far(s)&#8221; at the same time.</li>
<li>required <a href="http://pastebin.com/QNhkX6TE" target="_new">two fixes</a> to the code to get it work correctly on my system</li>
</ol>
</div>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2011/07/20/jar-with-deps-dont-like-meta-infservices/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2011%2F07%2F20%2Fjar-with-deps-dont-like-meta-infservices%2F&amp;title=jar-with-deps%20don%26%238217%3Bt%20like%20META-INF%2Fservices" id="wpa2a_10"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2011/07/20/jar-with-deps-dont-like-meta-infservices/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Deployment is the new build (part 3)</title>
		<link>http://blog.xebia.com/2011/06/16/deployment-is-the-new-build-part-3/</link>
		<comments>http://blog.xebia.com/2011/06/16/deployment-is-the-new-build-part-3/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 21:08:08 +0000</pubDate>
		<dc:creator>Andrew Phillips</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Xebia Labs]]></category>
		<category><![CDATA[devops]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/?p=6872</guid>
		<description><![CDATA[Earlier this year, I was invited to present a talk at Devopsdays Boston about deployment as the new build: how deployments are carried out now, how they will need to adapt in a more virtualized, on-demand application landscape and what fundamental improvements will need to come before deployment matures into the invisible, it just works&#8482; [...]]]></description>
			<content:encoded><![CDATA[<p><em>Earlier this year, I was invited to present a <a href="http://www.devopsdays.org/events/2011-boston/proposals/deployment_is_the_new_build/" target="_new">talk</a> at <a href="http://www.devopsdays.org/events/2011-boston/" target="_new">Devopsdays Boston</a> about </em><a href="http://www.slideshare.net/apwashere/deployment-is-the-new-build" target="_new">deployment as the new build</a><em>: how deployments are carried out now, how they will need to adapt in a more virtualized, on-demand application landscape and what fundamental improvements will need to come before deployment matures into the invisible, </em>it just works&trade;<em> experience build is today.</em></p>
<p>In the <a href="http://blog.xebia.com/2011/05/deployment-is-the-new-build-part-2/" target="_new">previous post</a>, we looked at how <em>Reusable commands</em>, <em>Models</em> and <em>Conventions++</em> helped turn build from a “black box” process into the “just works” experience we know today. </p>
<p>We then shifted back to deployment and identified <em>Develop a common model</em>, <em>(Re)discover vanilla</em> and <em>Support a &#8220;clean build&#8221;</em> as three key steps required to achieve a similar transition.<br />
<span id="more-6872"></span></p>
<h3>Develop a common model</h3>
<div style="padding: 5px; float: right;"><img src="http://blog.xebia.com/wp-content/uploads/2011/05/deployment-is-the-new-build-p3-1.png" alt="" title="deployment-is-the-new-build-p3-1" width="300" height="225" class="alignnone size-full wp-image-6954" /></div>
<p>Before we can advance to the &#8216;model&#8217; stage, we first&#8230;well&#8230;need a model. Thankfully, a very simple one can suffice: <strong>Packages</strong>, <strong>Environments</strong> and <strong>Deployments</strong>. </p>
<p>There&#8217;s nothing particularly magical to this, and indeed the concepts are commonly found in most organisations. But giving these things explicit labels helps not just formalize the ideas and gives developers and vendors something to support. It also creates a shared vocabulary and language around deployment, which is the first step to shared understanding and reusable functionality.</p>
<p>Indeed, the concepts are so basic that there does not appear to be much to say about them.</p>
<p><strong>Packages</strong> capture the components of the versioned item to be released, both artifacts represented by actual files as well as configuration, resource settings and metadata.</p>
<p>In accordance with release management best practice, packages should be stored in a <a href="http://en.wikipedia.org/wiki/Information_Technology_Infrastructure_Library#Software_Asset_Management" target="_new">DSL</a> and should be independent of the target environment, so that you have one &#8220;gold standard&#8221; package running in Development, Test, QA and Production. </p>
<p>Packages also mean that we can version everything, not just the application binaries but also the related configuration and environment settings.</p>
<p>Development and Test just mentioned are examples of <strong>Environments</strong>, simply collections of infrastructure &#8211; physical, virtual, long-running, on-demand, whatever &#8211; that applications run in as they progress through the <a href="http://en.wikipedia.org/wiki/Software_development_process#Deployment_and_maintenance" target="_new">ALM cycle</a>, potentially with approvals or other checkpoints governing the transition from one to the next.</p>
<p><strong>Deployment</strong>, then, is perhaps the one concept not immediately widely understood. A Deployment represents not just the activity of getting a Package running in a certain Environment, with a start and stop time, executing user, status and so forth. </p>
<p>Rather, a Deployment also documents the way in which the Package&#8217;s components have been deployed and, if applicable, customized. For instance, a Deployment will record that a certain EAR file in the package has been deployed to the following target server(s) or cluster(s), or that the data source password for this specific environment has been customized and set to a new value.</p>
<p>Recording this information is critical because it is very hard to be able to intelligently and correctly modify an application&#8217;s state &#8211; when upgrading to a new version, for instance, or adding new servers to the target cluster &#8211; if you do not know where and with which settings the application is currently running.</p>
<h3>(Re)discover vanilla</h3>
<div style="padding: 5px; float: right;"><img src="http://blog.xebia.com/wp-content/uploads/2011/05/deployment-is-the-new-build-p3-2.png" alt="" title="deployment-is-the-new-build-p3-2" width="301" height="200" class="alignnone size-full wp-image-6955" /></div>
<p>If we are going to achieve hassle-free, push-button deployments, another thing we will have to reconsider is whether we really need to tweak and customize our infrastructure in every way possible. Indeed, some companies seem to almost have a policy that any setting that might be a default should be regarded with suspicion and, preferably, changed.</p>
<p>Much as custom project layouts made setting up a build unnecessarily tedious and complicated in a convention- and model-based system, stubbornly refusing to go with infrastructure defaults will make it harder to get hassle-free deployments that truly cover all the steps required.</p>
<p>Sticking with defaults not only encourages reusability because the chances are much higher that a solution developed for a different scenario will also work in yours. It also improves maintainability and cuts down on the risk of &#8220;ripple&#8221; changes, where a custom value in the setting for the servers hosting application X requires further changes to the setup of application Y etc.</p>
<h3>Support a &#8220;clean build&#8221;</h3>
<div style="padding: 5px; float: right;"><img src="http://blog.xebia.com/wp-content/uploads/2011/05/deployment-is-the-new-build-p3-3.png" alt="" title="deployment-is-the-new-build-p3-3" width="298" height="208" class="alignnone size-full wp-image-6956" /></div>
<p>When building a large project, we try to cut down on the time taken by recompiling only the source code that has been modifying. When deploying applications, we similarly want to save time when upgrading to a new version, especially when this time represents production downtime.<br />
However, we also know that, eventually, some parts of any incremental build will end up going out of sync, causing strange compilation problems, or features or fixes not appearing when they should.</p>
<p>What do we do in such a case? Do we laboriously try to track down the files that are out of sync and rebuild piece by piece? No, we simply run a clean build to start from scratch, because in 99% of cases it&#8217;s much quicker to simply rebuild than try to track down the cause of the problem.</p>
<p>In deployment-land, we seldom have the ability to clean build, and this is one of the main causes for the stressful, time- and resource-consuming troubleshooting hunts that are still far too common. Of course, in order to clean build a system we need full versioning of the environment, its configuration and the applications deployed to it. Virtual appliances and virtualization solutions with snapshot capabilities will have a major role to play here.</p>
<p>We also need a known state for durable resources such as databases, which remains challenging but is being addressed by a growing number of products out there. </p>
<h3>Push button deployments</h3>
<p>Taking stock, it&#8217;s clear that there is still some way to go. We&#8217;re slowly developing a common model, but both &#8220;(Re)discovering vanilla&#8221; and &#8220;Supporting a &#8220;clean build&#8221; are visions not quite yet on the horizon of most large companies.<br />
In fact, it&#8217;s not so much technological advances that are required &#8211; many startups are pretty close to push-button deployments and continuous delivery. Indeed, the &#8220;poster children&#8221; of this movement already have setups where every commit can pass through an entire regression, integration and performance testing suite and potentially go straight to production.</p>
<p>No, the important hurdles to be taken are procedural and mental, changing rusty ways of working and entrenched mindsets. For those that can make it, though, the benefits in terms of accelerated business value are already proving to be game changers.</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2011/06/16/deployment-is-the-new-build-part-3/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2011%2F06%2F16%2Fdeployment-is-the-new-build-part-3%2F&amp;title=Deployment%20is%20the%20new%20build%20%28part%203%29" id="wpa2a_12"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2011/06/16/deployment-is-the-new-build-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deployment is the new build (part 2)</title>
		<link>http://blog.xebia.com/2011/05/21/deployment-is-the-new-build-part-2/</link>
		<comments>http://blog.xebia.com/2011/05/21/deployment-is-the-new-build-part-2/#comments</comments>
		<pubDate>Fri, 20 May 2011 22:49:01 +0000</pubDate>
		<dc:creator>Andrew Phillips</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Xebia Labs]]></category>
		<category><![CDATA[devops]]></category>

	<!-- AutoMeta Start -->
	<category>conventions</category>
	<category>conventions</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/?p=6846</guid>
		<description><![CDATA[Earlier this year, I was invited to present a talk at Devopsdays Boston about deployment as the new build: how deployments are carried out now, how they will need to adapt in a more virtualized, on-demand application landscape and what fundamental improvements will need to come before deployment matures into the invisible, it just works&#8482; [...]]]></description>
			<content:encoded><![CDATA[<p><em>Earlier this year, I was invited to present a <a href="http://www.devopsdays.org/events/2011-boston/proposals/deployment_is_the_new_build/" target="_new">talk</a> at <a href="http://www.devopsdays.org/events/2011-boston/" target="_new">Devopsdays Boston</a> about </em><a href="http://www.slideshare.net/apwashere/deployment-is-the-new-build" target="_new">deployment as the new build</a><em>: how deployments are carried out now, how they will need to adapt in a more virtualized, on-demand application landscape and what fundamental improvements will need to come before deployment matures into the invisible, </em>it just works&trade;<em> experience build is today.</em></p>
<p>In the <a href="http://blog.xebia.com/2011/05/deployment-is-the-new-build-part-1/" target="_new">previous post</a>, we compared deployment to another key process in the application lifecycle &#8211; build &#8211; and asked which key developments turned <em>it</em> from a magical &#8220;black box&#8221; into the &#8220;just works&#8221; process it is today. </p>
<p>We identified <em>Reusable commands</em>, <em>Models</em> and <em>Conventions++</em> as three key steps, which we&#8217;ll look into in more detail in this post. Then, we&#8217;ll shift back to deployment and ask which improvements will be essential to getting to &#8220;just works&#8221; here.<br />
<span id="more-6846"></span></p>
<h3>Reusable commands</h3>
<div style="padding: 5px; float: right;"><img src="http://blog.xebia.com/wp-content/uploads/2011/05/deployment-is-the-new-build-p2-1.png" alt="" title="deployment-is-the-new-build-p2-1" width="250" height="154" class="alignnone size-full wp-image-6861" /></div>
<p>The first step, epitomised by <a href="http://ant.apache.org/" target="_new">Apache Ant</a>, was the recognition that most of the low-level tasks or actions are the same whatever application is being built, whether calling a compiler, copying files or replacing placeholders.<br />
Rather than copy-pasting the same OS commands into every new build script, we encapsulated these commands as libraries of reusable components that only needed to be written once.<br />
Further, we discovered that certain patterns of step sequences would appear in many different builds. These &#8216;chunks&#8217;, such as constructing a classpath, or copying and processing static resources, evidently represented some higher-level build activity with a distinct function.</p>
<h3>Models</h3>
<div style="padding: 5px; float: right;"><img src="http://blog.xebia.com/wp-content/uploads/2011/05/deployment-is-the-new-build-p2-2.png" alt="" title="deployment-is-the-new-build-p2-2" width="250" height="150" class="alignnone size-full wp-image-6862" /></div>
<p>Whilst the realisation that all the actions carried out in a build are basically a sequence of common chunks was an important start, the next big advance was brought about by recognising that we weren&#8217;t just seeing repeated patterns of actions, but that the types of data these actions were working on were also shared.<br />
This gave rise to the notion of a true domain model for application builds, with source sets, resource sets, modules, dependencies and so forth that were originally introduced by <a href="http://maven.apache.org/" target="_new">Maven</a> and have featured and been reused in all build systems since.</p>
<p>Combining the sequence of common chunks with the new domain model that structured the data being processed gave rise to notion of distinct phases, in which parts of the build model are generated, prepared and made available to subsequent commands.<br />
In addition, Maven also supported the idea that the domain model, and thus the build phases, would have to be able to vary slightly to accommodate different types of Java artifacts that need to be delivered, such as JARs and EARs. This has subsequently been further developed to support builds of totally different technologies such as <a href="http://flexmojos.sonatype.org/" target="_new">Adobe Flex applications</a>.</p>
<h3>Conventions++</h3>
<div style="padding: 5px; float: right;"><img src="http://blog.xebia.com/wp-content/uploads/2011/05/deployment-is-the-new-build-p2-3.png" alt="" title="deployment-is-the-new-build-p2-3" width="250" height="172" class="alignnone size-full wp-image-6863" /></div>
<p>An additional benefit of domain models for build was the ability to make use of default values in a structured way, for instance for the names of built artifacts or the location of resource files.<br />
However, the flip side of this convenience, certainly in combination with <a href="http://maven.apache.org/pom.html" target="_new">XML</a> as a descriptor language for builds, meant that deviating from these standards could be quite a challenge. Certainly if the aim was to extend the domain model in some way, or to support a language or technology whose build flow was reasonably different from Java&#8217;s, such as building documentation bundles or virtual machine images, for instance.<br />
This has led to a generation of build tools, such as <a href="http://www.gradle.org/" target="_new">Gradle</a>, that aim to restore the developer to a position of full control in which arbitrary actions can easily be defined and organised into phases, tasks and entire builds. Of course, given how used we have become to the convenience of &#8220;it just works&#8221; in simple cases, these tools still support the full domain models and conventions of <a href="http://www.gradle.org/standard_plugins.html" target="_new">common technologies</a> such as Java.</p>
<h3>Who&#8217;d have thought?</h3>
<p>Reviewing this progression from today&#8217;s perspective, a couple of facts stand out that, certainly in comparison to other evolutions in IT, are quite surprising.<br />
Firstly, whilst it&#8217;s now hard to imagine specifying a dependency using anything other than the <a href="http://maven.apache.org/pom.html#Dependencies" target="_new">groupId:artifactId:version</a> pattern, none of the models or conventions that developed were formalised in industry standards. Instead, they were either based on observations of common patterns, or simply clever or even somewhat arbitrary choices (<a href="http://maven.apache.org/pom.html#Directories" target="_new"><tt>src/main/java</tt></a>, for instance).<br />
Secondly, we have seen how ease-of-use based on conventions, coupled with a moderate nuisance factor of tweaking those conventions, can dramatically change user behaviour. Initially, for instance, many of those new to Maven spent quite a significant amount of time, and produced a fair amount of XML, to change the standard settings to match their own environment, naming conventions, file paths etc.<br />
Pretty soon, though, and especially as the ratio of green field vs. legacy projects increased, it simply became easier to stick with Maven&#8217;s standard values and be done with it. Today, these conventions have become so standardised that they are supported not just by Maven, but essentially all other build systems out there, too.<br />
It&#8217;s not just users&#8217; preferences that were &#8220;charmed&#8221; into adopting standard conventions, though. In many cases, company standards previously seen as cast-iron were progressively discarded or modified if they could easily not be accommodated by the emerging de facto standards. Ease-of-use was able to triumph against abstract rules.</p>
<h3>And deployment?</h3>
<p>So much for the build process. What about deployment, today&#8217;s critical hurdle for automation in the business value delivery chain? As previously mentioned, the current industry average is somewhere between &#8220;black box&#8221; and &#8220;step sequence&#8221;. In terms of the descriptions of the build process evolution, the most advanced deployment automation systems are somewhere just beyond &#8220;reusable commands&#8221;, in other words.<br />
Which naturally begs the question: how do we get to a push-button state? What do we need to do to be able to reach the maturity level of build today?<br />
Looking at what we encounter in the industry today, three critical aspects will be:</p>
<ol>
<li><strong>Develop a common model</strong></li>
<li><strong>(Re)discover vanilla</strong></li>
<li><strong>Support a &#8220;clean build&#8221;</strong></li>
</ol>
<p>We’ll cover the details of these three concepts in the <a href="http://blog.xebia.com/2011/06/deployment-is-the-new-build-part-3/" target="_new">next blog</a>…</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2011/05/21/deployment-is-the-new-build-part-2/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2011%2F05%2F21%2Fdeployment-is-the-new-build-part-2%2F&amp;title=Deployment%20is%20the%20new%20build%20%28part%202%29" id="wpa2a_14"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2011/05/21/deployment-is-the-new-build-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deployment is the new build (part 1)</title>
		<link>http://blog.xebia.com/2011/05/03/deployment-is-the-new-build-part-1/</link>
		<comments>http://blog.xebia.com/2011/05/03/deployment-is-the-new-build-part-1/#comments</comments>
		<pubDate>Tue, 03 May 2011 19:35:06 +0000</pubDate>
		<dc:creator>Andrew Phillips</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Xebia Labs]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[devops]]></category>

	<!-- AutoMeta Start -->
	<category>devopsdays</category>
	<category>boston</category>
	<category>devopsdays</category>
	<category>boston</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/?p=6782</guid>
		<description><![CDATA[Earlier this year, I was invited to present a talk at Devopsdays Boston about deployment as the new build: how deployments are carried out now, how they will need to adapt in a more virtualized, on-demand application landscape and what fundamental improvements will need to come before deployment matures into the invisible, it just works&#8482; [...]]]></description>
			<content:encoded><![CDATA[<p><em>Earlier this year, I was invited to present a <a href="http://www.devopsdays.org/events/2011-boston/proposals/deployment_is_the_new_build/" target="_new">talk</a> at <a href="http://www.devopsdays.org/events/2011-boston/" target="_new">Devopsdays Boston</a> about </em><a href="http://www.slideshare.net/apwashere/deployment-is-the-new-build" target="_new">deployment as the new build</a><em>: how deployments are carried out now, how they will need to adapt in a more virtualized, on-demand application landscape and what fundamental improvements will need to come before deployment matures into the invisible, </em>it just works&trade;<em> experience build is today.</em></p>
<p>In this first post, we&#8217;ll focus on some of the changes and trends across the industry that have brought such increased business attention to the area of release, deployment and management of applications.<br />
<span id="more-6782"></span><br />
As companies focus on tuning their IT environment on rapid delivery of business value, more and more projects and initiatives within organisations are looking at the entire value chain of software production.</p>
<p>Whether under the banner of <a href="http://www.devopsdays.org" target="_new">Devops</a>, via integrated project teams or as part of the introduction of new development methodologies like <a href="http://en.wikipedia.org/wiki/Agile_software_development" target="_new">Agile</a><sup>1</sup> or infrastructure technologies such as <a href="http://www.nist.gov/itl/cloud/" target="_new">cloud</a><sup>2</sup>, there is a growing awareness of the need for automated, reliable and flexible deployment procedures.</p>
<p>Whilst it&#8217;s clear that the generation of customer features takes place within the development, testing and QA teams, the business value inherent in these features is only unlocked once the application is actually running in a target environment, accessible to users. And it&#8217;s not just the final release to production that requires a deployment: every UAT, performance or integration test generally needs an application running in a &#8220;real&#8221; environment, not a developer&#8217;s local machine. One test, one deployment. </p>
<p>Given the well-known costs and adverse effects of faulty software in production, the ability to raise quality, usability and performance through a greatly increased number of testing cycles represents significant added value in itself.</p>
<p>One of the consequences of this increased attention is that the importance of build, release and deployment professionals as deliverers of business value is being recognized more and more. The heightened focus also means, though, that many companies are realizing that the effectivity, simplicity and overhead of their release and deployment processes lag far behind that of build and continuous integration.</p>
<p>As my role at <a href="http://www.xebialabs.com" target="_new">XebiaLabs</a> involves studying, automating and improving deployment processes across the industry and helping developing our vision for deployment into the future, the question of why deployment is so different from build in today&#8217;s enterprises was bound to raise its head sooner or later. The resulting discussions and reflections formed the basis for this series.</p>
<h3>What&#8217;s in a word?</h3>
<p>One of the challenges surrounding the discussion of deployment in relation to build, release, provisioning and other tasks in the <a href="http://en.wikipedia.org/wiki/Application_lifecycle_management" target="_new">ALM</a> space is the &#8211; decreasing, thankfully &#8211; lack of a clear shared definition for <em>deployment</em>. Without wanting to promulgate this as the correct definition, for the context of this discussion I&#8217;d like to treat deployment as the process that</p>
<blockquote><p><em>takes the components that make up a release (typically a specific version of an application) and getting them correctly set up in an infrastructure environment so that the release is accessible to (end) users</em>
</p></blockquote>
<p>This would differentiate it from <em>build</em> and <em>release</em> in that it assumes that the application components have already been created, and from <em>provisioning</em> and other infrastructure tasks in that the target infrastructure is already assumed to be present. </p>
<p>On-demand virtual or cloud environments, or virtual appliances, put a bit of a different spin on the issue, and will be a topic for a subsequent blog.</p>
<h3>Blast from the past</h3>
<div style="padding: 5px; float: right;"><img src="http://blog.xebia.com/wp-content/uploads/2011/05/deployment-is-the-new-build-p1-1.png" alt="" title="deployment-is-the-new-build-p1-1" width="131" height="127" class="alignnone size-full wp-image-6785" /></div>
<p>Taking the above as our working definition, the sobering picture is that, with very few exceptions, deployment now is pretty much at the stage where build was in the days of the make guru: a black box put together and operated by a specialist that somehow works. With luck, this precious resource is still employed and around to fix or extend things when required, but if he or she is out to lunch you&#8217;re simply out of luck.</p>
<p>To be fair, there are quite a few places where there is least tooling or automation in place that tries to map out the sequence of steps or actions required to carry out a deployment, to at least bring some visibility and traceability and shine some light on the &#8216;magic&#8217;. But this is still a long way away from the push-button experience that build is nowadays. Laboriously visualizing and walking through a process step-by-step is still a sign ultimately of a lack of trust; a truly mature process doesn&#8217;t display its internals any more, it &#8220;just works&#8221;. Much like build today.</p>
<h3>The road to &#8220;just works&#8221;</h3>
<div style="padding: 5px; float: right;"><img src="http://blog.xebia.com/wp-content/uploads/2011/05/deployment-is-the-new-build-p1-2.png" alt="" title="deployment-is-the-new-build-p1-2" width="131" height="136" class="alignnone size-full wp-image-6786" /></div>
<p> Of course, build didn&#8217;t start out as a &#8220;just works&#8221; process either, so what actually were the steps that made this transition possible? Looking at the evolution of Java build tooling over the past decade or so, there have been at least three main developments:</p>
<ol>
<li><strong>Reusable commands</strong></li>
<li><strong>Models</strong></li>
<li><strong>Conventions++</strong></li>
</ol>
<p>We&#8217;ll dive into the details of these three concepts in the <a href="http://blog.xebia.com/2011/05/deployment-is-the-new-build-part-2/" target="_new">next blog</a>&#8230;</p>
<div style="background-color: #EFEEEA; border: 1px solid #AAAAAA; margin: 0.8em; padding: 0.4em; font-size: 85%;">
<strong>Footnotes</strong></p>
<ol>
<li>Which my colleagues from Xebia, as recognised <a href="http://www.xebia.com/agile-consultancy" target="_new">world-wide Agile experts</a>, are much better positioned to <a href="http://blog.xebia.com/category/agile/" target="_new">talk about</a>.</li>
<li>For which there are almost as many alternative definitions as <a href="http://cloud-standards.org/wiki/index.php?title=Main_Page" target="_new">standards and industry organisations</a>, admittedly.</li>
</ol>
</div>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2011/05/03/deployment-is-the-new-build-part-1/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2011%2F05%2F03%2Fdeployment-is-the-new-build-part-1%2F&amp;title=Deployment%20is%20the%20new%20build%20%28part%201%29" id="wpa2a_16"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2011/05/03/deployment-is-the-new-build-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Making the bootstrap loader &#8220;just another ClassLoader&#8221;</title>
		<link>http://blog.xebia.com/2011/02/24/making-the-bootstrap-loader-just-another-classloader/</link>
		<comments>http://blog.xebia.com/2011/02/24/making-the-bootstrap-loader-just-another-classloader/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 11:37:00 +0000</pubDate>
		<dc:creator>Andrew Phillips</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[class loader]]></category>

	<!-- AutoMeta Start -->
	<category>loader</category>
	<category>loader</category>
	<category>bootstrap</category>
	<category>getloader</category>
	<category>loadclass</category>
	<category>classloader</category>
	<category>getcontextclassloader</category>
	<category>getsystemclassloader</category>
	<category>loader</category>
	<category>loader</category>
	<category>bootstrap</category>
	<category>getloader</category>
	<category>loadclass</category>
	<category>classloader</category>
	<category>getcontextclassloader</category>
	<category>getsystemclassloader</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/?p=6078</guid>
		<description><![CDATA[Recently, I was tweaking MultiSPI to add the following class loading fallback logic: and realized that it&#8217;s not immediately evident how to do this in a uniform way. But actually, it&#8217;s quite simple&#8230;getting a ClassLoader object for the bootstrap loader is just a couple of lines of code. So what&#8217;s the problem? Well, if you&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I was tweaking <a href="http://blog.xebia.com/2011/02/13/multispi-consuming-service-provider-interfaces-in-2011/" target="_new">MultiSPI</a> to add the following class loading fallback logic:</p>
<pre class="brush: java; title: ; notranslate">
if (threadContextLoader != null) {
  loadFromContextLoader(className);
} else if (systemLoader != null) {
  loadFromSystemLoader(className);
} else {
  loadFromBootstrapLoader(className);
}
</pre>
<p>and realized that it&#8217;s not immediately evident how to do this in a uniform way. But actually, it&#8217;s quite simple&#8230;getting a <a href="http://download.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html" target="_new">ClassLoader</a> object for the bootstrap loader is just a couple of lines of code.<br />
<span id="more-6078"></span></p>
<h3>So what&#8217;s the problem?</h3>
<p>Well, if you&#8217;re happy with a literal implementation of the pseudo-code above, there obviously isn&#8217;t a problem. </p>
<pre class="brush: java; title: ; notranslate">
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader != null) {
  return loader.loadClass(className);
}

loader = ClassLoader.getSystemClassLoader();
if (loader != null) {
  return loader.loadClass(className);
}

// null is the bootstrap loader
return Class.forName(className, true, null);
</pre>
<p>But this is very procedural code<sup>1</sup>, and it would already be much more OO if we could do something like:</p>
<pre class="brush: java; title: ; notranslate">
getLoader().loadClass(className);

ClassLoader getLoader() {
  ClassLoader loader = Thread.currentThread().getContextClassLoader();
  if (loader != null) {
    return loader;
  }

  loader = ClassLoader.getSystemClassLoader();
  if (loader != null) {
    return loader;
  }

  return ...???????
}
</pre>
<p>The problem is that there simply isn&#8217;t a <tt>ClassLoader.getBootstrapClassLoader()</tt> or equivalent method. You can try to walk up the system loader&#8217;s <a href="http://download.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html#getParent()" target="_new">parent</a> hierarchy, of course, but what you&#8217;re likely to find is that the bootstrap loader will be <a href="http://download.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html#getParent()" target="_new">represented by <tt>null</tt></a> &#8211; not very useful in our circumstances.</p>
<h3>Writing BootstrapClassLoader</h3>
<p>So what we want is to come up with a <tt>ClassLoader</tt> implementation that delegates straight to the bootstrap loader. One option would be to override <a href="http://download.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html#loadClass(java.lang.String)" target="_new">loadClass</a> to simply call <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#forName(java.lang.String, boolean, java.lang.ClassLoader)" target="_new">Class.forName</a> with the above arguments, but there&#8217;s actually an even easier<sup>2</sup> way:</p>
<pre class="brush: java; title: ; notranslate">
class BootstrapClassLoader extends ClassLoader {
    BootstrapClassLoader() {
        /*
         * The default classloader implementation will use the bootstrap loader
         * if it finds a null parent.
         */
        super(null);
    }
}
</pre>
<p>Now we can finish our <tt>getLoader</tt> method:</p>
<pre class="brush: java; title: ; notranslate">
// or simply &quot;new ClassLoader(null) {};&quot;
final ClassLoader BOOTSTRAP_LOADER = new BootstrapClassLoader();

ClassLoader getLoader() {
  ClassLoader loader = Thread.currentThread().getContextClassLoader();
  if (loader != null) {
    return loader;
  }

  loader = ClassLoader.getSystemClassLoader();
  if (loader != null) {
    return loader;
  }

  return BOOTSTRAP_LOADER;
}
</pre>
<p>Unless we&#8217;re being really performance-conscious, we can even turn this into the almost functional<sup>3</sup>:</p>
<pre class="brush: java; title: ; notranslate">
ClassLoader getLoader() {
  return Iterables.find(asList(Thread.currentThread().getContextClassLoader(),
      ClassLoader.getSystemClassLoader(), BOOTSTRAP_LOADER), Predicates.notNull());
}
</pre>
<p>There&#8217;s a demo snippet on PasteBin <a href="http://pastebin.com/nJVXMucK" target="_new">here</a>.</p>
<div style="background-color: #EFEEEA; border: 1px solid #AAAAAA; margin: 0.8em; padding: 0.4em; font-size: 85%;">
<strong>Footnotes</strong></p>
<ol>
<li>Indeed, I hope your immediate reaction was something like <em>urgh!</em></li>
<li>and, to my mind, more elegant</li>
<li>Heavy use of <a href="http://code.google.com/p/guava-libraries/" target="_new">Guava</a> ahead!</li>
</ol>
</div>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2011/02/24/making-the-bootstrap-loader-just-another-classloader/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2011%2F02%2F24%2Fmaking-the-bootstrap-loader-just-another-classloader%2F&amp;title=Making%20the%20bootstrap%20loader%20%26%238220%3Bjust%20another%20ClassLoader%26%238221%3B" id="wpa2a_18"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2011/02/24/making-the-bootstrap-loader-just-another-classloader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MultiSPI &#8211; consuming service provider interfaces in 2011</title>
		<link>http://blog.xebia.com/2011/02/13/multispi-consuming-service-provider-interfaces-in-2011/</link>
		<comments>http://blog.xebia.com/2011/02/13/multispi-consuming-service-provider-interfaces-in-2011/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 09:11:11 +0000</pubDate>
		<dc:creator>Andrew Phillips</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[spi]]></category>

	<!-- AutoMeta Start -->
	<category>multispi</category>
	<category>serviceloader</category>
	<category>qrmedia</category>
	<category>aphillips</category>
	<category>googlecode</category>
	<category>snapshots</category>
	<category>snapshot</category>
	<category>spis</category>
	<category>multispi</category>
	<category>serviceloader</category>
	<category>qrmedia</category>
	<category>aphillips</category>
	<category>googlecode</category>
	<category>snapshots</category>
	<category>snapshot</category>
	<category>spis</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/?p=6071</guid>
		<description><![CDATA[Implementing a Java SPI isn&#8217;t a particularly 2011 experience1. Creating a correctly-named text file in META-INF/services, making sure it is correctly packaged and remembering to keep it up to date when you refactor is sufficiently annoying and error-prone that there are at least a couple of utils that aim to make this easier. At XebiaLabs, [...]]]></description>
			<content:encoded><![CDATA[<p>Implementing a Java SPI isn&#8217;t a particularly 2011 experience<sup>1</sup>. Creating a correctly-named text file in META-INF/services, making sure it is correctly packaged and remembering to keep it up to date when you refactor is sufficiently annoying and error-prone that there are at least a <a href="http://code.google.com/p/spi/" target="_new">couple</a> <a href="http://weblogs.java.net/blog/kohsuke/archive/2009/03/my_project_of_t.html" target="_new">of</a> utils that aim to make this easier.</p>
<p>At <a href="http://www.xebialabs.com/features" target="_new">XebiaLabs</a>, however, we&#8217;re not just the implementors of our plugin SPI. We also write the deployment engine that <em>consumes</em> these plugins. And unfortunately, there isn&#8217;t much out there to help you read, load and verify services. Hence <a href="http://aphillips.googlecode.com/svn/maven-sites/multi-spi/1.0-SNAPSHOT/index.html" target="_new">MultiSPI</a>.<br />
<span id="more-6071"></span></p>
<h3>What about ServiceLoader?</h3>
<p>Evidently, the engineers at <strike>Sun</strike>Oracle &#8211; as prominent SPI consumers &#8211; shared this frustration. In Java 6, they introduced <a href="http://download.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html" target="_new">ServiceLoader</a> to at least make &#8220;vanilla&#8221; SPI consumption easier. MultiSPI isn&#8217;t just a fully-compatible alternative for those still working with Java 5, however. It also supports a number of common additional use cases:</p>
<ol>
<li><strong>Inspecting the list of class names before they are loaded</strong>, for instance to remove or replace some items (think user-definable overrides), to use different class loaders for different packages (think OSGi) etc.</li>
<li><strong>Inspecting the classes before they are instantiated</strong>, for instance to check for required annotations or implemented interfaces, to delay creation of instances etc.</li>
<li><strong>Using non-vanilla instantiation strategies</strong>, for instance to support factory methods, or in conjunction with dependency injection etc.</li>
</ol>
<h3>Providing services in 2011</h3>
<p>More importantly, though, MultiSPI doesn&#8217;t just support reading service implementations from META-INF/services files. Because let&#8217;s face it, if you&#8217;re designing a component-provider mechanism today, it probably won&#8217;t be based on the <a href="http://download.oracle.com/javase/6/docs/technotes/guides/jar/jar.html#Service%20Provider" target="_new">vanilla SPI specification</a>.</p>
<p>MultiSPI supports <a href="http://aphillips.googlecode.com/svn/maven-sites/multi-spi/1.0-SNAPSHOT/apidocs/com/qrmedia/commons/multispi/config/MultiSpiBuilder.html#withAnnotationScanning(java.lang.Class, java.lang.String)" target="_new">annotation-</a> and <a href="http://aphillips.googlecode.com/svn/maven-sites/multi-spi/1.0-SNAPSHOT/apidocs/com/qrmedia/commons/multispi/config/MultiSpiBuilder.html#withManifestServiceClassnameAttributeScanning()" target="_new">manifest-scanning</a> out-of-the-box, but you can <a href="http://aphillips.googlecode.com/svn/maven-sites/multi-spi/1.0-SNAPSHOT/apidocs/com/qrmedia/commons/multispi/config/MultiSpiBuilder.html#withProviders()" target="_new">add providers</a> for any scheme of your choice, be it XML descriptors, system properties, environment variables or whatever. Of course, you can also mix and match different providers, especially useful if (as in our case with <a href="http://www.xebialabs.com/features" target="_new">Labs</a>) you are supporting multiple versions of an SPI.</p>
<h3>SPIs and dependency injection</h3>
<p>Ultimately, of course, SPIs are just service factories, and if you&#8217;re working within a dependency injection context you probably don&#8217;t want to invoke an SPI loader explicitly, you just want the resulting services to &#8220;be available&#8221; for injection into your business logic.<br />
Indeed, Spring added a <a href="http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/beans/factory/serviceloader/ServiceListFactoryBean.html" target="_new">ServiceLoader-backed factory</a> in 2.5, and of course you can do the same with MultiSPI, whether you want the implementation class names, the classes or the instances themselves. There&#8217;s <a href="http://code.google.com/p/aphillips/source/browse/multi-spi/trunk/src/test/java/com/qrmedia/commons/multispi/example/SpringAgentExample.java" target="_new">Spring</a> and <a href="http://code.google.com/p/aphillips/source/browse/multi-spi/trunk/src/test/java/com/qrmedia/commons/multispi/example/GuiceAgentExample.java" target="_new">Guice</a> examples; here&#8217;s the <a href="http://code.google.com/p/aphillips/source/browse/multi-spi/trunk/src/test/resources/agentContext.xml" target="_new">Spring context</a> that prepares a set of class names, classes and instances, for example:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;bean id=&quot;multiSpi&quot; class=&quot;com.qrmedia.commons.multispi.MultiSpi&quot;&gt;
  &lt;constructor-arg&gt;
    &lt;set&gt;
      &lt;bean class=&quot;com.qrmedia.commons.multispi.provider.MetaInfServicesProvider&quot; /&gt;
      &lt;bean class=&quot;com.qrmedia.commons.multispi.provider.AnnotationScanningProvider&quot;&gt;
        &lt;constructor-arg value=&quot;uk.gov.mi6.LicenseToKill&quot; /&gt;
        &lt;constructor-arg value=&quot;uk.gov&quot; /&gt;
      &lt;/bean&gt;
    &lt;/set&gt;
  &lt;/constructor-arg&gt;
&lt;/bean&gt;

&lt;bean id=&quot;agentNames&quot; factory-bean=&quot;multiSpi&quot; factory-method=&quot;findImplementationNames&quot;&gt;
  &lt;constructor-arg value=&quot;uk.gov.mi6.Agent&quot; /&gt;
&lt;/bean&gt;

&lt;bean id=&quot;agentClasses&quot; factory-bean=&quot;multiSpi&quot; factory-method=&quot;findImplementations&quot;&gt;
  &lt;constructor-arg value=&quot;uk.gov.mi6.Agent&quot; /&gt;
&lt;/bean&gt;

&lt;bean id=&quot;agents&quot; factory-bean=&quot;multiSpi&quot; factory-method=&quot;loadImplementations&quot;&gt;
  &lt;constructor-arg value=&quot;uk.gov.mi6.Agent&quot; /&gt;
&lt;/bean&gt;
</pre>
<p>Of course you can use many different <a href="http://aphillips.googlecode.com/svn/maven-sites/multi-spi/1.0-SNAPSHOT/apidocs/com/qrmedia/commons/multispi/MultiSpi.html" target="_new">MultiSpi</a> instances, with different provider configurations, in your application at the same time.</p>
<h3>Using MultiSPI</h3>
<p>To use MultiSPI, just add the following dependency and repositories to your POM:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;dependency&gt;
  &lt;groupId&gt;com.qrmedia.commons&lt;/groupId&gt;
  &lt;artifactId&gt;multi-spi&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;/dependency&gt; 

&lt;repository&gt;
  &lt;id&gt;qrmedia-releases&lt;/id&gt;
  &lt;url&gt;http://aphillips.googlecode.com/svn/maven-repository/releases&lt;/url&gt;
  &lt;releases&gt;
    &lt;enabled&gt;true&lt;/enabled&gt;
  &lt;/releases&gt;
  &lt;snapshots&gt;
    &lt;enabled&gt;false&lt;/enabled&gt;
  &lt;/snapshots&gt;
&lt;/repository&gt;
&lt;repository&gt;
  &lt;id&gt;qrmedia-snapshots&lt;/id&gt;
  &lt;url&gt;http://aphillips.googlecode.com/svn/maven-repository/snapshots&lt;/url&gt;
  &lt;releases&gt;
    &lt;enabled&gt;false&lt;/enabled&gt;
  &lt;/releases&gt;
  &lt;snapshots&gt;
    &lt;enabled&gt;true&lt;/enabled&gt;
  &lt;/snapshots&gt;
&lt;/repository&gt;
</pre>
<p>If you think you might run into conflicting <a href="http://aphillips.googlecode.com/svn/maven-sites/multi-spi/1.0-SNAPSHOT/dependencies.html" target="_new">dependencies</a> and want something that just works without having to deal with &lt;excludes&gt;, you can use:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;dependency&gt;
  &lt;groupId&gt;com.qrmedia.commons&lt;/groupId&gt;
  &lt;artifactId&gt;multi-spi&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &lt;classifier&gt;jar-with-dependencies&lt;/classifier&gt;
&lt;/dependency&gt;
</pre>
<p>instead.</p>
<p>The Maven site and project reports are <a href="http://aphillips.googlecode.com/svn/maven-sites/multi-spi/1.0-SNAPSHOT/project-info.html" target="_new">here</a>.</p>
<div style="background-color: #EFEEEA; border: 1px solid #AAAAAA; margin: 0.8em; padding: 0.4em; font-size: 85%;">
<strong>Footnotes</strong></p>
<ol>
<li>I&#8217;ll leave the debate about whether even writing <em>Java</em> can still be considered a 2011 experience to our <a href="http://maurits.wordpress.com/" target="_new">Clojure</a>, <a href="http://dutch-scala-enthusiasts.ning.com/" target="_new">Scala</a> etc. fans <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
</ol>
</div>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2011/02/13/multispi-consuming-service-provider-interfaces-in-2011/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2011%2F02%2F13%2Fmultispi-consuming-service-provider-interfaces-in-2011%2F&amp;title=MultiSPI%20%26%238211%3B%20consuming%20service%20provider%20interfaces%20in%202011" id="wpa2a_20"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2011/02/13/multispi-consuming-service-provider-interfaces-in-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  blog.xebia.com/author/aphillips/feed/ ) in 0.85527 seconds, on Feb 9th, 2012 at 4:37 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 9th, 2012 at 5:37 pm UTC -->
