<?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>Jayway Team Blog &#187; configuration</title>
	<atom:link href="http://blog.jayway.com/tag/configuration/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jayway.com</link>
	<description>Sharing Experience</description>
	<lastBuildDate>Sat, 11 Feb 2012 10:33:02 +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>Testing Web.config Transformations, Part 1</title>
		<link>http://blog.jayway.com/2011/12/08/testing-web-config-transformations/</link>
		<comments>http://blog.jayway.com/2011/12/08/testing-web-config-transformations/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 20:44:45 +0000</pubDate>
		<dc:creator>Mads Troest</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[automated testing]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[transformation]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[Web.config]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=11089</guid>
		<description><![CDATA[Web.config transformations is a Microsoft-supported technology for adapting a base configuration to a particular deployment environment. In my previous post, I mentioned how AppHarbor provides an online tool for manually testing transformations. Also, the Visual Studio extension SlowCheetah provides support for manually testing and transformation and diffing them against the base configuration from inside Visual Studio. These [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://msdn.microsoft.com/en-us/library/dd465326.aspx" target="_blank">Web.config transformations</a> is a Microsoft-supported technology for adapting a base configuration to a particular deployment environment.</p>
<p>In my <a href="http://blog.jayway.com/2011/11/14/web-config-transformations-and-xml-namespaces/" target="_blank">previous post</a>, I mentioned how <a href="http://appharbor.com" target="_blank">AppHarbor</a> provides an <a href="http://webconfigtransformationtester.apphb.com/" target="_blank">online tool</a> for manually testing transformations. Also, the Visual Studio extension <a href="http://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5" target="_blank">SlowCheetah</a> provides support for manually testing and transformation and <a href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/11/SlowCheetahPreviewTransform.png" target="_blank">diffing</a> them against the base configuration from inside Visual Studio. These tools are useful and may be fine for tinkering with getting a transform just right, but being software professionals, we find it highly desirable to reliably automate our transformation testing.</p>
<p>In this article we shall look at one way to exercise our Web.config transformations from our own code, so that we can TDD our transformations and regression test them as part of our continuous integration cycle, like everything else.</p>
<h2>Starting Point</h2>
<p>The actual Web.config transformation process is normally invoked by MSBuild, as described in detail by Elton Stoneman in <a href="http://geekswithblogs.net/EltonStoneman/archive/2010/08/20/using-msbuild-4.0-web.config-transformation-to-generate-any-config-file.aspx" target="_blank">this post</a>. (One approach to testing the transformations could, thus, be to fork off MSBuild processes on custom build targets, but we'd like to take a less cumbersome route.)</p>
<p>Being an MSBuild task means that the transformation is implemented as an <strong>ITask</strong> realization. The concrete implementation is called <strong>TransformXml</strong> and resides in the <strong>Microsoft.Web.Publishing.Tasks.dll</strong> assembly. Note that this assembly is not pre-installed with Windows/.NET but rather installed along with Visual Studio 2010, typically to <em>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web</em>). Given that its location is not fixed, you'd probably want to add it to your dependencies folder (caveat emptor: check license terms before passing it around).</p>
<p>From Elton's post, we can also see 3 arguments being passed to the TransformXml task:</p>
<ul>
<li>Source (the XML file to transform)</li>
<li>Transform (the transformation XML file itself)</li>
<li>Destination (the target of the transformed XML file)</li>
</ul>
<p>Armed with that background knowledge, let's move on and try to get the transformation to run outside of the MSBuild environment in which it normally executes. For our experiment, we'll be transforming the following source (<em>app.config</em>):</p>
<pre class="brush: xml;">   &lt;configuration&gt;
     &lt;appSettings&gt;
	   &lt;add key="testKey" value="testValue"/&gt;
     &lt;/appSettings&gt;
   &lt;/configuration&gt;</pre>
<p>The transformation we'll be testing (<em>app.Debug.config</em>) should change the "testValue" of the "testKey" to something transformation specific ("debugValue" in this case):</p>
<pre class="brush: xml;">   &lt;configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"&gt;
     &lt;appSettings&gt;
       &lt;add key="testKey"
            value="debugValue"
            xdt:Locator="Match(key)" xdt:Transform="SetAttributes" /&gt;
     &lt;/appSettings&gt;
   &lt;/configuration&gt;</pre>
<h2>Test Approach</h2>
<p>Our initial stab at automatically testing the transformation will be to invoke the XmlTransform through its outermost interface; i.e. the ITask interface. First, we need to add a reference to <strong>Microsoft.Web.Publishing.Tasks.dll</strong> as mentioned above. Additionally, we need to reference <strong>Microsoft.Build.Framework</strong> and <strong>Microsoft.Build.Utilities.v4.0</strong> (these should be available from your usual <em>Project, Add Reference, .NET </em>tab).</p>
<p>Opening up the XmlTransform class in Visual Studio's Object Browser shows us a single method, <strong>Execute()</strong>, plus a handful of properties, most of which we recognize from Stoneman's previously mentioned post. A little experimentation reveals the following details:</p>
<ul>
<li><strong>SourceRootPath</strong></li>
<ul>
<li>The base path to which the XML file specified in <strong>Source</strong> is relative. If not specified, this will  be the current directory (which, when running from a test runner, would typically be your build target directory).</li>
</ul>
<li><strong>Source</strong></li>
<ul>
<li>The name of the XML source file to be transformed. If this is not an absolute path, it will be relative to the <strong>SourceRootPath</strong>.</li>
</ul>
<li><strong>TransformRootPath</strong></li>
<ul>
<li>The base path to which the XML file specified in <strong>Transform</strong> is relative. If not specified, this will be the same as <strong>SourceRootPath</strong>.</li>
</ul>
<li><strong>Transform</strong></li>
<ul>
<li>The name of the XML transformation to be applied to the source. If this is not an absolute path, it will be relative to the <strong>TransformRootPath</strong>.</li>
</ul>
<li><strong>Destination</strong></li>
<ul>
<li>The name of the resulting transformed XML file. If this is not an absolute path, it will be relative to the current directory (typically your build target directory, in a test context).</li>
</ul>
</ul>
<p>So all we need to do is something like the following, right?</p>
<pre class="brush: csharp;">   var transformer = new TransformXml
   {
      SourceRootPath = @"..\..\..\Jayway.WebTransformTesting\",
      Source = @"app.config",
      Transform = @"app.Debug.config",
      Destination = @"app.transformed.config"
   };
   var transformationSucceeded = transformer.Execute();</pre>
<p>Well, as the <strong>System.InvalidOperationException</strong> with the message <em>"Task attempted to log before it was initialized" </em>thrown in our face subtly tells us, this is not quite the case...</p>
<p>Investigating the task implementation with Reflector shows the problem to be due to the fact that a property, <strong>BuildEngine</strong>, of the Task base class has not been set. It is used as a dependency injection mechanism, giving the task access to some environment services (see <a href="http://msdn.microsoft.com/en-us/library/microsoft.build.framework.ibuildengine.aspx" target="_blank">IBuildEngine</a> on MSDN) normally provided by MSBuild.</p>
<p>Well, the whole purpose of this experiment was to run outside of MSBuild, so we'll roll our own "build engine" instead:</p>
<pre class="brush: csharp;">   public class BuildEngineForTest : IBuildEngine
   {
      public void LogErrorEvent(BuildErrorEventArgs e)
      {
         Console.WriteLine(LogFormat, "ERROR", e.Message);
      }

      public void LogWarningEvent(BuildWarningEventArgs e)
      {
         Console.WriteLine(LogFormat, "WARNING", e.Message);
      }

      public void LogMessageEvent(BuildMessageEventArgs e)
      {
         Console.WriteLine(LogFormat, e.Importance, e.Message);
      }

      public void LogCustomEvent(CustomBuildEventArgs e)
      {
         Console.WriteLine(LogFormat, "CUSTOM", e.Message);
      }

      public bool BuildProjectFile(
         string projectFileName, string[] targetNames,
         IDictionary globalProperties, IDictionary targetOutputs)
      {
         return true;
      }

      public bool ContinueOnError
      {
         get { return true; }
      }

      public int LineNumberOfTaskNode
      {
         get { return 0; }
      }

      public int ColumnNumberOfTaskNode
      {
         get { return 0; }
      }

      public string ProjectFileOfTaskNode
      {
         get { return string.Empty; }
      }

      private const string LogFormat = "{0} : {1}";
   }</pre>
<p>This was the piece we were missing to be able to run the transformation outside MSBuild. We are, thus, able to write our coveted test:</p>
<pre class="brush: csharp;">...
   [Test]
   public void ApplyingDebugTransformationToConfigurationSetsExpectedKey()
   {
      const string targetFile = @"app.transformed.config";

      var transformer = new TransformXml
      {
         BuildEngine = new BuildEngineForTest(),
         SourceRootPath = @"..\..\..\Jayway.WebTransformTesting\",
         Source = @"app.config",
         Transform = @"app.Debug.config",
         Destination = targetFile
      };

      // Left as exercise for the reader... ;]
      AssertKeyInTransformedFile(targetFile);
   }
...</pre>
<p>Our transformation runs successfully, yielding the following console output from our "build engine":</p>
<pre>Normal : Transforming Source File: ..\..\..\Jayway.WebTransformTesting\app.config
Normal : Applying Transform File: ..\..\..\Jayway.WebTransformTesting\app.Debug.config
Low : Executing SetAttributes (transform line 6, 35)
Low : on /configuration/appSettings/add[@key='testKey']
Low : Applying to 'add' element (source line 4, 6)
Low : Set 'key' attribute
Low : Set 'value' attribute
Low : Set 2 attributes
Low : Done executing SetAttributes
Normal : Output File: app.transformed.config
Normal : Transformation succeeded</pre>
<p>Yay? Yay.</p>
<h2>Conclusion</h2>
<p>We have shown how Web.config Transformations can be invoked programmatically, outside the MSBuild process by providing a simple custom IBuildEngine realization; a technique that might prove useful for other scenarios as well.</p>
<p>We have applied that knowledge to enable automated testing of our transformations.</p>
<p>In my next post in this series, we'll continue our investigation, aiming to get rid of the whole, nasty detour around the file system.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2011/12/08/testing-web-config-transformations/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Web.config Transformations and XML Namespaces</title>
		<link>http://blog.jayway.com/2011/11/14/web-config-transformations-and-xml-namespaces/</link>
		<comments>http://blog.jayway.com/2011/11/14/web-config-transformations-and-xml-namespaces/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 12:45:15 +0000</pubDate>
		<dc:creator>Mads Troest</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[namespace]]></category>
		<category><![CDATA[NLog]]></category>
		<category><![CDATA[transformation]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[Web.config]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=10849</guid>
		<description><![CDATA[In the project I'm currently working on, we use Web.config transformations to adapt a base configuration to a particular deployment environment. I was adding a transformation to adapt our NLog configuration for the various environments, when I ran into a problem. I'd added the following transformation, intended to set the log level to Warning on [...]]]></description>
			<content:encoded><![CDATA[<p>In the project I'm currently working on, we use <a href="http://msdn.microsoft.com/en-us/library/dd465326.aspx" target="_blank">Web.config transformations</a> to adapt a base configuration to a particular deployment environment.</p>
<p>I was adding a transformation to adapt our NLog configuration for the various environments, when I ran into a problem. I'd added the following transformation, intended to set the log level to Warning on the given deloyment:</p>
<pre class="brush: xml;">&lt;nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"&gt;
  &lt;rules&gt;
    &lt;logger name="*" minlevel="Warn"
      xdt:Transform="SetAttributes(minlevel)" xdt:Locator="Match(name)"
    /&gt;
  &lt;/rules&gt;
&lt;/nlog&gt;</pre>
<p>However, the original fragment kept being passed through without modification. I tried various modes of matching (incidentally, the online <a href="http://webconfigtransformationtester.apphb.com/" target="_blank">Web Config Transformation Tester</a> is a good tool for such tinkering with transformations) to no avail, until I decided to try and remove the NLog namespace from the transformation:</p>
<pre class="brush: xml;">&lt;nlog&gt;
  &lt;rules&gt;
    &lt;logger name="*" minlevel="Warn"
      xdt:Transform="SetAttributes(minlevel)" xdt:Locator="Match(name)"
    /&gt;
  &lt;/rules&gt;
&lt;/nlog&gt;</pre>
<p>And lo and behold; it worked.</p>
<p>That could have been the end of it, but I decided to dig a bit deeper, since we have the NLog schema in our solution and properly referencing it allows us to have IntelliSense within the web.config.</p>
<p>Eventually, as an experiment, I tried associating a namespace prefix with the NLog namespace at the top level, and then explicitly qualify the NLog elements with that prefix, rather than relying on specifying a default namespace on the NLog element:</p>
<pre class="brush: xml;">&lt;configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"
  xmlns:nlog="http://www.nlog-project.org/schemas/NLog.xsd"
&gt;

  &lt;nlog:nlog&gt;
    &lt;nlog:rules&gt;
      &lt;nlog:logger name="*" minlevel="Warn"
        xdt:Transform="SetAttributes(minlevel)" xdt:Locator="Match(name)"
      /&gt;
    &lt;/nlog:rules&gt;
  &lt;/nlog:nlog&gt;

&lt;/configuration&gt;</pre>
<p>Success!</p>
<h2>Conclusion</h2>
<p>Explicitly prefixing elements from foreign XML namespaces in config transformations must be described as a workaround, since semantically the first and the third NLog fragments are equivalent.</p>
<p>In spite of this flaw in the web.config transformations implementation, this workaround allows you to get the benefits of IntelliSense and better validation when you have the schema for NLog or any other foreign fragment available.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2011/11/14/web-config-transformations-and-xml-namespaces/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>It&#8217;s time for IoC Container Configuration Detente</title>
		<link>http://blog.jayway.com/2010/09/05/its-time-for-ioc-container-configuration-detente/</link>
		<comments>http://blog.jayway.com/2010/09/05/its-time-for-ioc-container-configuration-detente/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 20:32:28 +0000</pubDate>
		<dc:creator>Magnus Mårtensson</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[IoC]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/2010/09/05/its-time-for-ioc-container-configuration-detente/</guid>
		<description><![CDATA[Want an easy way to configure your Inversion of Control (IoC) container using an API? Don’t care one iota about which specific container you actually are using you just want to get the work done? Want to configure your IoC in a type safe manner? Read on and find out how! Scroll passed the background [...]]]></description>
			<content:encoded><![CDATA[<p>Want an easy way to configure your <a href="http://en.wikipedia.org/wiki/Inversion_of_control">Inversion of Control</a> (IoC) container using an API? Don’t care one iota about which specific container you actually are using you just want to get the work done? Want to configure your IoC in a type safe manner? Read on and find out how!</p>
<p>Scroll passed the background and rationale musings for the good stuff. ;~)</p>
<h3>Background and rationale musings<font style="font-weight: bold"></font></h3>
<p>Looking at a great initiative; the <a href="http://commonservicelocator.codeplex.com/">Common Service Locator</a> and using it because it’s a good design practice to use abstractions one can’t help but to hunger for more! There was one more piece I felt myself wanting to sink my teeth into. After some testing, re-working and re-factoring and re-re-factoring ;~) an embryo for a common simple API begun to emerge. We have found in our team that there is a smallish set of classic configuration tasks involved in setting up your IoC:</p>
<ul>
<li><strong>Register Instance</strong> (with or without a key) </li>
<li><strong>Register Type</strong> (with or without a key) </li>
<li><strong>Marking a registration a Singleton</strong> </li>
<li><strong>Selecting a constructor for injection</strong> </li>
<li><strong>Selecting properties for injection</strong> </li>
</ul>
<p>This is it really!</p>
<p>Really? Yes pretty much. This is likely to fill about 95% of the needs for configuring an IoC.</p>
<p>We’ve tested it in our project and it works really well. We started out using the API of the IoC we chose but felt it imposed a lot of presence in our code making our coders have to know and care a lot about how and what makes the underlying container tick. All they wanted to do was configure how their code would fit together.</p>
<p>That seems quite easy to create and API for. Indeed. ;~)</p>
<p>But wait; one single API can’t possibly fulfill all of the IoC configuration needs out there for ever! True that - it can’t pretend to be a <a href="http://www.bing.com/Dictionary/search?q=define+silver+bullet&amp;FORM=DTPDIA&amp;qpvt=Silver+Bullet+definition">silver bullet</a>. Well let’s make it easy to extend then.</p>
<p>Hmmm... If not all IoC can implement this API; wouldn’t that make the API a little pointless? Well, not really. The API would not be <em>intended </em>to allow you to replace one container with another without changing or even recompiling the code. Though it <em>could </em>be used that way. Just because you can replace one IoC with another doesn’t mean you will! Having a fitting simplification for an API – and adapter if you will – still makes a lot of sense to your code maintainability!</p>
<p>What if all of the existing IoC creators out there couldn’t care less about this little pesky API? Well I sure can’t blame them who has time to read each and every blog post. Fortunately it doesn’t matter. Let’s make it so that anyone who implements the API for their favorite IoC container and contribute.</p>
<p>That sound’s fair! Not all IoC’s might even have a configuration API for that matter and the ones that do certainly do not have to have one that is suitable for such an API we’re talking of. Besides those that like code abstractions over hard references would use the API because it makes good design sense. Those who don’t care about such things would not use the API.</p>
<p>OK – I’m still interested; let’s have a closer look.</p>
<h3>Features we like</h3>
<p>What kind of features would we like to have in our API?</p>
<ul>
<li>It is annoying when configuration code breaks when you refactor. <strong>Type safety</strong>? <a href="http://blog.jayway.com/wordpress/wp-content/uploads/2010/09/checksmall13.png" rel="lightbox"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="checksmall[13]" border="0" alt="checksmall[13]" src="http://blog.jayway.com/wordpress/wp-content/uploads/2010/09/checksmall13_thumb.png" width="20" height="20" /></a> </li>
<li>It would be nice if it was easy to use and that means easy to read. A <strong>fluent interface</strong>? <a href="http://blog.jayway.com/wordpress/wp-content/uploads/2010/09/checksmall.png" rel="lightbox"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="checksmall" border="0" alt="checksmall" src="http://blog.jayway.com/wordpress/wp-content/uploads/2010/09/checksmall_thumb.png" width="20" height="20" /></a> </li>
<li>If I need to add my own favorite feature it should be easy to do so. Open source with an <strong>easily extensible API</strong>? <a href="http://blog.jayway.com/wordpress/wp-content/uploads/2010/09/checksmall11.png" rel="lightbox"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="checksmall[11]" border="0" alt="checksmall[11]" src="http://blog.jayway.com/wordpress/wp-content/uploads/2010/09/checksmall11_thumb.png" width="20" height="20" /></a> </li>
<li>It should be easy to implement for your own IoC. Good use of a <strong>base class implementation</strong>? <a href="http://blog.jayway.com/wordpress/wp-content/uploads/2010/09/checksmall131.png" rel="lightbox"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="checksmall[13]" border="0" alt="checksmall[13]" src="http://blog.jayway.com/wordpress/wp-content/uploads/2010/09/checksmall13_thumb1.png" width="20" height="20" /></a> </li>
</ul>
<h3>Sample code</h3>
<p>It’s time to look at some sample code for this thing! There is more sample code on the project site and also a listing of the API in full.</p>
<p>This is what the code would look like when you use the API to configure your code; easy to understand, fluent, type safe!</p>
<p> <font style="font-weight: bold">
<pre class="code">ServiceConfigurator.RegisterType&lt;<span style="color: #2b91af">IFoo</span>, <span style="color: #2b91af">Foo</span>&gt;()
                   .InjectionConstructor(() =&gt; <span style="color: blue">new </span><span style="color: #2b91af">Foo</span>())
                   .InjectionProperties(f =&gt; f.Bar, f =&gt; f.Baz)
                   .AsSingleton();</pre>
<p></font></p>
<p>That looks just awesome! Yes indeed! Awesome and quite useful. It’s easy to see how this may be extended for specific purposes. (Doh – sorry I’ll try not to sound like a TV chef or a TV advertisement any more – sorry.)</p>
<p>The code above tells your IoC container that you want to register the implementation Foo as the target for requests for instances of the contract IFoo. It will tell the IoC container to use the parameterless constructor (it can use any constructor). It will also tell the IoC container to use the properties Bar and Baz for <a href="http://en.wikipedia.org/wiki/Dependency_injection">Dependency Injection</a>. Finally it will tell the IoC container to treat the instance of Foo as a <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton</a> instance once it is created.</p>
<p>The <a href="http://lambdas">lambdas</a> look messy! Do they? We don’t even notice any more in our project. They are there to ensure type safety and if you implement this API using the base class the expressions that make up this “mess” are parsed once and for all and converted into more easily handled parameters such as types and strings. If you change any of your configured classes and try to compile the configuration code it will not even compile.</p>
<h3>The what and the where</h3>
<p>If you feel this API would be pretty darn useful and nice to get your hands on you’re in luck! It’s already created and published under open source license on <a href="http://www.codeplex.com">CodePlex</a>.</p>
<p>So without further ado… Introducing</p>
<p><a href="http://commonservicemanager.codeplex.com/"><strong><font size="3">The Common Service Manager</font></strong></a></p>
<p>All the information you need about this project is up there on the site so this post does not need to go any further. If you hurry YOU can <a href="http://commonservicemanager.codeplex.com/wikipage?title=Contributing">contribute</a> with the implementation for your favorite IoC and claim the fame!</p>
<p>If you feel this project is missing one key feature please don’t hesitate to <a href="http://commonservicemanager.codeplex.com/discussions">provide feedback</a>!</p>
<h3>Final words</h3>
<p>Thanks to the great guys of coding for the inspirational <a href="http://commonservicelocator.codeplex.com/">Common Service Locator</a> project that set our team off in the direction to create a piece of code that extends your work. Together these two pieces of API make our every day much more easy and that is what code by developers and for developers is all about! (The title of this post is a paraphrase from <a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/08/16/it-s-time-for-ioc-container-detente.aspx">Jeremy Miller</a>s classic post.)</p>
<p>Cheers,</p>
<p>M.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2010/09/05/its-time-for-ioc-container-configuration-detente/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring Timeout with Apache HttpClient 4.0</title>
		<link>http://blog.jayway.com/2009/03/17/configuring-timeout-with-apache-httpclient-40/</link>
		<comments>http://blog.jayway.com/2009/03/17/configuring-timeout-with-apache-httpclient-40/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 15:49:23 +0000</pubDate>
		<dc:creator>Mattias Hellborg Arthursson</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[4.0]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[httpclient]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[timeout]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=1174</guid>
		<description><![CDATA[Great news everyone: just recently an all-new version of Apache HttpClient was released. HttpClient is now part of the new initiative Apache HttpComponents, which seems to aim for a complete approach to Http programming in Java; server side as well as client side. I've used Commons HttpClient in older versions on several occasions in the [...]]]></description>
			<content:encoded><![CDATA[<p>Great news everyone: just recently an all-new version of <a href="http://hc.apache.org/httpcomponents-client/index.html">Apache HttpClient</a> was released. HttpClient is now part of the new initiative <a href="http://hc.apache.org/">Apache HttpComponents</a>, which seems to aim for a complete approach to Http programming in Java; server side as well as client side.</p>
<p>I've used Commons HttpClient in older versions on several occasions in the past and have found it to be extremely useful. I've only just started working with the new version, but there seems to quite a lot of good stuff in there. For example I'm thrilled to see that the Template pattern, heavily used in Spring, has now made its way to the Apache world (e.g. <a href="http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/client/ResponseHandler.html">ResponseHandler</a>, a callback interface to be used with <a href="http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/client/HttpClient.html">HttpClient</a> for handling results).</p>
<p>Now, configuration of <code>HttpClient</code> has always been a little bit tricky. There are so many features in there, and most of these are configured using generic parameters (<code>HttpParams</code>), basically name-value pairs of a setting identifier and its value. This has not been made that much easier in the new version.</p>
<p>In my current project I was struggling to find the appropriate parameters for configuring timeouts with the new version of the framework. It turned out to be quite difficult to find clear information on this - the documentation on the 4.0 version of <code>HttpClient</code> is still quite sparse. Since it took me a while to find out how to do this I figured I wasn't alone, so here goes:</p>
<p>My original solution for this problem - being completely unable to find the proper way to do it - was to use the hard-coded property values and set them as parameters in <code>HttpParams</code>. Fortunately, a reader with signature 'BoD' (see below) knew the right way to do this and was kind enough to share. </p>
<p>Right, the code looks as follows:</p>
<pre class="java">&nbsp;
DefaultHttpClient httpClient = <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
HttpParams params = httpClient.<span style="color: #006600;">getParams</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
HttpConnectionParams.<span style="color: #006600;">setConnectionTimeout</span><span style="color: #66cc66;">&#40;</span>httpParams, connectionTimeoutMillis<span style="color: #66cc66;">&#41;</span>;
HttpConnectionParams.<span style="color: #006600;">setSoTimeout</span><span style="color: #66cc66;">&#40;</span>httpParams, socketTimeoutMillis<span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>Simple as that - hard to understand why that should take me so long to figure out <img src='http://blog.jayway.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Thanks again to 'BoD' for setting me straight on this.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2009/03/17/configuring-timeout-with-apache-httpclient-40/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

