<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>tag:www.nabble.com,2006:forum-2737</id>
	<title>Nabble - NanoContainer - PicoContainer - Users</title>
	<updated>2008-12-02T08:01:33Z</updated>
	<link rel="self" type="application/atom+xml" href="http://www.nabble.com/NanoContainer---PicoContainer---Users-f2737.xml" />
	<link rel="alternate" type="text/html" href="http://www.nabble.com/NanoContainer---PicoContainer---Users-f2737.html" />
	<subtitle type="html"></subtitle>
	
<entry>
	<id>tag:www.nabble.com,2006:post-20795266</id>
	<title>Re: Java configurator</title>
	<published>2008-12-02T08:01:33Z</published>
	<updated>2008-12-02T08:01:33Z</updated>
	<author>
		<name>Paul Hammant-3</name>
	</author>
	<content type="html">This is really interesting. &amp;nbsp;Glassfish and Derby are top rated &amp;nbsp;
&lt;br&gt;technologies for web apps, and to have some PicoContainer-leveraging &amp;nbsp;
&lt;br&gt;way of setting them up would be cool.
&lt;br&gt;&lt;br&gt;We have a Jetty binding ( &lt;a href=&quot;https://svn.codehaus.org/picocontainer/java/2.x/trunk/jetty&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://svn.codehaus.org/picocontainer/java/2.x/trunk/jetty&lt;/a&gt;&amp;nbsp;
&lt;br&gt;&amp;nbsp; ). &amp;nbsp;It is wedded to Jetty though with no abstraction that Tomcat or &amp;nbsp;
&lt;br&gt;Glassfish could take advantage of.
&lt;br&gt;&lt;br&gt;Tell us more, and introduce yourself a little :-)
&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&lt;br&gt;- Paul
&lt;br&gt;&lt;br&gt;On Dec 1, 2008, at 7:30 PM, devantor wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi, &amp;nbsp;congrats for your project! &amp;nbsp;I'm using pico to create a webapp &amp;nbsp;
&lt;br&gt;&amp;gt; with Derby and Glassfish embedded. &amp;nbsp;I created a java configurator &amp;nbsp;
&lt;br&gt;&amp;gt; using annotations. My setup allows me to swap to another container. &amp;nbsp; 
&lt;br&gt;&amp;gt; I use the factory and constructor pattern because I don't want to &amp;nbsp;
&lt;br&gt;&amp;gt; use @inject everywhere, the less intrusive the better.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; My project is using picocontainer snaphot with maven. &amp;nbsp;I want to &amp;nbsp;
&lt;br&gt;&amp;gt; contribute the config part if it's useful for you.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; A file created in META-INF/dfxcontainer.
&lt;br&gt;&amp;gt; properties setup the container factory to use.
&lt;br&gt;&amp;gt; dfx 
&lt;br&gt;&amp;gt; .common 
&lt;br&gt;&amp;gt; .container.factory=dfx.common.container.ContainerFactoryTestImpl
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; META-INF/dfxconfig.properties
&lt;br&gt;&amp;gt; dfx.configs=dfx.common.config.Config1,dfx.common.config.Config2
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Examples:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; @DfxContainer(scope = ContainerScope1.class)
&lt;br&gt;&amp;gt; public class Config1 implements DfxConfig {
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; @DfxContainerComponent(key = ComponentA.class)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; public ComponentAImpl componentA;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; @DfxComponent(id = &amp;quot;core-test&amp;quot;)
&lt;br&gt;&amp;gt; @DfxContainer(scope = ComponentScope.class)
&lt;br&gt;&amp;gt; public class CoreTestConfig implements DfxConfig {
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; @DfxContainerComponent(key = dfx.core.dao.DAOFacadeMock.class)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; public dfx.core.dao.DAOFacadeMock daoFacadeMock;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; @DfxContainerComponent(key = &amp;nbsp;
&lt;br&gt;&amp;gt; dfx.core.plugin.IndexerPluginTest.class)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; @DfxIndexerPlugin(extensions = { &amp;quot;extA&amp;quot;, &amp;quot;extB&amp;quot; }, params = {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @DfxParam(id = &amp;quot;paramA&amp;quot;, values = { &amp;quot;valueA&amp;quot; }),
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @DfxParam(id = &amp;quot;paramB&amp;quot;, values = { &amp;quot;valueB&amp;quot; }) }, &amp;nbsp;
&lt;br&gt;&amp;gt; searchFields = {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @DfxSearchField(value = &amp;quot;searchFieldA&amp;quot;, visible = true),
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @DfxSearchField(value = &amp;quot;searchFieldB&amp;quot;, visible = &amp;nbsp;
&lt;br&gt;&amp;gt; false) })
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; public dfx.core.plugin.IndexerPluginTest indexerPluginTest;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; }
&lt;/div&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Java-configurator-tp20785436p20795266.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20794970</id>
	<title>Re: BasicComponentParameter doesn't work with parameterized types</title>
	<published>2008-12-02T07:49:45Z</published>
	<updated>2008-12-02T07:49:45Z</updated>
	<author>
		<name>Paul Hammant-3</name>
	</author>
	<content type="html">Yeah, you'll most likely have to make that anon-inner class non-anon, &amp;nbsp;
&lt;br&gt;and make it public. &amp;nbsp;There's a dumbass JVM rule about methods being &amp;nbsp;
&lt;br&gt;inaccessible despite being public if the class containing them is &amp;nbsp;
&lt;br&gt;private (implicitly anon-inner ones are).
&lt;br&gt;&lt;br&gt;There's no setAccessible() that can be done via reflection, it would &amp;nbsp;
&lt;br&gt;have to be an ASM solution to allow more elegant anon-inner usage.
&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&lt;br&gt;- Paul
&lt;br&gt;&lt;br&gt;On Dec 2, 2008, at 6:33 AM, Paul Hammant wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi Daniel,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Most likely we're not going to do the most fine-grained features of &amp;nbsp;
&lt;br&gt;&amp;gt; Generics until PicoContainer 3.0 ( most of the API that refers to &amp;nbsp;
&lt;br&gt;&amp;gt; Class will be changed to refer to Type instead, and we'll do some &amp;nbsp;
&lt;br&gt;&amp;gt; capturing of potentially erased types on addComponent methods).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; For now though, there is a very elegant PicoContainer 2.6+ way to do &amp;nbsp;
&lt;br&gt;&amp;gt; what you want :
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;@Test
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;public void &amp;nbsp;
&lt;br&gt;&amp;gt; testCan_Use_Provider_As_Workaround_For_with_Generic_Type() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;final DefaultPicoContainer pico = new DefaultPicoContainer();
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(FictionFactory.class);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(NonFictionFactory.class);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addAdapter(new ProviderAdapter() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public Object getComponentKey() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return &amp;quot;bookHelperUsingFiction&amp;quot;;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// depend on what you like in the args for the provide &amp;nbsp;
&lt;br&gt;&amp;gt; method......
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public BookHelper provide(FictionFactory fictionFactory) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return new BookHelper(fictionFactory);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;});
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Object component = pico.getComponent(&amp;quot;bookHelperUsingFiction&amp;quot;);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertNotNull(component);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Regards,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; - Paul
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On Dec 1, 2008, at 5:43 PM, Daniel Wellman wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Reposting the code since the HTML formatting ate all the &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; parameterized types.
&lt;br&gt;&amp;gt;&amp;gt; Doh!
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;public void &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; testCannot_Use_BasicComponentParameter_with_Generic_Type() {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; DefaultPicoContainer pico = new DefaultPicoContainer();
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; pico.addComponent(FictionFactory.class);
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; pico.addComponent(NonFictionFactory.class);
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; // This throws a java.lang.ClassCastException:
&lt;br&gt;&amp;gt;&amp;gt; sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; pico.addComponent(&amp;quot;bookHelperUsingFiction&amp;quot;, BookHelper.class, new
&lt;br&gt;&amp;gt;&amp;gt; BasicComponentParameter(FictionFactory.class));
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; Object component = pico.getComponent(&amp;quot;bookHelperUsingFiction&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; assertNotNull(component);
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;}
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;public static class BookHelper&amp;lt;T&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; BookFactory&amp;lt;T&amp;gt; factory;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; // The test above passes if BookFactory does not have a &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; parameterized
&lt;br&gt;&amp;gt;&amp;gt; type, e.g.
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; // if it's publicBookHelper(BookFactory newFactory) { ... }
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; public BookHelper(BookFactory&amp;lt;T&amp;gt; newFactory) {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.factory = newFactory;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;}
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;public static interface BookFactory&amp;lt;T&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; T build();
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;}
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;public static class FictionFactory implements BookFactory&amp;lt;Fiction&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; public Fiction build() {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return new Fiction();
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;}
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;public static class NonFictionFactory implements &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; BookFactory&amp;lt;NonFiction&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; public NonFiction build() {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return new NonFiction();
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;}
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;static class Fiction {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;}
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;static class NonFiction {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;}
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; -- 
&lt;br&gt;&amp;gt;&amp;gt; View this message in context: &lt;a href=&quot;http://www.nabble.com/BasicComponentParameter-doesn%27t-work-with-parameterized-types-tp20784248p20784451.html&quot; target=&quot;_top&quot;&gt;http://www.nabble.com/BasicComponentParameter-doesn%27t-work-with-parameterized-types-tp20784248p20784451.html&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; Sent from the NanoContainer - PicoContainer - Users mailing list &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; archive at Nabble.com.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; ---------------------------------------------------------------------
&lt;br&gt;&amp;gt;&amp;gt; To unsubscribe from this list, please visit:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ---------------------------------------------------------------------
&lt;br&gt;&amp;gt; To unsubscribe from this list, please visit:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/BasicComponentParameter-doesn%27t-work-with-parameterized-types-tp20784248p20794970.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20793453</id>
	<title>Re: BasicComponentParameter doesn't work with parameterized types</title>
	<published>2008-12-02T06:33:00Z</published>
	<updated>2008-12-02T06:33:00Z</updated>
	<author>
		<name>Paul Hammant-3</name>
	</author>
	<content type="html">Hi Daniel,
