avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <pe...@apache.org>
Subject Re: From a single Component to ComponentSelector
Date Mon, 11 Feb 2002 08:57:44 GMT
On Mon, 11 Feb 2002 19:23, Torsten Curdt wrote:
> 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?

It really depends on how you want to do it. For instance there is an 
alternative to using a ComponentSelector if you have a fixed number of 
alternatives. For instance consider the case of a Mail server which  has 
access to 2 MailRepository components. The first one is for spooling (ie 
temporary storage while being processed) and the second is for long term 

Both components implement the same interface - namely MailRepository - but 
they are different roles because one is intended to be used as a spool while 
the other is intended to be used for long term storage. So I would store them 
flatly in the ComponentManager as

MailRepository.ROLE --> LongTermMailRepository object
MailRepository.ROLE + "/Spool" --> ShortTermSpoolMailRepository object

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

The default ComponentManager would only return the component last added under 
the specific role.



| Wise men don't need advice. Fools don't take it. |
|              -Benjamin Franklin                  |

To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>

View raw message