Gonzalo A. Diethelm wrote:

>>>ComponentException is a
>>>system exception not an application system and should be handled by the
>>>container not by individual component. Receiving a ComponentException
>>>should mean that the whole component is fubared.
>>>      
>>>
>>I simply disagree on the concept, but it doesn't matter as long as there
>>is a way to ask to the container if a component is present in the system
>>without having to catch an exception.
>>    
>>
>
>I'm a non-committer and a total Avalon newbie, but I just can't resist.
>In the olden days (read: C programming), it would be OBVIOUS that you
>would do
>
>  Component c = container.lookup(name);
>  if (c == null)
>    // not found
>  else
>    // found
>
>I know having the exists() method achieves the same, but any sane
>programmer would retch at the idea of doing TWO searches, one to
>ensure the component is there, one to retrieve it.
>
>There, I said it. Perhaps this doesn't apply in the Avalon world, but
>I fail to see why lookup() couldn't just simply return the component
>when it is found, or null in any other case.
>

Something to consider is that an exist operation can be interprited as 
"tell me if it is possible to return a service corresponding to profile 
I'm providing".  This allows a type based response by a container - 
because the container knows if the service type is valid, and if the 
assembly constraints are valid, and as such, it knows if it is possible 
or not without actually instantiating the service.  This means that the 
instantiation arrising from a lookup invocation can be deferred until 
such time that the service is actually needed (if at all), resulting in 
reduced memory footprint and faster component initialization times.

Cheers, Steve.


-- 

Stephen J. McConnell

OSM SARL
digital products for a global economy
mailto:[EMAIL PROTECTED]
http://www.osm.net




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to