Re: [picocontainer-dev] requst for clarification
Paul Hammant <[email protected]>
| Newsgroups | gmane.comp.java.picocontainer.devel |
|---|---|
| Message-ID | <[email protected]> |
Its not compileing for me in trunk Konstantin, there's no ByClass and I'm not getting it without that clarity. Also, is there any way that you can illustrate the problem with child.getComponent(...) ? - Paul On Dec 1, 2007, at 7:18 AM, Konstantin Priblouda wrote: > > --- 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 > --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email