[picocontainer-dev] Parameter names question

Paul Hammant <[email protected]>
Newsgroups gmane.comp.java.picocontainer.devel
Message-ID <[email protected]>
Folks,

See http://picocontainer.org/component-configuration.html ... section  
called "Relying on parameter names" and its example - BigFatComponent

We've debated the need for the dummy components before. It troubles  
me too there is not a more elegant design to prevent accidental  
population of a type with something that's not for it.  See  
initForConfig() in DefaultPicoContainer , which it might be best for  
us to dispense with.

What if we had two modes of operation, like so:

Mode 1 - Components are injected by type first, where there are more  
than one type that could satisfy a ctor argument, then the parameter  
name can be used to select the appropriate thing to inject.

Mode 2 - Components are injected by parameter name first, and where  
there is nothing so-named that could be injected, then the parameter  
will be resolved by type.

I can kinda see that working. I'm wondering how the two modes are  
triggered..

Should we have a setMode(..) on DPC ?  With a better name of course.

Or should we have a different container - NamedParameterPicoContainer  
or NameFirstPicoContainer (yeesh)

Or should we somehow set a name-first preference for a component on  
registration ..

    pico.as(NAMED_PARAMS).addComponent(BigFatComponent.class)

Hmmm, now that I've typed it, that last looks attractive.

Thoughts?

- Paul



---------------------------------------------------------------------
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.