<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Java-Based Configuration of Spring Dependency Injection</title>
	<atom:link href="http://www.basilv.com/psd/blog/2009/java-based-configuration-of-spring-dependency-injection/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.basilv.com/psd/blog/2009/java-based-configuration-of-spring-dependency-injection</link>
	<description></description>
	<lastBuildDate>Fri, 12 Mar 2010 03:55:20 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Bean Scoping in Spring Framework 2.0 &#171; Burak DEDE Weblog</title>
		<link>http://www.basilv.com/psd/blog/2009/java-based-configuration-of-spring-dependency-injection/comment-page-1#comment-96088</link>
		<dc:creator>Bean Scoping in Spring Framework 2.0 &#171; Burak DEDE Weblog</dc:creator>
		<pubDate>Sun, 16 Aug 2009 22:01:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.basilv.com/psd/?p=353#comment-96088</guid>
		<description>[...] Java-Based Configuration of Spring Dependency Injection (basilv.com) [...]</description>
		<content:encoded><![CDATA[<p>[...] Java-Based Configuration of Spring Dependency Injection (basilv.com) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Basil Vandegriend</title>
		<link>http://www.basilv.com/psd/blog/2009/java-based-configuration-of-spring-dependency-injection/comment-page-1#comment-89769</link>
		<dc:creator>Basil Vandegriend</dc:creator>
		<pubDate>Sat, 02 May 2009 03:42:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.basilv.com/psd/?p=353#comment-89769</guid>
		<description>Thanks Chris for the great comment. I&#039;ve updated the post to change the recommended approach to component-scanning. Your work on JavaConfig is much appreciated.</description>
		<content:encoded><![CDATA[<p>Thanks Chris for the great comment. I&#8217;ve updated the post to change the recommended approach to component-scanning. Your work on JavaConfig is much appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Beams</title>
		<link>http://www.basilv.com/psd/blog/2009/java-based-configuration-of-spring-dependency-injection/comment-page-1#comment-89738</link>
		<dc:creator>Chris Beams</dc:creator>
		<pubDate>Fri, 01 May 2009 19:22:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.basilv.com/psd/?p=353#comment-89738</guid>
		<description>Hi Basil,

A nice write up, and I&#039;m glad to hear you like what you&#039;re seeing.  I thought I&#039;d take a moment to address your questions and concerns:

&gt; Explicit bean declaration and DI vs. full component-scanning, vs. a mix of bean declaration and dependency autowiring:

I&#039;ll just speak from the experience that I and other SpringSource consultants have seen with real teams using Spring &#039;in the wild&#039;.  While explicit XML-based configuration is still very common, a large percentage of teams have taken to using component scanning liberally throughout their applications.  This does require a bit of educating the team as to how it works, but what doesn&#039;t?  The productivity benefits gained from not needing to return to the XML for every change seem to outweigh the initial and very short learning curve.  Making proper use of the @Service, @Repository annotations (as you did above) helps in this process.  The team gets to know what these annotations mean rather quickly.  I wouldn&#039;t underestimate developers too much.

I would generally advise against the third option you mention, of defining the bean definition explicitly, but allowing dependencies to be autowired.  This is a kind of &#039;one foot in, one foot out&#039; approach, and comes off a little bit like false advertising.  I find it the most confusing personally, and have heard the same sentiments in teams I&#039;ve consulted with.  I have actually never seen a serious application use this mix of explicit declaration and autowiring as a team standard.

Now, keep in mind that even if one agressively adopts component scanning and use of @Autowired, there is still, by necessity, a place for explicit bean declaration and wiring.  Any time you&#039;re dealing with a third party class (usually infrastructure-related, such as a DataSource), you of course must declare this explicitly in XML (or JavaConfig).

This sums up the best practice that I see with teams using Spring in a modern fashion:  Explicit wiring for infrastructure (JMS, JDBC, etc), and component-scan/@Autowired for the service and data access layers.

&gt; Component-scanning issues in Java EE application servers:

Spring&#039;s component scanning facility is pretty solid.  I know of no open issues around classloading problems in Java EE environments.  Using component scanning in an OSGi environment is more tricky, but even those problems have all been addressed in Spring DM and dm Server.

&gt; Future of JavaConfig

As you mentioned, essential JavaConfig functionality has been ported to Spring Core for the 3.0M3 release.  Although 3.0M3 has not yet dropped, the current phase of the porting effort is complete.  I&#039;d love it if you&#039;d take a look and provide feedback on what you see.

You can grab the latest nightly build snapshot of Spring 3.0 using Maven: http://pastebin.com/f472b1c7d.  Explore the org.springframework.context.annotation package to see what&#039;s there / what&#039;s new.  You&#039;ll see the familiar @Configuration, @Bean and @Import annotations; also you&#039;ll see that @Scope has been updated for use with @Bean methods, and there are also now @Lazy, @Primary and @DependsOn annotations that are usable with @Bean methods or at the class level in conjunction with @Component.

You&#039;ll notice that certain annotations and classes have not been ported, such as JavaConfig[Web]ApplicationContext, @ComponentScan, @AnnotationDrivenConfig and others.

Right now, in an effort to keep things as minimal as possible, the &#039;bootstrapping mechanism&#039; for JavaConfig is XML.  You can have a very minimal XML file such as this one: http://pastebin.com/f76cd1c59

There is an existing issue against Spring 3 to port the JavaConfig ApplicationContext implementations.  You may want to watch/vote/comment on that issue to stay tuned: http://jira.springframework.org/browse/SPR-5682

&gt; Compatibility issues between JavaConfig 1.0.0.M4 and Spring 3.0M2

Note that these issues have been worked out in the forthcoming Spring 3.0M3, so it&#039;s actually possible now to us JavaConfig 1.0.0.M4 against the nightly snapshots mentioned above.  This usage is mutually exclusive with the new functionality that&#039;s been ported into core, but you can use one or the other per your choice.

Again, all feedback is welcome, and thanks for your interest!

Chris Beams
Lead, Spring JavaConfig
http://springsource.org/javaconfig
twitter: @cbeams, @javaconfig</description>
		<content:encoded><![CDATA[<p>Hi Basil,</p>
<p>A nice write up, and I&#8217;m glad to hear you like what you&#8217;re seeing.  I thought I&#8217;d take a moment to address your questions and concerns:</p>
<p>> Explicit bean declaration and DI vs. full component-scanning, vs. a mix of bean declaration and dependency autowiring:</p>
<p>I&#8217;ll just speak from the experience that I and other SpringSource consultants have seen with real teams using Spring &#8216;in the wild&#8217;.  While explicit XML-based configuration is still very common, a large percentage of teams have taken to using component scanning liberally throughout their applications.  This does require a bit of educating the team as to how it works, but what doesn&#8217;t?  The productivity benefits gained from not needing to return to the XML for every change seem to outweigh the initial and very short learning curve.  Making proper use of the @Service, @Repository annotations (as you did above) helps in this process.  The team gets to know what these annotations mean rather quickly.  I wouldn&#8217;t underestimate developers too much.</p>
<p>I would generally advise against the third option you mention, of defining the bean definition explicitly, but allowing dependencies to be autowired.  This is a kind of &#8216;one foot in, one foot out&#8217; approach, and comes off a little bit like false advertising.  I find it the most confusing personally, and have heard the same sentiments in teams I&#8217;ve consulted with.  I have actually never seen a serious application use this mix of explicit declaration and autowiring as a team standard.</p>
<p>Now, keep in mind that even if one agressively adopts component scanning and use of @Autowired, there is still, by necessity, a place for explicit bean declaration and wiring.  Any time you&#8217;re dealing with a third party class (usually infrastructure-related, such as a DataSource), you of course must declare this explicitly in XML (or JavaConfig).</p>
<p>This sums up the best practice that I see with teams using Spring in a modern fashion:  Explicit wiring for infrastructure (JMS, JDBC, etc), and component-scan/@Autowired for the service and data access layers.</p>
<p>> Component-scanning issues in Java EE application servers:</p>
<p>Spring&#8217;s component scanning facility is pretty solid.  I know of no open issues around classloading problems in Java EE environments.  Using component scanning in an OSGi environment is more tricky, but even those problems have all been addressed in Spring DM and dm Server.</p>
<p>> Future of JavaConfig</p>
<p>As you mentioned, essential JavaConfig functionality has been ported to Spring Core for the 3.0M3 release.  Although 3.0M3 has not yet dropped, the current phase of the porting effort is complete.  I&#8217;d love it if you&#8217;d take a look and provide feedback on what you see.</p>
<p>You can grab the latest nightly build snapshot of Spring 3.0 using Maven: <a href="http://pastebin.com/f472b1c7d" rel="nofollow">http://pastebin.com/f472b1c7d</a>.  Explore the org.springframework.context.annotation package to see what&#8217;s there / what&#8217;s new.  You&#8217;ll see the familiar @Configuration, @Bean and @Import annotations; also you&#8217;ll see that @Scope has been updated for use with @Bean methods, and there are also now @Lazy, @Primary and @DependsOn annotations that are usable with @Bean methods or at the class level in conjunction with @Component.</p>
<p>You&#8217;ll notice that certain annotations and classes have not been ported, such as JavaConfig[Web]ApplicationContext, @ComponentScan, @AnnotationDrivenConfig and others.</p>
<p>Right now, in an effort to keep things as minimal as possible, the &#8216;bootstrapping mechanism&#8217; for JavaConfig is XML.  You can have a very minimal XML file such as this one: <a href="http://pastebin.com/f76cd1c59" rel="nofollow">http://pastebin.com/f76cd1c59</a></p>
<p>There is an existing issue against Spring 3 to port the JavaConfig ApplicationContext implementations.  You may want to watch/vote/comment on that issue to stay tuned: <a href="http://jira.springframework.org/browse/SPR-5682" rel="nofollow">http://jira.springframework.org/browse/SPR-5682</a></p>
<p>> Compatibility issues between JavaConfig 1.0.0.M4 and Spring 3.0M2</p>
<p>Note that these issues have been worked out in the forthcoming Spring 3.0M3, so it&#8217;s actually possible now to us JavaConfig 1.0.0.M4 against the nightly snapshots mentioned above.  This usage is mutually exclusive with the new functionality that&#8217;s been ported into core, but you can use one or the other per your choice.</p>
<p>Again, all feedback is welcome, and thanks for your interest!</p>
<p>Chris Beams<br />
Lead, Spring JavaConfig<br />
<a href="http://springsource.org/javaconfig" rel="nofollow">http://springsource.org/javaconfig</a><br />
twitter: @cbeams, @javaconfig</p>
]]></content:encoded>
	</item>
</channel>
</rss>
