<?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: Dependency injection with Groovy and Google Guice</title>
	<atom:link href="http://blog.stannard.net.au/2010/05/18/dependency-injection-with-groovy-and-google-guice/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.stannard.net.au/2010/05/18/dependency-injection-with-groovy-and-google-guice/</link>
	<description></description>
	<lastBuildDate>Sun, 08 Jan 2012 15:53:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: Kevan Stannard</title>
		<link>http://blog.stannard.net.au/2010/05/18/dependency-injection-with-groovy-and-google-guice/comment-page-1/#comment-1413</link>
		<dc:creator>Kevan Stannard</dc:creator>
		<pubDate>Fri, 04 Feb 2011 03:37:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stannard.net.au/?p=150#comment-1413</guid>
		<description>Comment posted to the groovy mailing list about this entry from Brian Schlining:

Only thing I might add is to mention the use of the @Named annotation. It&#039;s one way to bind the same interface or class to different implementations. Here&#039;s a contrived example that injects different JPA EntityManagerFactories :

class FooDaoFactory {
    def entityManagerFactory;

    @Inject
    public FooDaoFactory(@Named(&quot;persist-unit-foo&quot;) EntityManagerFactory entityManagerFactory) {
        this.entityManagerFactory = entityManagerFactory;

    }
}

class BarDaoFactory {
    def entityManagerFactory;

    @Inject
    public BarDaoFactory(@Named(&quot;persist-unit-bar&quot;) EntityManagerFactory entityManagerFactory) {
        this.entityManagerFactory = entityManagerFactory;

    }
}
 

binder.bind(EntityManagerFactory.class).annotatedWith(Names.named(&quot;persist-unit-foo&quot;)).toInstance(Persistence.createEntityManagerFactory(&quot;fooUnit&quot;));
        
binder.bind(EntityManagerFactory.class).annotatedWith(Names.named(&quot;persist-unit-bar&quot;)).toInstance(Persistence.createEntityManagerFactory(&quot;barUnit&quot;));

def injector = Guice.createInjector()
def foo = injector.getInstance(FooDaoFactory.class);
def bar = injector.getInstance(BarDaoFactory.class);</description>
		<content:encoded><![CDATA[<p>Comment posted to the groovy mailing list about this entry from Brian Schlining:</p>
<p>Only thing I might add is to mention the use of the @Named annotation. It&#8217;s one way to bind the same interface or class to different implementations. Here&#8217;s a contrived example that injects different JPA EntityManagerFactories :</p>
<p>class FooDaoFactory {<br />
    def entityManagerFactory;</p>
<p>    @Inject<br />
    public FooDaoFactory(@Named(&#8220;persist-unit-foo&#8221;) EntityManagerFactory entityManagerFactory) {<br />
        this.entityManagerFactory = entityManagerFactory;</p>
<p>    }<br />
}</p>
<p>class BarDaoFactory {<br />
    def entityManagerFactory;</p>
<p>    @Inject<br />
    public BarDaoFactory(@Named(&#8220;persist-unit-bar&#8221;) EntityManagerFactory entityManagerFactory) {<br />
        this.entityManagerFactory = entityManagerFactory;</p>
<p>    }<br />
}</p>
<p>binder.bind(EntityManagerFactory.class).annotatedWith(Names.named(&#8220;persist-unit-foo&#8221;)).toInstance(Persistence.createEntityManagerFactory(&#8220;fooUnit&#8221;));</p>
<p>binder.bind(EntityManagerFactory.class).annotatedWith(Names.named(&#8220;persist-unit-bar&#8221;)).toInstance(Persistence.createEntityManagerFactory(&#8220;barUnit&#8221;));</p>
<p>def injector = Guice.createInjector()<br />
def foo = injector.getInstance(FooDaoFactory.class);<br />
def bar = injector.getInstance(BarDaoFactory.class);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevan Stannard</title>
		<link>http://blog.stannard.net.au/2010/05/18/dependency-injection-with-groovy-and-google-guice/comment-page-1/#comment-843</link>
		<dc:creator>Kevan Stannard</dc:creator>
		<pubDate>Tue, 18 May 2010 20:12:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stannard.net.au/?p=150#comment-843</guid>
		<description>No problem Wim. Yes, planning to use Guice. It looks like a nice lightweight annotation based DI framwork.</description>
		<content:encoded><![CDATA[<p>No problem Wim. Yes, planning to use Guice. It looks like a nice lightweight annotation based DI framwork.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wim Molenberghs</title>
		<link>http://blog.stannard.net.au/2010/05/18/dependency-injection-with-groovy-and-google-guice/comment-page-1/#comment-842</link>
		<dc:creator>Wim Molenberghs</dc:creator>
		<pubDate>Tue, 18 May 2010 17:06:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stannard.net.au/?p=150#comment-842</guid>
		<description>Thanks for the credits ;-)

Nice introduction for Groovy.
Are you planning to use Guice in your next projects?</description>
		<content:encoded><![CDATA[<p>Thanks for the credits <img src='http://blog.stannard.net.au/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Nice introduction for Groovy.<br />
Are you planning to use Guice in your next projects?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

