avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen McConnell <mcconn...@apache.org>
Subject Re: reduction ad unum
Date Sat, 23 Nov 2002 18:00:19 GMT


Noel J. Bergman wrote:

>>It looks good, but I really do not like the mass of castings begin done.
>>    
>>
>
>The ability to do the cast requires an IS-A relationship.  I would prefer
>something like:
>
>     T t = (T) context.get(T.class);
>  
>

You can avoid the IS-A overhead if the context entry class is declared 
as part of the component description.  In such a case you just need:

  T t = (T) context.get( "t" );

The container ensures that the entry value returned for the key "t" is 
castable to T.

>and I believe that this better satisfies your examples, as well.  There is
>nothing here that talks about implementation.  It simply says that a context
>can have multiple interfaces, and that there is a method on the context by
>which to acquire a specific one.
>
>This is just a strawman.  I've left out exception/error handling, and well
>as a .has(Class) method, and I'm not married to the idea that this is a
>Context method, although I believe that to be the right place.
>
>Workable?  :-)
>

Not using the get method because get takes a string.

Cheers, Steve.

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

-- 

Stephen J. McConnell

OSM SARL
digital products for a global economy
mailto:mcconnell@osm.net
http://www.osm.net




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


Mime
View raw message