Am 08.03.12 13:56, schrieb Uwe San:
> Hi all,
>
> does Riena work with Guice, i.e., could I use Guice for dependency injection instead of Riena's own DI mechanism?
>
> I know the advantages of Riena's DI mechanism as defined at
> wiki.eclipse.org/Riena_Getting_Started_with_injecting_services_and_extensions :
>
> Quote:
>> code-based, i.e. no XML configuration files
>> fluent interfaces
>> conventions that simplify the injection definitions.
>
>
> As I see it, Guice fulfills these requirements pretty well. What would be the disadvantages of Guice in a Riena context?
> I'm sure there are good reasons why Riena has its own DI.
>
> Thanks,
> Uwe
I am starting to play with Guice in another project and get to know. Riena only has its own DI annotations and injectors
but it uses the lifecycle and rules of the underlying extensions (Equinox) and services (OSGi). Both of them have a
dynamic nature, so extensions and services can be added and removed at runtime which requires the Injector to unbind and
bind as it fits.

Guice is very different as it injects components but only at start (AFAIK). Once everything is injected the object model
is rather static. Guice has no real notion for a component that is stopped and there must be unbinded....

Another difference is that multiple services implementing the same interface is something very common in OSGi and
therefor everyfor every component that gets services injected is prepared for this. In Guice this is also possible but
(AFAIK) more the exception. Quit often you will have singletons that get injected and bind..

And Riena also has the capability of injecting extensions via dynamic proxies that map to the underlying representation of extension (extension registry).
And like Rienas service injection this honors the fact that bundles may come and go.

Christian, Stefan, thanks for your comments. My insights into Riena's DI concept and how it fis into the general context start growing.

Quote:

Another difference is that multiple services implementing the same interface is something very common in OSGi and
therefor everyfor every component that gets services injected is prepared for this. In Guice this is also possible but
(AFAIK) more the exception.

I think this feature is supported by Guice but maybe rarely used. So any Guice user is free to make it more popular.

Are you guys familiar with the peaberry extension for Guice (as described at code.google.com/p/google-guice/wiki/OSGi)? I'm not an expert on this, but it sounds like it provides the support for dynamic services you are referring to in Riena.