Re: [picocontainer-dev] requst for clarification

Konstantin Priblouda <kpriblouda-/[email protected]>
Newsgroups gmane.comp.java.picocontainer.devel
Message-ID <[email protected]>
--- Paul Hammant <[email protected]> wrote:

> Yes -
> 
>      public void testFoo() {
>          MutablePicoContainer parent =
> createPicoContainer(null);
>          MutablePicoContainer child =
> parent.makeChildContainer();
>          parent.addComponent(Integer.class, 1234);
>          child.addComponent(Integer.class, 5678);
>          child.addComponent(NeedsTwo.class); //
> NeedsTwo take an  
> Integer param and assigns to pub field 'two'
>          assertEquals(5678,
> child.getComponent(NeedsTwo.class).two);
>      }
> 
> However, you are alluding to a more sophisticated
> case than the above ?

Kind of:

	public void
testChildKeyMasksParentAdapterRegardlessOfType() {
		MutablePicoContainer parent = new
DefaultPicoContainer();
		MutablePicoContainer child = new
DefaultPicoContainer(parent);
		
		
		parent.addComponent("foo bar",239);
		parent.addComponent(515,515);
		// shall mask in parent
		child.addComponent("foo bar");
		
		// only 1 integer is resolvable here
		ByClass byClass = new ByClass(Integer.class);

		// shall retrieve all the integers from both
contaienrs
		assertEquals(1,byClass.lookup(child).size());
		
	
assertEquals(515,((ComponentAdapter)byClass.lookup(child).iterator().next()).getComponentKey());
	}


Here "foo bar" in child container ( which is string ) 
masks  integer keyed by "foo bar"

regards,

----[ Konstantin Pribluda http://www.pribluda.de ]----------------
JTec quality components: http://www.pribluda.de/projects/


      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.