From: Jamis Buck Date: 2004-10-07T22:01:42+09:00 Subject: Re: Ruby-esque Inversion of Control Brian Candler wrote: > It doesn't work for all cases - e.g. where you want to change logging so > that one component gets a different logger. In that particular example, you > could rebuild the dependency information to allow for it: [snip] In Copland, I have a LogFactory service which intelligently manages the instantiation of logger instances. It can be configured to specify a differently-configured logger for different services. This requires that some additional information be passed to the constructor block, such as the metadata about the service being constructed, so that the LogFactory can be given enough information to configure the new logger correctly. Something (roughly) like this: container.register( :service ) { |c,meta| svc = NewService.new svc.logger = c.log_factory.get( meta ) svc } - Jamis -- Jamis Buck jgb3@email.byu.edu http://www.jamisbuck.org/jamis