Hello, I think I can answer your question... When looking up a Component
from the ExcaliburComponentManager, it is always a one-one mapping. The
ComponentSelector is just another type of Component! Normally the
ComponentSelector is bound under the name Component.ROLE + "Selector", so
your code does not necessarily have to change. For example, you could bind a
default implementation under Component.ROLE, and your new code can lookup
the ComponentSelector under Component.ROLE + "Selector" and select an
appropriate implementation (Of course, this will mean that you have an extra
component lying around just for legacy code.)
Another alternative would be to write a custom ComponentManager and override
the behavior of lookup(). In the case where nothing is bound under
Component.ROLE it would check to see if a ComponentSelector is bound under
the name Component.ROLE + "Selector". If so, it would then select a
"default" implementation and return that. Your ComponentManager would have
to somehow know which hint is the default, perhaps by the configuration.
E.g.
<component
class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector"
role="MyComponentSelector" default-hint="default">
<component-instance name="default" class="MyDefaultImpl"/>
</component>
Regards,
--mike
-----Original Message-----
From: Torsten Curdt [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 11, 2002 1:24 AM
To: Avalon Developers List
Subject: From a single Component to ComponentSelector
I have a question on the (current;) ComponenManager.
Right now I have a Component in our project which
can simply looked up by "cm.lookup(role)" but now
I'm about to need another Component for the same
role. So usually I would use a ComponentSelector
for this. But what happens with the current code
where I only do a lookup(role). Do I have to go
threw the code and change this to use the
ComponentSelector, too?
In the end it comes to one question: What's the
behaviour of the ComponentManager when a "lookup(role)"
is called when there are more than one Components
for that role?
--
Torsten
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>