<?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>Justin Dag &#187; spring</title>
	<atom:link href="http://justindag.com/tag/spring/feed/" rel="self" type="application/rss+xml" />
	<link>http://justindag.com</link>
	<description></description>
	<lastBuildDate>Fri, 26 Mar 2010 16:29:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Grails, Constructor Injection, and Spring Bean Builders</title>
		<link>http://justindag.com/2008/07/grails-constructor-injection-and-spring-bean-builders/</link>
		<comments>http://justindag.com/2008/07/grails-constructor-injection-and-spring-bean-builders/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 01:40:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://justindag.com/?p=4</guid>
		<description><![CDATA[Had a run-in with Grails and trying to wire up some custom beans using Grails&#8217;s Spring Bean Builder DSL mechanism.   I was wiring up an instance of the Apache HttpClient object, which can be constructed with HttpClientParams and/or HttpConnectionManager.  Now the Grails BB syntax expects the first argument to be the type [...]]]></description>
			<content:encoded><![CDATA[<p>Had a run-in with Grails and trying to wire up some custom beans using Grails&#8217;s Spring Bean Builder DSL mechanism.   I was wiring up an instance of the Apache HttpClient object, which can be constructed with HttpClientParams and/or HttpConnectionManager.  Now the Grails BB syntax expects the first argument to be the type you&#8217;re wiring, followed by the parameters to pass into the constructor.  Something like this:<br />
<code>httpClient(org.apache.commons.httpclient.HttpClient, defaultGlobalHttpConnectionManager)</code></p>
<p>Where httpClient is the bean name/id, <code>org.apache.commons.httpclient.HttpClient</code> is the type we&#8217;re wiring, and defaultGlobalHttpConnectionManager is some custom implementation of the HttpConnectionManager.</p>
<p>When using this Bean Builder syntax, Grails gets consfused about the argument ordering and is unable to create its Grails Application Context.  I also tried the following which didn&#8217;t work either.<br />
<code>httpClient(org.apache.commons.httpclient.HttpClient, null,<br />
defaultGlobalHttpConnectionManager)</code></p>
<p>I don&#8217;t know if you can explicitly set the arguments the same way you can in the standard XML wiring approach.   My solution was then to use the tried and true method.</p>
<p><code>&lt;bean id="defaultGlobalHttpConnectionManager"<br />
class="com.site.commons.http.GlobalHttpConnectionManager"<br />
destroy-method="shutDown" lazy-init="default" autowire="default"<br />
dependency-check="default"&gt;<br />
&lt;property name="soTimeout"&gt;<br />
&lt;value&gt;20000&lt;/value&gt;<br />
&lt;/property&gt;<br />
&lt;property name="connectionTimeout"&gt;<br />
&lt;value&gt;20000&lt;/value &gt;<br />
&lt;/property&gt;<br />
&lt;/bean&gt;</code><br />
<code><br />
&lt;bean id="httpClient"<br />
class="org.apache.commons.httpclient.HttpClient" lazy-init="default"<br />
autowire="default"<br />
dependency-check="default"&gt;<br />
&lt;constructor-arg ref="defaultGlobalHttpConnectionManager" /&gt;<br />
&lt;/bean&gt;<br />
</code><br />
<strong>Resources:</strong><br />
<a href="http://grails.org/doc/1.0.x/">http://grails.org/doc/1.0.x/</a><br />
<a href="http://hc.apache.org/httpclient-3.x/apidocs/index.html">http://hc.apache.org/httpclient-3.x/apidocs/index.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://justindag.com/2008/07/grails-constructor-injection-and-spring-bean-builders/feed/</wfw:commentRss>
		<slash:comments>186</slash:comments>
		</item>
	</channel>
</rss>

