2008/12/11 chouaieb jalloul <[email protected]> > > hi, > I tried to create two implementations of a simple service installed on > osgi. When a consumer would like to use this service, it was the first > provider installed that was used. Even when I uninstall it, it's still > be used. I think it's because peaberry created a proxy for this one.
[ I've copied this reply to the [email protected] list, as that's more appropriate for this sort of question ] As discussed on the design page ( http://code.google.com/p/peaberry/wiki/DetailedDesign) peaberry injects a simple proxy that dynamically delegates to the most appropriate service, you can also use decoration to change this behaviour to support "sticky" services, etc. So from a Guice perspective setter injection is still static, in that your setter method will only be called once with the proxy - you won't see your setter method repeatedly called as services appear or disappear. If we did this then we'd also have to consider how to handle constructor injection (ie. should we rebuild the object graph?) otherwise you'd get different behaviour depending on whether you chose setter or constructor injection. However this shouldn't be a problem, because when you call the injected proxy it will delegate dynamically - so for the example above, once you uninstall the first service you should see the second service being called (this is one of the main testcases), and in most situations this is what you really want. FYI, you can also ask peaberry to skip the proxy and inject the real service, but then this means you're tied to that service instance until you re-inject the object or create a new one. If you're looking for some sort of notification call that a service has appeared then this is being planned, and this would then let you rebuild your object graph based on the new service (ie. it would be you initiating the rebuild using the injector, not Guice). The benefit of this approach is that we don't need to change how bindings and injection work in Guice (bindings are still static). I did the same thing with Spring-DM, and it used the first installed, > but since uninstalled it switches to the other one. > I was wondering if peaberry could do the same thing, and how much time > the proxy would be still persistent after uninstalling a provider. > thanks > I think it's best if you provide a testcase and post it to the [email protected] list (or send it to me directly) because what you're describing is definitely achievable with peaberry - but if you're expecting your setter method to be called again when the service is uninstalled then that won't happen... HTH -- Cheers, Stuart --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-guice?hl=en -~----------~----~----~----~------~----~------~--~---
