Leo Sutic wrote:
>
> All,
>
> as it is now, the ComponentManager will throw an exception if the role
> passed to lookup(String) does not match an existing component.
>
> This means that one can in theory write components/composers that adapt
> according to the available services by doing something like this:
<snip/>
> But this is ugly, and I have not found a general guideline in the Avalon
> docs for this.
I agree, it is ugly.
> I propose the following addition to the ComponentManager interface:
>
> /**
> * Checks if the component manager has a component corresponding
> * to the specified role.
> *
> * @param role the role name
> * @return true if the manager has a component associated with the
> * given role, false otherwise.
> * @throws ComponentException if an error occurs.
> */
> public boolean hasComponent (String role) throws ComponentException;
>
> So the vote is: Should the ComponentManager interface be extended in the way
> described above?
Any simple boolean "discovery" methods should never throw an exception.
It only complicates matters.
There comes two questions for the need for this approach:
1) If we are talking about NEEDED components that the calling Component
must have in order to work, then we need to strengthen the contract
between the parent and child Components. The Parent MUST know what
its children NEED. Anything less is an incorrectly designed system.
2) If we are talking about OPTIONAL components that the calling Component
would like to have for ADDITIONAL functionality, then this approach
greatly simplifies coding. The Parent still must know what the child
NEEDS, but is not required to supply any OPTIONAL components.
So for the existance of this method, I am +1--as long as no exception is thrown.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]