On Sun, 10 Oct 2004 23:17:12 +0900, Jamis Buck <jgb3 / email.byu.edu> wrote: > Did you want: > > (A) The have existing references to Logger refresh themselves and > start logging to the new file? or > > (B) To have existing references to Logger remain unchanged and have > new loggers start logging to the new file? > > (A) is not so simple to do (as I mentioned in my last post). (B), > however, would be much more straightforward. I'm not sure I was clear enough, and I am still of the opinion (A) would not be *that* complex to implement, bear with me, I'm not that good at describing it in English :) I wanted the registry to keep track of the dependency graph, so that when a service was changed, it would be marked dirty. The registry would then walk the dependency graph in reverse order, and mark all dependant services as dirty too. Being dirty just means that the next time a request for a dirty service was made, the creation block would be executed again, result cached, and marked clean. I realize "service was changed" is rather vague. In my case, I would probably write a service to contain configuration values like "filename" (I don't like mixing data-only services with services that actually do something). I'd add an domain-specific interceptor wrapping this configuration service, that would know which method invocations on the service are 'writes'. The interceptor would then send a message to the registry, saying "service :config is dirty". The registry, because it knows the dependencies on :config, can mark :config and all things that used :config, as dirty. The registry would know the dependency graph, because: any services depending on :config would have done a "reg.config.value" in their construction block. In effect, this would be (A) above. Pseudo-code: reg.register(:config) { Configuration.new } reg.intercept(:config).with { |reg| ConfigurationInterceptor.new(reg} } reg.register(:logger) { |reg| Logger.new(reg.config.filename) } .... somewhere else in application: reg.config.filename = "newfile" Because the construction block for :logger called reg.config, the registry is aware that it depends on :config. The reg.config.filename assign would have been caught by the interceptor as a "write", and once completed, the interceptor would send a dirty(:config) message to the registry. I was thinking, for this particular approach to work, |reg| in the :logger construction block might need to be a proxy that collects the services used in the block, and adds them to a dependency graph, instead of being the registry itself (for thread-safety?) Hope that gives you more of an idea of what I'm getting at... Leon