&lt;br&gt;&lt;br&gt;Most likely we're not going to do the most fine-grained features of &amp;nbsp;
&lt;br&gt;Generics until PicoContainer 3.0 ( most of the API that refers to &amp;nbsp;
&lt;br&gt;Class will be changed to refer to Type instead, and we'll do some &amp;nbsp;
&lt;br&gt;capturing of potentially erased types on addComponent methods).
&lt;br&gt;&lt;br&gt;For now though, there is a very elegant PicoContainer 2.6+ way to do &amp;nbsp;
&lt;br&gt;what you want :
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;@Test
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;public void &amp;nbsp;
&lt;br&gt;testCan_Use_Provider_As_Workaround_For_with_Generic_Type() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;final DefaultPicoContainer pico = new DefaultPicoContainer();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(FictionFactory.class);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(NonFictionFactory.class);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addAdapter(new ProviderAdapter() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public Object getComponentKey() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return &amp;quot;bookHelperUsingFiction&amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// depend on what you like in the args for the provide &amp;nbsp;
&lt;br&gt;method......
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public BookHelper provide(FictionFactory fictionFactory) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return new BookHelper(fictionFactory);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;});
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Object component = pico.getComponent(&amp;quot;bookHelperUsingFiction&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertNotNull(component);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&lt;br&gt;- Paul
&lt;br&gt;&lt;br&gt;On Dec 1, 2008, at 5:43 PM, Daniel Wellman wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Reposting the code since the HTML formatting ate all the &amp;nbsp;
&lt;br&gt;&amp;gt; parameterized types.
&lt;br&gt;&amp;gt; Doh!
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public void &amp;nbsp;
&lt;br&gt;&amp;gt; testCannot_Use_BasicComponentParameter_with_Generic_Type() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;DefaultPicoContainer pico = new DefaultPicoContainer();
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(FictionFactory.class);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(NonFictionFactory.class);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;// This throws a java.lang.ClassCastException:
&lt;br&gt;&amp;gt; sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(&amp;quot;bookHelperUsingFiction&amp;quot;, BookHelper.class, new
&lt;br&gt;&amp;gt; BasicComponentParameter(FictionFactory.class));
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;Object component = pico.getComponent(&amp;quot;bookHelperUsingFiction&amp;quot;);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertNotNull(component);
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public static class BookHelper&amp;lt;T&amp;gt; {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;BookFactory&amp;lt;T&amp;gt; factory;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;// The test above passes if BookFactory does not have a &amp;nbsp;
&lt;br&gt;&amp;gt; parameterized
&lt;br&gt;&amp;gt; type, e.g.
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;// if it's publicBookHelper(BookFactory newFactory) { ... }
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;public BookHelper(BookFactory&amp;lt;T&amp;gt; newFactory) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.factory = newFactory;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public static interface BookFactory&amp;lt;T&amp;gt; {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;T build();
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public static class FictionFactory implements BookFactory&amp;lt;Fiction&amp;gt; {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;public Fiction build() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return new Fiction();
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public static class NonFictionFactory implements &amp;nbsp;
&lt;br&gt;&amp;gt; BookFactory&amp;lt;NonFiction&amp;gt;
&lt;br&gt;&amp;gt; {
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;public NonFiction build() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return new NonFiction();
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; static class Fiction {
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; static class NonFiction {
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://www.nabble.com/BasicComponentParameter-doesn%27t-work-with-parameterized-types-tp20784248p20784451.html&quot; target=&quot;_top&quot;&gt;http://www.nabble.com/BasicComponentParameter-doesn%27t-work-with-parameterized-types-tp20784248p20784451.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the NanoContainer - PicoContainer - Users mailing list &amp;nbsp;
&lt;br&gt;&amp;gt; archive at Nabble.com.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ---------------------------------------------------------------------
&lt;br&gt;&amp;gt; To unsubscribe from this list, please visit:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/BasicComponentParameter-doesn%27t-work-with-parameterized-types-tp20784248p20793453.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20785436</id>
	<title>Java configurator</title>
	<published>2008-12-01T19:30:35Z</published>
	<updated>2008-12-01T19:30:35Z</updated>
	<author>
		<name>devantor</name>
	</author>
	<content type="html">Hi,&amp;nbsp; congrats for your project!&amp;nbsp; I&amp;#39;m using pico to create a webapp with
Derby and Glassfish embedded.&amp;nbsp; I created a java configurator using
annotations. My setup allows me to swap to another container.&amp;nbsp; I use
the factory and constructor pattern because I don&amp;#39;t want to use @inject
everywhere, the less intrusive the better. &lt;br&gt;
&lt;br&gt;My project is using picocontainer snaphot with maven.&amp;nbsp; I want to contribute the config part if it&amp;#39;s useful for you.&lt;br&gt;&lt;br&gt;&lt;br&gt;A file created in META-INF/dfxcontainer.&lt;div id=&quot;:17e&quot; class=&quot;ArwC7c ckChnd&quot;&gt;properties setup the container factory to use.&lt;br&gt;

dfx.common.container.factory=dfx.common.container.ContainerFactoryTestImpl&lt;br&gt;&lt;br&gt;META-INF/dfxconfig.properties&lt;br&gt;dfx.configs=dfx.common.config.Config1,dfx.common.config.Config2&lt;br&gt;&lt;br&gt;Examples:&lt;br&gt;&lt;br&gt;@DfxContainer(scope = ContainerScope1.class)
&lt;br&gt;public class Config1 implements DfxConfig {
&lt;br&gt;&amp;nbsp;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @DfxContainerComponent(key = ComponentA.class)
&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public ComponentAImpl componentA;
&lt;br&gt;&amp;nbsp;&lt;br&gt;}&lt;br&gt;&lt;br&gt; &lt;br&gt;@DfxComponent(id = &amp;quot;core-test&amp;quot;)
&lt;br&gt;@DfxContainer(scope = ComponentScope.class)
&lt;br&gt;public class CoreTestConfig implements DfxConfig {
&lt;br&gt;&amp;nbsp;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @DfxContainerComponent(key = dfx.core.dao.DAOFacadeMock.class)
&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public dfx.core.dao.DAOFacadeMock daoFacadeMock;
&lt;br&gt;&amp;nbsp;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @DfxContainerComponent(key = dfx.core.plugin.IndexerPluginTest.class)
&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @DfxIndexerPlugin(extensions = { &amp;quot;extA&amp;quot;, &amp;quot;extB&amp;quot; }, params = {
&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @DfxParam(id = &amp;quot;paramA&amp;quot;, values = { &amp;quot;valueA&amp;quot; }),
&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @DfxParam(id = &amp;quot;paramB&amp;quot;, values = { &amp;quot;valueB&amp;quot; }) }, searchFields = {
&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @DfxSearchField(value = &amp;quot;searchFieldA&amp;quot;, visible = true),
&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @DfxSearchField(value = &amp;quot;searchFieldB&amp;quot;, visible = false) })
&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public dfx.core.plugin.IndexerPluginTest indexerPluginTest;
&lt;br&gt;&amp;nbsp;&lt;br&gt;}
&lt;br&gt;&lt;/div&gt;
</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Java-configurator-tp20785436p20785436.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20784451</id>
	<title>Re: BasicComponentParameter doesn't work with parameterized types</title>
	<published>2008-12-01T17:43:13Z</published>
	<updated>2008-12-01T17:43:13Z</updated>
	<author>
		<name>Daniel Wellman</name>
	</author>
	<content type="html">Reposting the code since the HTML formatting ate all the parameterized types. &amp;nbsp;Doh!
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public void testCannot_Use_BasicComponentParameter_with_Generic_Type() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; DefaultPicoContainer pico = new DefaultPicoContainer();
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; pico.addComponent(FictionFactory.class);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; pico.addComponent(NonFictionFactory.class);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // This throws a java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; pico.addComponent(&amp;quot;bookHelperUsingFiction&amp;quot;, BookHelper.class, new BasicComponentParameter(FictionFactory.class));
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Object component = pico.getComponent(&amp;quot;bookHelperUsingFiction&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; assertNotNull(component);
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public static class BookHelper&amp;lt;T&amp;gt; {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; BookFactory&amp;lt;T&amp;gt; factory;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // The test above passes if BookFactory does not have a parameterized type, e.g.
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // if it's publicBookHelper(BookFactory newFactory) { ... }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; public BookHelper(BookFactory&amp;lt;T&amp;gt; newFactory) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.factory = newFactory;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public static interface BookFactory&amp;lt;T&amp;gt; {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; T build();
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public static class FictionFactory implements BookFactory&amp;lt;Fiction&amp;gt; {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; public Fiction build() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return new Fiction();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public static class NonFictionFactory implements BookFactory&amp;lt;NonFiction&amp;gt; {
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; public NonFiction build() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return new NonFiction();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;static class Fiction {
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;static class NonFiction {
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/BasicComponentParameter-doesn%27t-work-with-parameterized-types-tp20784248p20784451.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20784248</id>
	<title>BasicComponentParameter doesn't work with parameterized types</title>
	<published>2008-12-01T17:21:23Z</published>
	<updated>2008-12-01T17:21:23Z</updated>
	<author>
		<name>Daniel Wellman</name>
	</author>
	<content type="html">It looks like PicoContainer 2 from trunk does not allow specifying BasicComponentParameters when the target parameter has a generic/parameterized type.  The following code example produces this ClassCastException:

&lt;pre&gt;
java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
	at org.picocontainer.parameters.BasicComponentParameter.resolveInstance(BasicComponentParameter.java:161)
	at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:67)
	at org.picocontainer.injectors.SingleMemberInjector.getMemberArguments(SingleMemberInjector.java:53)
	at org.picocontainer.injectors.ConstructorInjector.getMemberArguments(ConstructorInjector.java:240)
	at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:199)
	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:289)
	at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:229)
	at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:573)
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:537)
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:514)
	at com.myexample.picocontainer.PicoAcceptanceTest.testCannot_Use_BasicComponentParameter_with_Generic_Type(PicoAcceptanceTest.java:152)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
&lt;/pre&gt;

Here's the example:

&lt;pre&gt;
   public void testCannot_Use_BasicComponentParameter_with_Generic_Type() {
      DefaultPicoContainer pico = new DefaultPicoContainer();

      pico.addComponent(FictionFactory.class);
      pico.addComponent(NonFictionFactory.class);
      pico.addComponent(&quot;bookHelperUsingFiction&quot;, BookHelper.class, new BasicComponentParameter(FictionFactory.class));

      // This throws a java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
      Object component = pico.getComponent(&quot;bookHelperUsingFiction&quot;);
      assertNotNull(component);
   }

   public static class BookHelper&lt;T&gt; {
      BookFactory&lt;T&gt; factory;

      // The test above passes if BookFactory does not have a parameterized type, e.g.
      // if it's publicBookHelper(BookFactory newFactory) { ... }
      public BookHelper(BookFactory&lt;T&gt; newFactory) {
         this.factory = newFactory;
      }
   }

   public static interface BookFactory&lt;T&gt; {
      T build();
   }

   public static class FictionFactory implements BookFactory&lt;Fiction&gt; {
      public Fiction build() {
         return new Fiction();
      }
   }

   public static class NonFictionFactory implements BookFactory&lt;NonFiction&gt; {

      public NonFiction build() {
         return new NonFiction();
      }
   }

   static class Fiction {
   }

   static class NonFiction {
   }
&lt;/pre&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/BasicComponentParameter-doesn%27t-work-with-parameterized-types-tp20784248p20784248.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20764507</id>
	<title>Re: Problem with annotation injection in abstract classes</title>
	<published>2008-11-30T17:04:38Z</published>
	<updated>2008-11-30T17:04:38Z</updated>
	<author>
		<name>Paul Hammant-3</name>
	</author>
	<content type="html">&lt;html&gt;&lt;body style=&quot;word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; &quot;&gt;Yeah, I can repro and have fixed. &amp;nbsp;It was to do with AdaptingInjection which has duplicate code for sniffing for the @Inject annotation.&lt;div apple-content-edited=&quot;true&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; &quot;&gt;&lt;div style=&quot;word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; &quot;&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;- Paul&lt;/div&gt;&lt;/div&gt;&lt;/span&gt; &lt;/div&gt;&lt;br&gt;&lt;div&gt;&lt;div&gt;On Nov 30, 2008, at 4:43 AM, Jonathan Ariel wrote:&lt;/div&gt;&lt;br class=&quot;Apple-interchange-newline&quot;&gt;&lt;blockquote type=&quot;cite&quot;&gt;You are right... it is working, the problem appears when you use withAutomatic() instead of withAnnotatedFieldInjection().&lt;br&gt;In my case I need both annotation and constructor injection. Do you think that it should work when using withAutomatic?&lt;br&gt; &lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Sat, Nov 29, 2008 at 12:01 PM, Paul Hammant &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20764507&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;paul@...&lt;/a&gt;&gt;&lt;/span&gt; wrote:&lt;br&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt; &lt;div style=&quot;&quot;&gt;Jonathan.&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;I can't reproduce :-(&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Is the following representative ...............&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static abstract class A2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Inject&lt;/div&gt; &lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;protected D2 d2;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static abstract class B2 extends A2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static class C2 extends B2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static class D2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;@Test&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public void testThatEvenMoreSuperClassCanHaveAnnotatedFields() {&lt;/div&gt;&lt;div class=&quot;Ih2E3d&quot;&gt;&lt;div&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MutablePicoContainer container = new PicoBuilder().withAnnotatedFieldInjection().build();&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;container.addComponent(D2.class);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;container.addComponent(C2.class);&lt;/div&gt;&lt;div&gt;&lt;br&gt; &lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C2 c2 = container.getComponent(C2.class);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertNotNull(c2);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertNotNull(c2.d2);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;div&gt; &lt;span style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;div&gt;Regards,&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;- Paul&lt;/div&gt;&lt;/div&gt;&lt;/span&gt; &lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class=&quot;Wj3C7c&quot;&gt;&lt;br&gt;&lt;div&gt;&lt;div&gt;On Nov 27, 2008, at 3:06 PM, Jonathan Ariel wrote:&lt;/div&gt;&lt;br&gt;&lt;blockquote type=&quot;cite&quot;&gt;I seems to still have problems with this... and it is when I have more than one level of inheritance... for example:&lt;br&gt; &lt;br&gt;C extends B that extends A&lt;br&gt;&lt;br&gt;B and A are abstract&lt;br&gt;&lt;br&gt;in A I'm injecting D&lt;br&gt;&lt;br&gt;when getting an instance of C from the container, D is null.&lt;br&gt; &lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Nov 26, 2008 at 1:24 PM, Jonathan Ariel &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20764507&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ionathan@...&lt;/a&gt;&gt;&lt;/span&gt; wrote:&lt;br&gt; &lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt; I agree. I'll change my code. Thanks! Good reasons :)&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt; On Wed, Nov 26, 2008 at 11:46 AM, Daniel Wellman &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20764507&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;etldan@...&lt;/a&gt;&gt;&lt;/span&gt; wrote:&lt;br&gt; &lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt; &lt;div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Nov 26, 2008 at 2:50 AM, Paul Hammant &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20764507&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;paul@...&lt;/a&gt;&gt;&lt;/span&gt; wrote:&lt;br&gt; &lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt; Well five is a bit borderline, yes. &amp;nbsp;Firstly, if you're using IDEA for looking after your component set, then using the refactoring &quot;introduce parameter&quot; can help lots - it you do that in the super class, all subclasses will get it too. &amp;nbsp;Then there's &quot;Change method signature&quot; which IDEA and Eclipse have.&lt;br&gt; &lt;br&gt; Alternatively, the purists may study the five components that are dependencies and wonder if there is some separation of concerts. &amp;nbsp;They would try to look to see if there is some intermediate dependency that could encompass the capabilities of, say, three of the components. &amp;nbsp;With the introduction of the intermediate component, you would see a reduce number of deps going into the final one. &amp;nbsp;Of course, that's easy for me to say not having seen your set of components.&lt;br&gt; &lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;I agree; I like Constructor Injection for a few reasons:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;You know you always have all your dependencies when you get an instance of your component from &amp;nbsp;the container. &amp;nbsp;You don't have to write any &quot;afterInitialized&quot; method where you check that you really have all your dependencies set -- Spring does this, I don't know about Guice. &amp;nbsp;For testing it's particularly nice because you know all your required dependencies by looking at the constructor. &amp;nbsp;With setter injection, it's up to the programmer to look at all the bean properties and make sure they're all set in the test. &amp;nbsp;&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Constructor injection is even more compelling when you are adding new dependencies to existing classes -- the IDE will remind you that your test objects are missing dependencies (because they are missing a constructor parameter) whereas setter injection will probably cause the test to fail at runtime with a NullPointerException.&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Re: Too many dependencies&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;As Paul said, if you have too many dependencies, there's probably some other abstraction which is trying to come out. &amp;nbsp;Just like testing with mock objects can tell you if your interfaces need rethinking (&quot;Why do I have to mock all these calls to get my code to work?&quot;), long constructor lists can tell if you if you have too many or unusual dependencies.&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;And yes, a good IDE will help you deal with the mechanics of introducing new parameters, moving them, etc.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Dan&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt; &lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt; &lt;/div&gt; &lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/body&gt;&lt;/html&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Problem-with-annotation-injection-in-abstract-classes-tp20688511p20764507.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20755313</id>
	<title>Re: Problem with annotation injection in abstract classes</title>
	<published>2008-11-29T23:48:32Z</published>
	<updated>2008-11-29T23:48:32Z</updated>
	<author>
		<name>Paul Hammant-3</name>
	</author>
	<content type="html">&lt;html&gt;&lt;body style=&quot;word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; &quot;&gt;Should do. &amp;nbsp;I'll look into it.&lt;div&gt;&lt;br&gt;&lt;div&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; &quot;&gt;&lt;div style=&quot;word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; &quot;&gt;&lt;div&gt;Regards,&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;- Paul&lt;/div&gt;&lt;/div&gt;&lt;/span&gt; &lt;/div&gt;&lt;br&gt;&lt;div&gt;&lt;div&gt;On Nov 30, 2008, at 4:43 AM, Jonathan Ariel wrote:&lt;/div&gt;&lt;br class=&quot;Apple-interchange-newline&quot;&gt;&lt;blockquote type=&quot;cite&quot;&gt;You are right... it is working, the problem appears when you use withAutomatic() instead of withAnnotatedFieldInjection().&lt;br&gt;In my case I need both annotation and constructor injection. Do you think that it should work when using withAutomatic?&lt;br&gt; &lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Sat, Nov 29, 2008 at 12:01 PM, Paul Hammant &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20755313&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;paul@...&lt;/a&gt;&gt;&lt;/span&gt; wrote:&lt;br&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt; &lt;div style=&quot;&quot;&gt;Jonathan.&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;I can't reproduce :-(&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Is the following representative ...............&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static abstract class A2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Inject&lt;/div&gt; &lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;protected D2 d2;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static abstract class B2 extends A2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static class C2 extends B2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static class D2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;@Test&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public void testThatEvenMoreSuperClassCanHaveAnnotatedFields() {&lt;/div&gt;&lt;div class=&quot;Ih2E3d&quot;&gt;&lt;div&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MutablePicoContainer container = new PicoBuilder().withAnnotatedFieldInjection().build();&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;container.addComponent(D2.class);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;container.addComponent(C2.class);&lt;/div&gt;&lt;div&gt;&lt;br&gt; &lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C2 c2 = container.getComponent(C2.class);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertNotNull(c2);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertNotNull(c2.d2);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;div&gt; &lt;span style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;&quot;&gt;&lt;div style=&quot;&quot;&gt; &lt;div&gt;Regards,&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;- Paul&lt;/div&gt;&lt;/div&gt;&lt;/span&gt; &lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class=&quot;Wj3C7c&quot;&gt;&lt;br&gt;&lt;div&gt;&lt;div&gt;On Nov 27, 2008, at 3:06 PM, Jonathan Ariel wrote:&lt;/div&gt;&lt;br&gt;&lt;blockquote type=&quot;cite&quot;&gt;I seems to still have problems with this... and it is when I have more than one level of inheritance... for example:&lt;br&gt; &lt;br&gt;C extends B that extends A&lt;br&gt;&lt;br&gt;B and A are abstract&lt;br&gt;&lt;br&gt;in A I'm injecting D&lt;br&gt;&lt;br&gt;when getting an instance of C from the container, D is null.&lt;br&gt; &lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Nov 26, 2008 at 1:24 PM, Jonathan Ariel &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20755313&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ionathan@...&lt;/a&gt;&gt;&lt;/span&gt; wrote:&lt;br&gt; &lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt; I agree. I'll change my code. Thanks! Good reasons :)&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt; On Wed, Nov 26, 2008 at 11:46 AM, Daniel Wellman &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20755313&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;etldan@...&lt;/a&gt;&gt;&lt;/span&gt; wrote:&lt;br&gt; &lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt; &lt;div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Nov 26, 2008 at 2:50 AM, Paul Hammant &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20755313&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;paul@...&lt;/a&gt;&gt;&lt;/span&gt; wrote:&lt;br&gt; &lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt; Well five is a bit borderline, yes. &amp;nbsp;Firstly, if you're using IDEA for looking after your component set, then using the refactoring &quot;introduce parameter&quot; can help lots - it you do that in the super class, all subclasses will get it too. &amp;nbsp;Then there's &quot;Change method signature&quot; which IDEA and Eclipse have.&lt;br&gt; &lt;br&gt; Alternatively, the purists may study the five components that are dependencies and wonder if there is some separation of concerts. &amp;nbsp;They would try to look to see if there is some intermediate dependency that could encompass the capabilities of, say, three of the components. &amp;nbsp;With the introduction of the intermediate component, you would see a reduce number of deps going into the final one. &amp;nbsp;Of course, that's easy for me to say not having seen your set of components.&lt;br&gt; &lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;I agree; I like Constructor Injection for a few reasons:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;You know you always have all your dependencies when you get an instance of your component from &amp;nbsp;the container. &amp;nbsp;You don't have to write any &quot;afterInitialized&quot; method where you check that you really have all your dependencies set -- Spring does this, I don't know about Guice. &amp;nbsp;For testing it's particularly nice because you know all your required dependencies by looking at the constructor. &amp;nbsp;With setter injection, it's up to the programmer to look at all the bean properties and make sure they're all set in the test. &amp;nbsp;&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Constructor injection is even more compelling when you are adding new dependencies to existing classes -- the IDE will remind you that your test objects are missing dependencies (because they are missing a constructor parameter) whereas setter injection will probably cause the test to fail at runtime with a NullPointerException.&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Re: Too many dependencies&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;As Paul said, if you have too many dependencies, there's probably some other abstraction which is trying to come out. &amp;nbsp;Just like testing with mock objects can tell you if your interfaces need rethinking (&quot;Why do I have to mock all these calls to get my code to work?&quot;), long constructor lists can tell if you if you have too many or unusual dependencies.&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;And yes, a good IDE will help you deal with the mechanics of introducing new parameters, moving them, etc.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Dan&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt; &lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt; &lt;/div&gt; &lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Problem-with-annotation-injection-in-abstract-classes-tp20688511p20755313.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20754562</id>
	<title>Re: Problem with annotation injection in abstract classes</title>
	<published>2008-11-29T20:43:45Z</published>
	<updated>2008-11-29T20:43:45Z</updated>
	<author>
		<name>Jonathan Ariel</name>
	</author>
	<content type="html">You are right... it is working, the problem appears when you use withAutomatic() instead of withAnnotatedFieldInjection().&lt;br&gt;In my case I need both annotation and constructor injection. Do you think that it should work when using withAutomatic?&lt;br&gt;
&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Sat, Nov 29, 2008 at 12:01 PM, Paul Hammant &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20754562&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;paul@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
&lt;div style=&quot;&quot;&gt;Jonathan.&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;I can&amp;#39;t reproduce :-(&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Is the following representative ...............&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static abstract class A2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Inject&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;protected D2 d2;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static abstract class B2 extends A2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static class C2 extends B2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static class D2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;@Test&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public void testThatEvenMoreSuperClassCanHaveAnnotatedFields() {&lt;/div&gt;&lt;div class=&quot;Ih2E3d&quot;&gt;&lt;div&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MutablePicoContainer container = new PicoBuilder().withAnnotatedFieldInjection().build();&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;container.addComponent(D2.class);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;container.addComponent(C2.class);&lt;/div&gt;&lt;div&gt;&lt;br&gt;
&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C2 c2 = container.getComponent(C2.class);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertNotNull(c2);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertNotNull(c2.d2);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;div&gt; &lt;span style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;&quot;&gt;&lt;div style=&quot;&quot;&gt;
&lt;div&gt;Regards,&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;- Paul&lt;/div&gt;&lt;/div&gt;&lt;/span&gt; &lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class=&quot;Wj3C7c&quot;&gt;&lt;br&gt;&lt;div&gt;&lt;div&gt;On Nov 27, 2008, at 3:06 PM, Jonathan Ariel wrote:&lt;/div&gt;&lt;br&gt;&lt;blockquote type=&quot;cite&quot;&gt;I seems to still have problems with this... and it is when I have more than one level of inheritance... for example:&lt;br&gt;
&lt;br&gt;C extends B that extends A&lt;br&gt;&lt;br&gt;B and A are abstract&lt;br&gt;&lt;br&gt;in A I&amp;#39;m injecting D&lt;br&gt;&lt;br&gt;when getting an instance of C from the container, D is null.&lt;br&gt; &lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Nov 26, 2008 at 1:24 PM, Jonathan Ariel &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20754562&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ionathan@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt; I agree. I&amp;#39;ll change my code. Thanks! Good reasons :)&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;
On Wed, Nov 26, 2008 at 11:46 AM, Daniel Wellman &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20754562&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;etldan@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt; &lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
&lt;div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Nov 26, 2008 at 2:50 AM, Paul Hammant &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20754562&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;paul@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt; &lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
 Well five is a bit borderline, yes. &amp;nbsp;Firstly, if you&amp;#39;re using IDEA for looking after your component set, then using the refactoring &amp;quot;introduce parameter&amp;quot; can help lots - it you do that in the super class, all subclasses will get it too. &amp;nbsp;Then there&amp;#39;s &amp;quot;Change method signature&amp;quot; which IDEA and Eclipse have.&lt;br&gt;
 &lt;br&gt; Alternatively, the purists may study the five components that are dependencies and wonder if there is some separation of concerts. &amp;nbsp;They would try to look to see if there is some intermediate dependency that could encompass the capabilities of, say, three of the components. &amp;nbsp;With the introduction of the intermediate component, you would see a reduce number of deps going into the final one. &amp;nbsp;Of course, that&amp;#39;s easy for me to say not having seen your set of components.&lt;br&gt;
 &lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;I agree; I like Constructor Injection for a few reasons:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;You know you always have all your dependencies when you get an instance of your component from &amp;nbsp;the container. &amp;nbsp;You don&amp;#39;t have to write any &amp;quot;afterInitialized&amp;quot; method where you check that you really have all your dependencies set -- Spring does this, I don&amp;#39;t know about Guice. &amp;nbsp;For testing it&amp;#39;s particularly nice because you know all your required dependencies by looking at the constructor. &amp;nbsp;With setter injection, it&amp;#39;s up to the programmer to look at all the bean properties and make sure they&amp;#39;re all set in the test. &amp;nbsp;&lt;/div&gt;
 &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Constructor injection is even more compelling when you are adding new dependencies to existing classes -- the IDE will remind you that your test objects are missing dependencies (because they are missing a constructor parameter) whereas setter injection will probably cause the test to fail at runtime with a NullPointerException.&lt;/div&gt;
 &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Re: Too many dependencies&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;As Paul said, if you have too many dependencies, there&amp;#39;s probably some other abstraction which is trying to come out. &amp;nbsp;Just like testing with mock objects can tell you if your interfaces need rethinking (&amp;quot;Why do I have to mock all these calls to get my code to work?&amp;quot;), long constructor lists can tell if you if you have too many or unusual dependencies.&lt;/div&gt;
 &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;And yes, a good IDE will help you deal with the mechanics of introducing new parameters, moving them, etc.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Dan&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt; &lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt; &lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;
</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Problem-with-annotation-injection-in-abstract-classes-tp20688511p20754562.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20747300</id>
	<title>Re: CollectionComponentParameter works differently with generic Collection types?</title>
	<published>2008-11-29T06:01:45Z</published>
	<updated>2008-11-29T06:01:45Z</updated>
	<author>
		<name>Paul Hammant-3</name>
	</author>
	<content type="html">&lt;html&gt;&lt;body style=&quot;word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; &quot;&gt;Fixed I think. &amp;nbsp;Jar by separate email.&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;div&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; &quot;&gt;&lt;div style=&quot;word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; &quot;&gt;&lt;div&gt;Regards,&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;- Paul&lt;/div&gt;&lt;/div&gt;&lt;/span&gt; &lt;/div&gt;&lt;br&gt;&lt;div&gt;&lt;div&gt;On Nov 27, 2008, at 2:29 PM, Daniel Wellman wrote:&lt;/div&gt;&lt;br class=&quot;Apple-interchange-newline&quot;&gt;&lt;blockquote type=&quot;cite&quot;&gt;Paul,&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Thanks for taking a look at this!&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Cheers,&lt;/div&gt;&lt;div&gt;Dan&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Thu, Nov 27, 2008 at 7:00 AM, Paul Hammant &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20747300&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;paul@...&lt;/a&gt;&gt;&lt;/span&gt; wrote:&lt;br&gt; &lt;blockquote class=&quot;gmail_quote&quot; style=&quot;margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;&quot;&gt;Well I can reproduce this easily enough. &amp;nbsp;I'm playing with alternatives for fixing it Daniel...&lt;div class=&quot;Ih2E3d&quot;&gt; &lt;br&gt; &lt;br&gt; Regards,&lt;br&gt; &lt;br&gt; - Paul&lt;br&gt; &lt;br&gt; On Nov 25, 2008, at 1:05 AM, Daniel Wellman wrote:&lt;br&gt; &lt;br&gt; &lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class=&quot;Wj3C7c&quot;&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex&quot;&gt; &lt;br&gt; Has the behavior of CollectionComponentParameter changed now that Pico 2&lt;br&gt; recognizes generic collection parameter types?&lt;br&gt; &lt;br&gt; In the example below, I expected that adding a CollectionComponentParameter&lt;br&gt; with a componentValueType of Cod.class would only have Cod fish in the bowl,&lt;br&gt; but I observe that it gets both Cod and Shark.&lt;br&gt; &lt;br&gt; If I repeat the experiment by making the Bowl have a type-erased List, the&lt;br&gt; test works as I expect -- I only get a Cod.&lt;br&gt; &lt;br&gt; Is this the expected behavior for typed collections?&lt;br&gt; &lt;br&gt; Test below:&lt;br&gt; &lt;br&gt; &lt;br&gt; &amp;nbsp;public void testRegisteringSubsetOfGenericCollectionParameters() {&lt;br&gt; &amp;nbsp; &amp;nbsp; DefaultPicoContainer pico = new DefaultPicoContainer();&lt;br&gt; &amp;nbsp; &amp;nbsp; pico.addComponent(Cod.class);&lt;br&gt; &amp;nbsp; &amp;nbsp; pico.addComponent(Shark.class);&lt;br&gt; &amp;nbsp; &amp;nbsp; pico.addComponent(GenericBowl.class, GenericBowl.class,&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new CollectionComponentParameter(Cod.class, false));&lt;br&gt; &lt;br&gt; &lt;br&gt; &amp;nbsp; &amp;nbsp; GenericBowl bowl = pico.getComponent(GenericBowl.class);&lt;br&gt; &amp;nbsp; &amp;nbsp; // FAILS with PicoContainer 2.7-SNAPSHOT, returns 2&lt;br&gt; &amp;nbsp; &amp;nbsp; assertEquals(1, bowl.fishes.size());&lt;br&gt; &amp;nbsp;}&lt;br&gt; &lt;br&gt; &amp;nbsp;// Types&lt;br&gt; &lt;br&gt; &amp;nbsp;public static interface Fish {&lt;br&gt; &amp;nbsp;}&lt;br&gt; &lt;br&gt; &amp;nbsp;public static class Cod implements Fish {&lt;br&gt; &amp;nbsp;}&lt;br&gt; &lt;br&gt; &amp;nbsp;public static class Shark implements Fish {&lt;br&gt; &amp;nbsp;}&lt;br&gt; &lt;br&gt; &amp;nbsp;public static class GenericBowl {&lt;br&gt; &amp;nbsp; &amp;nbsp; List&amp;lt;Fish&gt; fishes;&lt;br&gt; &lt;br&gt; &amp;nbsp; &amp;nbsp; public GenericBowl(List&amp;lt;Fish&gt; fishes) {&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.fishes = fishes;&lt;br&gt; &amp;nbsp; &amp;nbsp; }&lt;br&gt; &amp;nbsp;}&lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; ... but this one passes:&lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &amp;nbsp;public void testRegisteringSubsetOfTypeErasedCollectionParameters() {&lt;br&gt; &amp;nbsp; &amp;nbsp; DefaultPicoContainer pico = new DefaultPicoContainer();&lt;br&gt; &amp;nbsp; &amp;nbsp; pico.addComponent(Cod.class);&lt;br&gt; &amp;nbsp; &amp;nbsp; pico.addComponent(Shark.class);&lt;br&gt; &amp;nbsp; &amp;nbsp; pico.addComponent(GenericBowl.class, GenericBowl.class,&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new CollectionComponentParameter(Fish.class, false));&lt;br&gt; &lt;br&gt; &lt;br&gt; &amp;nbsp; &amp;nbsp; GenericBowl bowl = pico.getComponent(GenericBowl.class);&lt;br&gt; &amp;nbsp; &amp;nbsp; assertEquals(2, bowl.fishes.size());&lt;br&gt; &amp;nbsp; &amp;nbsp; assertTrue(CollectionUtilities.contains(bowl.fishes, new&lt;br&gt; ContainsInstanceOfTypePredicate(Cod.class)));&lt;br&gt; &amp;nbsp; &amp;nbsp; assertTrue(CollectionUtilities.contains(bowl.fishes, new&lt;br&gt; ContainsInstanceOfTypePredicate(Shark.class)));&lt;br&gt; &amp;nbsp;}&lt;br&gt; &lt;br&gt; &lt;br&gt; &amp;nbsp;public static class TypeErasedListBowl {&lt;br&gt; &amp;nbsp; &amp;nbsp; List fishes;&lt;br&gt; &lt;br&gt; &amp;nbsp; &amp;nbsp; public TypeErasedListBowl(List fishes) {&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.fishes = fishes;&lt;br&gt; &amp;nbsp; &amp;nbsp; }&lt;br&gt; &amp;nbsp;}&lt;br&gt; &lt;br&gt; &lt;br&gt; -- &lt;br&gt; View this message in context: &lt;a href=&quot;http://www.nabble.com/CollectionComponentParameter-works-differently-with-generic-Collection-types--tp20673363p20673363.html&quot; target=&quot;_blank&quot;&gt;http://www.nabble.com/CollectionComponentParameter-works-differently-with-generic-Collection-types--tp20673363p20673363.html&lt;/a&gt;&lt;br&gt; Sent from the NanoContainer - PicoContainer - Users mailing list archive at Nabble.com.&lt;br&gt; &lt;br&gt; &lt;br&gt; ---------------------------------------------------------------------&lt;br&gt; To unsubscribe from this list, please visit:&lt;br&gt; &lt;br&gt; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;/blockquote&gt; &lt;br&gt; &lt;br&gt; ---------------------------------------------------------------------&lt;br&gt; To unsubscribe from this list, please visit:&lt;br&gt; &lt;br&gt; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/CollectionComponentParameter-works-differently-with-generic-Collection-types--tp20673363p20747300.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20747293</id>
	<title>Re: Problem with annotation injection in abstract classes</title>
	<published>2008-11-29T06:01:42Z</published>
	<updated>2008-11-29T06:01:42Z</updated>
	<author>
		<name>Paul Hammant-3</name>
	</author>
	<content type="html">&lt;html&gt;&lt;body style=&quot;word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; &quot;&gt;Jonathan.&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;I can't reproduce :-(&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Is the following representative ...............&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static abstract class A2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Inject&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;protected D2 d2;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static abstract class B2 extends A2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static class C2 extends B2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static class D2 {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;@Test&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public void testThatEvenMoreSuperClassCanHaveAnnotatedFields() {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MutablePicoContainer container = new PicoBuilder().withAnnotatedFieldInjection().build();&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;container.addComponent(D2.class);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;container.addComponent(C2.class);&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C2 c2 = container.getComponent(C2.class);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertNotNull(c2);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertNotNull(c2.d2);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;div&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; &quot;&gt;&lt;div style=&quot;word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; &quot;&gt;&lt;div&gt;Regards,&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;- Paul&lt;/div&gt;&lt;/div&gt;&lt;/span&gt; &lt;/div&gt;&lt;br&gt;&lt;div&gt;&lt;div&gt;On Nov 27, 2008, at 3:06 PM, Jonathan Ariel wrote:&lt;/div&gt;&lt;br class=&quot;Apple-interchange-newline&quot;&gt;&lt;blockquote type=&quot;cite&quot;&gt;I seems to still have problems with this... and it is when I have more than one level of inheritance... for example:&lt;br&gt;&lt;br&gt;C extends B that extends A&lt;br&gt;&lt;br&gt;B and A are abstract&lt;br&gt;&lt;br&gt;in A I'm injecting D&lt;br&gt;&lt;br&gt;when getting an instance of C from the container, D is null.&lt;br&gt; &lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Nov 26, 2008 at 1:24 PM, Jonathan Ariel &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20747293&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ionathan@...&lt;/a&gt;&gt;&lt;/span&gt; wrote:&lt;br&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt; I agree. I'll change my code. Thanks! Good reasons :)&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class=&quot;Wj3C7c&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Nov 26, 2008 at 11:46 AM, Daniel Wellman &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20747293&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;etldan@...&lt;/a&gt;&gt;&lt;/span&gt; wrote:&lt;br&gt; &lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;&lt;div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Nov 26, 2008 at 2:50 AM, Paul Hammant &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20747293&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;paul@...&lt;/a&gt;&gt;&lt;/span&gt; wrote:&lt;br&gt; &lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt; Well five is a bit borderline, yes. &amp;nbsp;Firstly, if you're using IDEA for looking after your component set, then using the refactoring &quot;introduce parameter&quot; can help lots - it you do that in the super class, all subclasses will get it too. &amp;nbsp;Then there's &quot;Change method signature&quot; which IDEA and Eclipse have.&lt;br&gt; &lt;br&gt; Alternatively, the purists may study the five components that are dependencies and wonder if there is some separation of concerts. &amp;nbsp;They would try to look to see if there is some intermediate dependency that could encompass the capabilities of, say, three of the components. &amp;nbsp;With the introduction of the intermediate component, you would see a reduce number of deps going into the final one. &amp;nbsp;Of course, that's easy for me to say not having seen your set of components.&lt;br&gt; &lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;I agree; I like Constructor Injection for a few reasons:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;You know you always have all your dependencies when you get an instance of your component from &amp;nbsp;the container. &amp;nbsp;You don't have to write any &quot;afterInitialized&quot; method where you check that you really have all your dependencies set -- Spring does this, I don't know about Guice. &amp;nbsp;For testing it's particularly nice because you know all your required dependencies by looking at the constructor. &amp;nbsp;With setter injection, it's up to the programmer to look at all the bean properties and make sure they're all set in the test. &amp;nbsp;&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Constructor injection is even more compelling when you are adding new dependencies to existing classes -- the IDE will remind you that your test objects are missing dependencies (because they are missing a constructor parameter) whereas setter injection will probably cause the test to fail at runtime with a NullPointerException.&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Re: Too many dependencies&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;As Paul said, if you have too many dependencies, there's probably some other abstraction which is trying to come out. &amp;nbsp;Just like testing with mock objects can tell you if your interfaces need rethinking (&quot;Why do I have to mock all these calls to get my code to work?&quot;), long constructor lists can tell if you if you have too many or unusual dependencies.&lt;/div&gt; &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;And yes, a good IDE will help you deal with the mechanics of introducing new parameters, moving them, etc.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Dan&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt; &lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt; &lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Problem-with-annotation-injection-in-abstract-classes-tp20688511p20747293.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20721129</id>
	<title>Re: Problem with annotation injection in abstract classes</title>
	<published>2008-11-27T07:06:42Z</published>
	<updated>2008-11-27T07:06:42Z</updated>
	<author>
		<name>Jonathan Ariel</name>
	</author>
	<content type="html">I seems to still have problems with this... and it is when I have more than one level of inheritance... for example:&lt;br&gt;&lt;br&gt;C extends B that extends A&lt;br&gt;&lt;br&gt;B and A are abstract&lt;br&gt;&lt;br&gt;in A I&amp;#39;m injecting D&lt;br&gt;&lt;br&gt;when getting an instance of C from the container, D is null.&lt;br&gt;
&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Nov 26, 2008 at 1:24 PM, Jonathan Ariel &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20721129&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ionathan@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
I agree. I&amp;#39;ll change my code. Thanks! Good reasons :)&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class=&quot;Wj3C7c&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Nov 26, 2008 at 11:46 AM, Daniel Wellman &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20721129&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;etldan@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;

&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;&lt;div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Nov 26, 2008 at 2:50 AM, Paul Hammant &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20721129&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;paul@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;

&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
Well five is a bit borderline, yes. &amp;nbsp;Firstly, if you&amp;#39;re using IDEA for looking after your component set, then using the refactoring &amp;quot;introduce parameter&amp;quot; can help lots - it you do that in the super class, all subclasses will get it too. &amp;nbsp;Then there&amp;#39;s &amp;quot;Change method signature&amp;quot; which IDEA and Eclipse have.&lt;br&gt;



&lt;br&gt;
Alternatively, the purists may study the five components that are dependencies and wonder if there is some separation of concerts. &amp;nbsp;They would try to look to see if there is some intermediate dependency that could encompass the capabilities of, say, three of the components. &amp;nbsp;With the introduction of the intermediate component, you would see a reduce number of deps going into the final one. &amp;nbsp;Of course, that&amp;#39;s easy for me to say not having seen your set of components.&lt;br&gt;


&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;I agree; I like Constructor Injection for a few reasons:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;You know you always have all your dependencies when you get an instance of your component from &amp;nbsp;the container. &amp;nbsp;You don&amp;#39;t have to write any &amp;quot;afterInitialized&amp;quot; method where you check that you really have all your dependencies set -- Spring does this, I don&amp;#39;t know about Guice. &amp;nbsp;For testing it&amp;#39;s particularly nice because you know all your required dependencies by looking at the constructor. &amp;nbsp;With setter injection, it&amp;#39;s up to the programmer to look at all the bean properties and make sure they&amp;#39;re all set in the test. &amp;nbsp;&lt;/div&gt;


&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Constructor injection is even more compelling when you are adding new dependencies to existing classes -- the IDE will remind you that your test objects are missing dependencies (because they are missing a constructor parameter) whereas setter injection will probably cause the test to fail at runtime with a NullPointerException.&lt;/div&gt;


&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Re: Too many dependencies&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;As Paul said, if you have too many dependencies, there&amp;#39;s probably some other abstraction which is trying to come out. &amp;nbsp;Just like testing with mock objects can tell you if your interfaces need rethinking (&amp;quot;Why do I have to mock all these calls to get my code to work?&amp;quot;), long constructor lists can tell if you if you have too many or unusual dependencies.&lt;/div&gt;


&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;And yes, a good IDE will help you deal with the mechanics of introducing new parameters, moving them, etc.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Dan&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;
&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;
</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Problem-with-annotation-injection-in-abstract-classes-tp20688511p20721129.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20720313</id>
	<title>Re: CollectionComponentParameter works differently with generic Collection types?</title>
	<published>2008-11-27T06:29:18Z</published>
	<updated>2008-11-27T06:29:18Z</updated>
	<author>
		<name>Daniel Wellman</name>
	</author>
	<content type="html">Paul,&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Thanks for taking a look at this!&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Cheers,&lt;/div&gt;&lt;div&gt;Dan&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Thu, Nov 27, 2008 at 7:00 AM, Paul Hammant &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20720313&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;paul@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;&quot;&gt;Well I can reproduce this easily enough. &amp;nbsp;I&amp;#39;m playing with alternatives for fixing it Daniel...&lt;div class=&quot;Ih2E3d&quot;&gt;
&lt;br&gt;
&lt;br&gt;
Regards,&lt;br&gt;
&lt;br&gt;
- Paul&lt;br&gt;
&lt;br&gt;
On Nov 25, 2008, at 1:05 AM, Daniel Wellman wrote:&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class=&quot;Wj3C7c&quot;&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex&quot;&gt;
&lt;br&gt;
Has the behavior of CollectionComponentParameter changed now that Pico 2&lt;br&gt;
recognizes generic collection parameter types?&lt;br&gt;
&lt;br&gt;
In the example below, I expected that adding a CollectionComponentParameter&lt;br&gt;
with a componentValueType of Cod.class would only have Cod fish in the bowl,&lt;br&gt;
but I observe that it gets both Cod and Shark.&lt;br&gt;
&lt;br&gt;
If I repeat the experiment by making the Bowl have a type-erased List, the&lt;br&gt;
test works as I expect -- I only get a Cod.&lt;br&gt;
&lt;br&gt;
Is this the expected behavior for typed collections?&lt;br&gt;
&lt;br&gt;
Test below:&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
 &amp;nbsp;public void testRegisteringSubsetOfGenericCollectionParameters() {&lt;br&gt;
 &amp;nbsp; &amp;nbsp; DefaultPicoContainer pico = new DefaultPicoContainer();&lt;br&gt;
 &amp;nbsp; &amp;nbsp; pico.addComponent(Cod.class);&lt;br&gt;
 &amp;nbsp; &amp;nbsp; pico.addComponent(Shark.class);&lt;br&gt;
 &amp;nbsp; &amp;nbsp; pico.addComponent(GenericBowl.class, GenericBowl.class,&lt;br&gt;
 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new CollectionComponentParameter(Cod.class, false));&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
 &amp;nbsp; &amp;nbsp; GenericBowl bowl = pico.getComponent(GenericBowl.class);&lt;br&gt;
 &amp;nbsp; &amp;nbsp; // FAILS with PicoContainer 2.7-SNAPSHOT, returns 2&lt;br&gt;
 &amp;nbsp; &amp;nbsp; assertEquals(1, bowl.fishes.size());&lt;br&gt;
 &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
 &amp;nbsp;// Types&lt;br&gt;
&lt;br&gt;
 &amp;nbsp;public static interface Fish {&lt;br&gt;
 &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
 &amp;nbsp;public static class Cod implements Fish {&lt;br&gt;
 &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
 &amp;nbsp;public static class Shark implements Fish {&lt;br&gt;
 &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
 &amp;nbsp;public static class GenericBowl {&lt;br&gt;
 &amp;nbsp; &amp;nbsp; List&amp;lt;Fish&amp;gt; fishes;&lt;br&gt;
&lt;br&gt;
 &amp;nbsp; &amp;nbsp; public GenericBowl(List&amp;lt;Fish&amp;gt; fishes) {&lt;br&gt;
 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.fishes = fishes;&lt;br&gt;
 &amp;nbsp; &amp;nbsp; }&lt;br&gt;
 &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
... but this one passes:&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
 &amp;nbsp;public void testRegisteringSubsetOfTypeErasedCollectionParameters() {&lt;br&gt;
 &amp;nbsp; &amp;nbsp; DefaultPicoContainer pico = new DefaultPicoContainer();&lt;br&gt;
 &amp;nbsp; &amp;nbsp; pico.addComponent(Cod.class);&lt;br&gt;
 &amp;nbsp; &amp;nbsp; pico.addComponent(Shark.class);&lt;br&gt;
 &amp;nbsp; &amp;nbsp; pico.addComponent(GenericBowl.class, GenericBowl.class,&lt;br&gt;
 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new CollectionComponentParameter(Fish.class, false));&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
 &amp;nbsp; &amp;nbsp; GenericBowl bowl = pico.getComponent(GenericBowl.class);&lt;br&gt;
 &amp;nbsp; &amp;nbsp; assertEquals(2, bowl.fishes.size());&lt;br&gt;
 &amp;nbsp; &amp;nbsp; assertTrue(CollectionUtilities.contains(bowl.fishes, new&lt;br&gt;
ContainsInstanceOfTypePredicate(Cod.class)));&lt;br&gt;
 &amp;nbsp; &amp;nbsp; assertTrue(CollectionUtilities.contains(bowl.fishes, new&lt;br&gt;
ContainsInstanceOfTypePredicate(Shark.class)));&lt;br&gt;
 &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
 &amp;nbsp;public static class TypeErasedListBowl {&lt;br&gt;
 &amp;nbsp; &amp;nbsp; List fishes;&lt;br&gt;
&lt;br&gt;
 &amp;nbsp; &amp;nbsp; public TypeErasedListBowl(List fishes) {&lt;br&gt;
 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.fishes = fishes;&lt;br&gt;
 &amp;nbsp; &amp;nbsp; }&lt;br&gt;
 &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
View this message in context: &lt;a href=&quot;http://www.nabble.com/CollectionComponentParameter-works-differently-with-generic-Collection-types--tp20673363p20673363.html&quot; target=&quot;_blank&quot;&gt;http://www.nabble.com/CollectionComponentParameter-works-differently-with-generic-Collection-types--tp20673363p20673363.html&lt;/a&gt;&lt;br&gt;

Sent from the NanoContainer - PicoContainer - Users mailing list archive at Nabble.com.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
---------------------------------------------------------------------&lt;br&gt;
To unsubscribe from this list, please visit:&lt;br&gt;
&lt;br&gt;
 &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;br&gt;
---------------------------------------------------------------------&lt;br&gt;
To unsubscribe from this list, please visit:&lt;br&gt;
&lt;br&gt;
 &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;
</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/CollectionComponentParameter-works-differently-with-generic-Collection-types--tp20673363p20720313.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20718111</id>
	<title>Re: CollectionComponentParameter works differently with generic Collection types?</title>
	<published>2008-11-27T04:00:55Z</published>
	<updated>2008-11-27T04:00:55Z</updated>
	<author>
		<name>Paul Hammant-3</name>
	</author>
	<content type="html">Well I can reproduce this easily enough. &amp;nbsp;I'm playing with &amp;nbsp;
&lt;br&gt;alternatives for fixing it Daniel...
&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&lt;br&gt;- Paul
&lt;br&gt;&lt;br&gt;On Nov 25, 2008, at 1:05 AM, Daniel Wellman wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Has the behavior of CollectionComponentParameter changed now that &amp;nbsp;
&lt;br&gt;&amp;gt; Pico 2
&lt;br&gt;&amp;gt; recognizes generic collection parameter types?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; In the example below, I expected that adding a &amp;nbsp;
&lt;br&gt;&amp;gt; CollectionComponentParameter
&lt;br&gt;&amp;gt; with a componentValueType of Cod.class would only have Cod fish in &amp;nbsp;
&lt;br&gt;&amp;gt; the bowl,
&lt;br&gt;&amp;gt; but I observe that it gets both Cod and Shark.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; If I repeat the experiment by making the Bowl have a type-erased &amp;nbsp;
&lt;br&gt;&amp;gt; List, the
&lt;br&gt;&amp;gt; test works as I expect -- I only get a Cod.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Is this the expected behavior for typed collections?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Test below:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public void testRegisteringSubsetOfGenericCollectionParameters() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;DefaultPicoContainer pico = new DefaultPicoContainer();
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(Cod.class);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(Shark.class);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(GenericBowl.class, GenericBowl.class,
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;new CollectionComponentParameter(Cod.class, false));
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;GenericBowl bowl = pico.getComponent(GenericBowl.class);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;// FAILS with PicoContainer 2.7-SNAPSHOT, returns 2
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertEquals(1, bowl.fishes.size());
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; // Types
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public static interface Fish {
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public static class Cod implements Fish {
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public static class Shark implements Fish {
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public static class GenericBowl {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;List&amp;lt;Fish&amp;gt; fishes;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;public GenericBowl(List&amp;lt;Fish&amp;gt; fishes) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.fishes = fishes;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ... but this one passes:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public void &amp;nbsp;
&lt;br&gt;&amp;gt; testRegisteringSubsetOfTypeErasedCollectionParameters() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;DefaultPicoContainer pico = new DefaultPicoContainer();
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(Cod.class);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(Shark.class);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(GenericBowl.class, GenericBowl.class,
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;new CollectionComponentParameter(Fish.class, false));
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;GenericBowl bowl = pico.getComponent(GenericBowl.class);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertEquals(2, bowl.fishes.size());
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertTrue(CollectionUtilities.contains(bowl.fishes, new
&lt;br&gt;&amp;gt; ContainsInstanceOfTypePredicate(Cod.class)));
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertTrue(CollectionUtilities.contains(bowl.fishes, new
&lt;br&gt;&amp;gt; ContainsInstanceOfTypePredicate(Shark.class)));
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public static class TypeErasedListBowl {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;List fishes;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;public TypeErasedListBowl(List fishes) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.fishes = fishes;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://www.nabble.com/CollectionComponentParameter-works-differently-with-generic-Collection-types--tp20673363p20673363.html&quot; target=&quot;_top&quot;&gt;http://www.nabble.com/CollectionComponentParameter-works-differently-with-generic-Collection-types--tp20673363p20673363.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the NanoContainer - PicoContainer - Users mailing list &amp;nbsp;
&lt;br&gt;&amp;gt; archive at Nabble.com.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ---------------------------------------------------------------------
&lt;br&gt;&amp;gt; To unsubscribe from this list, please visit:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/CollectionComponentParameter-works-differently-with-generic-Collection-types--tp20673363p20718111.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20703081</id>
	<title>Re: Problem with annotation injection in abstract classes</title>
	<published>2008-11-26T07:24:11Z</published>
	<updated>2008-11-26T07:24:11Z</updated>
	<author>
		<name>Jonathan Ariel</name>
	</author>
	<content type="html">I agree. I&amp;#39;ll change my code. Thanks! Good reasons :)&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Nov 26, 2008 at 11:46 AM, Daniel Wellman &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20703081&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;etldan@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;&lt;div class=&quot;Ih2E3d&quot;&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Nov 26, 2008 at 2:50 AM, Paul Hammant &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20703081&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;paul@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
Well five is a bit borderline, yes. &amp;nbsp;Firstly, if you&amp;#39;re using IDEA for looking after your component set, then using the refactoring &amp;quot;introduce parameter&amp;quot; can help lots - it you do that in the super class, all subclasses will get it too. &amp;nbsp;Then there&amp;#39;s &amp;quot;Change method signature&amp;quot; which IDEA and Eclipse have.&lt;br&gt;


&lt;br&gt;
Alternatively, the purists may study the five components that are dependencies and wonder if there is some separation of concerts. &amp;nbsp;They would try to look to see if there is some intermediate dependency that could encompass the capabilities of, say, three of the components. &amp;nbsp;With the introduction of the intermediate component, you would see a reduce number of deps going into the final one. &amp;nbsp;Of course, that&amp;#39;s easy for me to say not having seen your set of components.&lt;br&gt;

&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;I agree; I like Constructor Injection for a few reasons:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;You know you always have all your dependencies when you get an instance of your component from &amp;nbsp;the container. &amp;nbsp;You don&amp;#39;t have to write any &amp;quot;afterInitialized&amp;quot; method where you check that you really have all your dependencies set -- Spring does this, I don&amp;#39;t know about Guice. &amp;nbsp;For testing it&amp;#39;s particularly nice because you know all your required dependencies by looking at the constructor. &amp;nbsp;With setter injection, it&amp;#39;s up to the programmer to look at all the bean properties and make sure they&amp;#39;re all set in the test. &amp;nbsp;&lt;/div&gt;

&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Constructor injection is even more compelling when you are adding new dependencies to existing classes -- the IDE will remind you that your test objects are missing dependencies (because they are missing a constructor parameter) whereas setter injection will probably cause the test to fail at runtime with a NullPointerException.&lt;/div&gt;

&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Re: Too many dependencies&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;As Paul said, if you have too many dependencies, there&amp;#39;s probably some other abstraction which is trying to come out. &amp;nbsp;Just like testing with mock objects can tell you if your interfaces need rethinking (&amp;quot;Why do I have to mock all these calls to get my code to work?&amp;quot;), long constructor lists can tell if you if you have too many or unusual dependencies.&lt;/div&gt;

&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;And yes, a good IDE will help you deal with the mechanics of introducing new parameters, moving them, etc.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Dan&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;
&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;
</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Problem-with-annotation-injection-in-abstract-classes-tp20688511p20703081.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20701299</id>
	<title>Re: Problem with annotation injection in abstract classes</title>
	<published>2008-11-26T05:46:36Z</published>
	<updated>2008-11-26T05:46:36Z</updated>
	<author>
		<name>Daniel Wellman</name>
	</author>
	<content type="html">&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Nov 26, 2008 at 2:50 AM, Paul Hammant &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20701299&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;paul@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;&quot;&gt;
Well five is a bit borderline, yes. &amp;nbsp;Firstly, if you&amp;#39;re using IDEA for looking after your component set, then using the refactoring &amp;quot;introduce parameter&amp;quot; can help lots - it you do that in the super class, all subclasses will get it too. &amp;nbsp;Then there&amp;#39;s &amp;quot;Change method signature&amp;quot; which IDEA and Eclipse have.&lt;br&gt;

&lt;br&gt;
Alternatively, the purists may study the five components that are dependencies and wonder if there is some separation of concerts. &amp;nbsp;They would try to look to see if there is some intermediate dependency that could encompass the capabilities of, say, three of the components. &amp;nbsp;With the introduction of the intermediate component, you would see a reduce number of deps going into the final one. &amp;nbsp;Of course, that&amp;#39;s easy for me to say not having seen your set of components.&lt;br&gt;
&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;div&gt;I agree; I like Constructor Injection for a few reasons:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;You know you always have all your dependencies when you get an instance of your component from &amp;nbsp;the container. &amp;nbsp;You don&amp;#39;t have to write any &amp;quot;afterInitialized&amp;quot; method where you check that you really have all your dependencies set -- Spring does this, I don&amp;#39;t know about Guice. &amp;nbsp;For testing it&amp;#39;s particularly nice because you know all your required dependencies by looking at the constructor. &amp;nbsp;With setter injection, it&amp;#39;s up to the programmer to look at all the bean properties and make sure they&amp;#39;re all set in the test. &amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Constructor injection is even more compelling when you are adding new dependencies to existing classes -- the IDE will remind you that your test objects are missing dependencies (because they are missing a constructor parameter) whereas setter injection will probably cause the test to fail at runtime with a NullPointerException.&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Re: Too many dependencies&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;As Paul said, if you have too many dependencies, there&amp;#39;s probably some other abstraction which is trying to come out. &amp;nbsp;Just like testing with mock objects can tell you if your interfaces need rethinking (&amp;quot;Why do I have to mock all these calls to get my code to work?&amp;quot;), long constructor lists can tell if you if you have too many or unusual dependencies.&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;And yes, a good IDE will help you deal with the mechanics of introducing new parameters, moving them, etc.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Dan&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;
</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Problem-with-annotation-injection-in-abstract-classes-tp20688511p20701299.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20696249</id>
	<title>Re: Problem with annotation injection in abstract classes</title>
	<published>2008-11-25T23:50:42Z</published>
	<updated>2008-11-25T23:50:42Z</updated>
	<author>
		<name>Paul Hammant-3</name>
	</author>
	<content type="html">Jonathan,
&lt;br&gt;&lt;br&gt;On Nov 26, 2008, at 12:23 AM, Jonathan Ariel wrote:
&lt;br&gt;&lt;br&gt;&amp;gt; Thank you very much! Really great job!
&lt;br&gt;&amp;gt; I understand that using constructor injection is better, but I don't &amp;nbsp;
&lt;br&gt;&amp;gt; like it when I have lots of dependencies (I mean 4 or 5 or even &amp;nbsp;
&lt;br&gt;&amp;gt; more). because that mean lots of parameters on every constructor of &amp;nbsp;
&lt;br&gt;&amp;gt; every subclass. If I discover that I need a new parameter in the &amp;nbsp;
&lt;br&gt;&amp;gt; super class constructor, I'll have to go and change every subclass &amp;nbsp;
&lt;br&gt;&amp;gt; constructor.
&lt;br&gt;&amp;gt; Do you think there is a better way to do that?
&lt;br&gt;&lt;br&gt;Well five is a bit borderline, yes. &amp;nbsp;Firstly, if you're using IDEA for &amp;nbsp;
&lt;br&gt;looking after your component set, then using the refactoring &amp;nbsp;
&lt;br&gt;&amp;quot;introduce parameter&amp;quot; can help lots - it you do that in the super &amp;nbsp;
&lt;br&gt;class, all subclasses will get it too. &amp;nbsp;Then there's &amp;quot;Change method &amp;nbsp;
&lt;br&gt;signature&amp;quot; which IDEA and Eclipse have.
&lt;br&gt;&lt;br&gt;Alternatively, the purists may study the five components that are &amp;nbsp;
&lt;br&gt;dependencies and wonder if there is some separation of concerts. &amp;nbsp;They &amp;nbsp;
&lt;br&gt;would try to look to see if there is some intermediate dependency that &amp;nbsp;
&lt;br&gt;could encompass the capabilities of, say, three of the components. &amp;nbsp; 
&lt;br&gt;With the introduction of the intermediate component, you would see a &amp;nbsp;
&lt;br&gt;reduce number of deps going into the final one. &amp;nbsp;Of course, that's &amp;nbsp;
&lt;br&gt;easy for me to say not having seen your set of components.
&lt;br&gt;&lt;br&gt;Are you using our @Inject annotation, or using your own one? &amp;nbsp;You'd be &amp;nbsp;
&lt;br&gt;using your own one if you're aiming at having the least dependency on &amp;nbsp;
&lt;br&gt;PicoContainer's classbase.
&lt;br&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; BTW really good job with PicoContainer. Good documentation also!
&lt;br&gt;&lt;br&gt;Thanks. &amp;nbsp;We've been improving it over the last year or so :-)
&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&lt;br&gt;- Paul
&lt;br&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Problem-with-annotation-injection-in-abstract-classes-tp20688511p20696249.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20692512</id>
	<title>Re: Problem with annotation injection in abstract classes</title>
	<published>2008-11-25T16:23:53Z</published>
	<updated>2008-11-25T16:23:53Z</updated>
	<author>
		<name>Jonathan Ariel</name>
	</author>
	<content type="html">Thank you very much! Really great job! &lt;br&gt;I understand that using constructor injection is better, but I don&amp;#39;t like it when I have lots of dependencies (I mean 4 or 5 or even more). because that mean lots of parameters on every constructor of every subclass. If I discover that I need a new parameter in the super class constructor, I&amp;#39;ll have to go and change every subclass constructor.&lt;br&gt;
Do you think there is a better way to do that?&lt;br&gt;&lt;br&gt;BTW really good job with PicoContainer. Good documentation also!&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;On Tue, Nov 25, 2008 at 10:14 PM, Paul Hammant &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20692512&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;paul@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;Jonathan,&lt;br&gt;
&lt;br&gt;
Fixed in revision 5083 for PicoContainer 2.7, thanks for reporting this.&lt;br&gt;
&lt;br&gt;
If you can, you should really use Constructor Injection. Even the Guice team recommends this :-)&lt;br&gt;
&lt;br&gt;
I&amp;#39;ve emailed you a snapshot jar separately.&lt;br&gt;
&lt;br&gt;
Regards,&lt;br&gt;&lt;font color=&quot;#888888&quot;&gt;
&lt;br&gt;
- Paul&lt;/font&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class=&quot;Wj3C7c&quot;&gt;&lt;br&gt;
&lt;br&gt;
On Nov 25, 2008, at 7:57 PM, Jonathan Ariel wrote:&lt;br&gt;
&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
Hi! I&amp;#39;m trying to do something like this without good results. Am I doing something wrong?&lt;br&gt;
&lt;br&gt;
public abstract class A {&lt;br&gt;
 &amp;nbsp;@Inject&lt;br&gt;
 &amp;nbsp;protected C c;&lt;br&gt;
&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
public class B extends A {&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
public class C {&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
MutablePicoContainer container = new PicoBuilder().withAnnotatedFieldInjection().build();&lt;br&gt;
container.addComponent(C.class);&lt;br&gt;
container.addComponent(B.class);&lt;br&gt;
&lt;br&gt;
and finally in when I do:&lt;br&gt;
&lt;br&gt;
B b = container.getComponent(B.class);&lt;br&gt;
&lt;br&gt;
in b the field c is null. I think the expected behavior is c being injected with an instance of C.&lt;br&gt;
&lt;br&gt;
What do you think?&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
Jonathan&lt;br&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class=&quot;Wj3C7c&quot;&gt;
---------------------------------------------------------------------&lt;br&gt;
To unsubscribe from this list, please visit:&lt;br&gt;
&lt;br&gt;
 &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;
</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Problem-with-annotation-injection-in-abstract-classes-tp20688511p20692512.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20692423</id>
	<title>Re: CollectionComponentParameter works differently with generic Collection types?</title>
	<published>2008-11-25T16:15:56Z</published>
	<updated>2008-11-25T16:15:56Z</updated>
	<author>
		<name>Paul Hammant-3</name>
	</author>
	<content type="html">It could be Daniel. &amp;nbsp;Ill compare your case for PicoContainer 2.4 and &amp;nbsp;
&lt;br&gt;latest to observe (and fix?) the difference.
&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&lt;br&gt;- Paul
&lt;br&gt;&lt;br&gt;On Nov 25, 2008, at 1:05 AM, Daniel Wellman wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Has the behavior of CollectionComponentParameter changed now that &amp;nbsp;
&lt;br&gt;&amp;gt; Pico 2
&lt;br&gt;&amp;gt; recognizes generic collection parameter types?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; In the example below, I expected that adding a &amp;nbsp;
&lt;br&gt;&amp;gt; CollectionComponentParameter
&lt;br&gt;&amp;gt; with a componentValueType of Cod.class would only have Cod fish in &amp;nbsp;
&lt;br&gt;&amp;gt; the bowl,
&lt;br&gt;&amp;gt; but I observe that it gets both Cod and Shark.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; If I repeat the experiment by making the Bowl have a type-erased &amp;nbsp;
&lt;br&gt;&amp;gt; List, the
&lt;br&gt;&amp;gt; test works as I expect -- I only get a Cod.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Is this the expected behavior for typed collections?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Test below:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public void testRegisteringSubsetOfGenericCollectionParameters() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;DefaultPicoContainer pico = new DefaultPicoContainer();
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(Cod.class);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(Shark.class);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(GenericBowl.class, GenericBowl.class,
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;new CollectionComponentParameter(Cod.class, false));
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;GenericBowl bowl = pico.getComponent(GenericBowl.class);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;// FAILS with PicoContainer 2.7-SNAPSHOT, returns 2
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertEquals(1, bowl.fishes.size());
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; // Types
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public static interface Fish {
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public static class Cod implements Fish {
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public static class Shark implements Fish {
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public static class GenericBowl {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;List&amp;lt;Fish&amp;gt; fishes;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;public GenericBowl(List&amp;lt;Fish&amp;gt; fishes) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.fishes = fishes;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ... but this one passes:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public void &amp;nbsp;
&lt;br&gt;&amp;gt; testRegisteringSubsetOfTypeErasedCollectionParameters() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;DefaultPicoContainer pico = new DefaultPicoContainer();
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(Cod.class);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(Shark.class);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;pico.addComponent(GenericBowl.class, GenericBowl.class,
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;new CollectionComponentParameter(Fish.class, false));
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;GenericBowl bowl = pico.getComponent(GenericBowl.class);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertEquals(2, bowl.fishes.size());
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertTrue(CollectionUtilities.contains(bowl.fishes, new
&lt;br&gt;&amp;gt; ContainsInstanceOfTypePredicate(Cod.class)));
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;assertTrue(CollectionUtilities.contains(bowl.fishes, new
&lt;br&gt;&amp;gt; ContainsInstanceOfTypePredicate(Shark.class)));
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; public static class TypeErasedListBowl {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;List fishes;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;public TypeErasedListBowl(List fishes) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.fishes = fishes;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://www.nabble.com/CollectionComponentParameter-works-differently-with-generic-Collection-types--tp20673363p20673363.html&quot; target=&quot;_top&quot;&gt;http://www.nabble.com/CollectionComponentParameter-works-differently-with-generic-Collection-types--tp20673363p20673363.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the NanoContainer - PicoContainer - Users mailing list &amp;nbsp;
&lt;br&gt;&amp;gt; archive at Nabble.com.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ---------------------------------------------------------------------
&lt;br&gt;&amp;gt; To unsubscribe from this list, please visit:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/CollectionComponentParameter-works-differently-with-generic-Collection-types--tp20673363p20692423.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20692398</id>
	<title>Re: Problem with annotation injection in abstract classes</title>
	<published>2008-11-25T16:14:35Z</published>
	<updated>2008-11-25T16:14:35Z</updated>
	<author>
		<name>Paul Hammant-3</name>
	</author>
	<content type="html">Jonathan,
&lt;br&gt;&lt;br&gt;Fixed in revision 5083 for PicoContainer 2.7, thanks for reporting this.
&lt;br&gt;&lt;br&gt;If you can, you should really use Constructor Injection. Even the &amp;nbsp;
&lt;br&gt;Guice team recommends this :-)
&lt;br&gt;&lt;br&gt;I've emailed you a snapshot jar separately.
&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&lt;br&gt;- Paul
&lt;br&gt;&lt;br&gt;On Nov 25, 2008, at 7:57 PM, Jonathan Ariel wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi! I'm trying to do something like this without good results. Am I &amp;nbsp;
&lt;br&gt;&amp;gt; doing something wrong?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; public abstract class A {
&lt;br&gt;&amp;gt; &amp;nbsp; @Inject
&lt;br&gt;&amp;gt; &amp;nbsp; protected C c;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; public class B extends A {
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; public class C {
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; MutablePicoContainer container = new &amp;nbsp;
&lt;br&gt;&amp;gt; PicoBuilder().withAnnotatedFieldInjection().build();
&lt;br&gt;&amp;gt; container.addComponent(C.class);
&lt;br&gt;&amp;gt; container.addComponent(B.class);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; and finally in when I do:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; B b = container.getComponent(B.class);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; in b the field c is null. I think the expected behavior is c being &amp;nbsp;
&lt;br&gt;&amp;gt; injected with an instance of C.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; What do you think?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Jonathan
&lt;/div&gt;&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Problem-with-annotation-injection-in-abstract-classes-tp20688511p20692398.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20690064</id>
	<title>RE: Problem with annotation injection in abstract classes</title>
	<published>2008-11-25T13:36:00Z</published>
	<updated>2008-11-25T13:36:00Z</updated>
	<author>
		<name>ErikNRC</name>
	</author>
	<content type="html">IMO, Guice 2 does a much better job with the injection... Pico is not very injection friendly...
&lt;br&gt;Pico doesn't currently handle inheritance with the injection. I asked for that feature long ago...
&lt;br&gt;&lt;br&gt;Erik.
&lt;br&gt;&lt;br&gt;________________________________________
&lt;br&gt;From: Jonathan Ariel [mailto:&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20690064&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ionathan@...&lt;/a&gt;] 
&lt;br&gt;Sent: November 25, 2008 2:58 PM
&lt;br&gt;To: &lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=20690064&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;user@...&lt;/a&gt;
&lt;br&gt;Subject: [picocontainer-user] Problem with annotation injection in abstract classes
&lt;br&gt;&lt;br&gt;Hi! I'm trying to do something like this without good results. Am I doing something wrong?
&lt;br&gt;&lt;br&gt;public abstract class A {
&lt;br&gt;  @Inject
&lt;br&gt;  protected C c;
&lt;br&gt;&lt;br&gt;}
&lt;br&gt;&lt;br&gt;public class B extends A {
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;public class C {
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;MutablePicoContainer container = new PicoBuilder().withAnnotatedFieldInjection().build();
&lt;br&gt;container.addComponent(C.class);
&lt;br&gt;container.addComponent(B.class);
&lt;br&gt;&lt;br&gt;and finally in when I do:
&lt;br&gt;&lt;br&gt;B b = container.getComponent(B.class);
&lt;br&gt;&lt;br&gt;in b the field c is null. I think the expected behavior is c being injected with an instance of C.
&lt;br&gt;&lt;br&gt;What do you think? 
&lt;br&gt;&lt;br&gt;Thanks,
&lt;br&gt;&lt;br&gt;Jonathan
&lt;br&gt;&lt;br&gt;---------------------------------------------------------------------
&lt;br&gt;To unsubscribe from this list, please visit:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://xircles.codehaus.org/manage_email&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xircles.codehaus.org/manage_email&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Problem-with-annotation-injection-in-abstract-classes-tp20688511p20690064.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20688511</id>
	<title>Problem with annotation injection in abstract classes</title>
	<published>2008-11-25T11:57:36Z</published>
	<updated>2008-11-25T11:57:36Z</updated>
	<author>
		<name>Jonathan Ariel</name>
	</author>
	<content type="html">Hi! I&amp;#39;m trying to do something like this without good results. Am I doing something wrong?&lt;br&gt;&lt;br&gt;public abstract class A {&lt;br&gt;&amp;nbsp; @Inject&lt;br&gt;&amp;nbsp; protected C c;&lt;br&gt;&lt;br&gt;}&lt;br&gt;&lt;br&gt;public class B extends A {&lt;br&gt;}&lt;br&gt;&lt;br&gt;public class C {&lt;br&gt;
}&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;MutablePicoContainer container = new PicoBuilder().withAnnotatedFieldInjection().build();&lt;br&gt;container.addComponent(C.class);&lt;br&gt;container.addComponent(B.class);&lt;br&gt;&lt;br&gt;and finally in when I do:&lt;br&gt;&lt;br&gt;B b = container.getComponent(B.class);&lt;br&gt;
&lt;br&gt;in b the field c is null. I think the expected behavior is c being injected with an instance of C.&lt;br&gt;&lt;br&gt;What do you think? &lt;br&gt;&lt;br&gt;Thanks,&lt;br&gt;&lt;br&gt;Jonathan&lt;br&gt;
</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Problem-with-annotation-injection-in-abstract-classes-tp20688511p20688511.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-20673363</id>
	<title>CollectionComponentParameter works differently with generic Collection types?</title>
	<published>2008-11-24T17:05:27Z</published>
	<updated>2008-11-24T17:05:27Z</updated>
	<author>
		<name>Daniel Wellman</name>
	</author>
	<content type="html">Has the behavior of CollectionComponentParameter changed now that Pico 2 recognizes generic collection parameter types?
&lt;br&gt;&lt;br&gt;In the example below, I expected that adding a CollectionComponentParameter with a componentValueType of Cod.class would only have Cod fish in the bowl, but I observe that it gets both Cod and Shark.
&lt;br&gt;&lt;br&gt;If I repeat the experiment by making the Bowl have a type-erased List, the test works as I expect -- I only get a Cod.
&lt;br&gt;&lt;br&gt;Is this the expected behavior for typed collections?
&lt;br&gt;&lt;br&gt;Test below:
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public void testRegisteringSubsetOfGenericCollectionParameters() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; DefaultPicoContainer pico = new DefaultPicoContainer();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; pico.addComponent(Cod.class);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; pico.addComponent(Shark.class);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; pico.addComponent(GenericBowl.class, GenericBowl.class,
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new CollectionComponentParameter(Cod.class, false));
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; GenericBowl bowl = pico.getComponent(GenericBowl.class);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // FAILS with PicoContainer 2.7-SNAPSHOT, returns 2
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; assertEquals(1, bowl.fishes.size());
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;// Types
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public static interface Fish {
&lt;br&gt;&amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;public static class Co