avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen McConnell <mcconn...@osm.net>
Subject Re: Optional Services/Context entrys
Date Sun, 09 Jun 2002 04:25:45 GMT

Bottom line - is I understand correctly this isn't an interface question 
- is more a question concerning a particular implemetation approach at 
the container/SM/CM level?

Steve.


Peter Donald wrote:

> Hi,
>
> After playing with the meta-info and going through a few use-cases one 
> of the questions that is still not answered. The main one is whether 
> it is valid for their to be "optional" entries in the ServiceManager 
> and/or Context. For instance would the following be valid use case in 
> case of ServiceManager
>
> void service( ServiceManager sm ) throws ServiceException
> {
>   if( sm.hasService( MyOptionalService.ROLE )
>   {
>      myOptionalService = (MyOptionalService)sm.lookup( 
> MyOptionalService.ROLE );
>   }
> }
>
> Ages ago we decided that it was bad form to do the above, however I 
> believe Berin has changed his mind (?) and I never really minded it. 
> For those of you who weren't around the main reason we decided we did 
> not like it was because it allowed the possibility of the following 
> kind of code
>
> if( sm.hasService( MyService.ROLE + "/key3" ) ) { ...use that 
> service... }
> else if( sm.hasService( MyService.ROLE + "/key2" ) ) { ...use that 
> service... }
> else if( sm.hasService( MyService.ROLE + "/key1" ) ) { ...use that 
> service... }
> else { ...use the base service... }
>
> The above code is bad as it mixes concerns. It should be 
> responsibility of assembler to map correct service implementation onto 
> single key rather than the developer who dictates assembly structure.
>
> In most cases "optional" entrys will never be used but in some (rare) 
> cases it could be useful. For example in Phoenix we have one case 
> where optional would be useful. What we end up having to do is create 
> a NoopSystemManager. There is a few cases in myrmidon that I would 
> also benefit from allowing "optional" entrys in context/serviceManager.
>
> Any problems with relaxing and allowing optional thingies?
>
>
> -- 
> 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