Status: New
Owner: ----

New issue 468 by iyosifov: The Singleton annotation should be itself @Inherited annotated
http://code.google.com/p/google-guice/issues/detail?id=468

I'm new to guice and dependency injection in general so please correct me
if my usage pattern is obviously bogous.

The problem I ran into is basically thus:

The app I'm working on has a core package which defines infrastructure code
and very abstract ( that is - lots of empty methods, not actually abstract
) Service Provider classes. Suppose Core is one such class. Core is
@Singleton annotated and multiple parts of the code take Core injections.

There's a basic package which contains some skeleton code for the Core SP.
Suppose Basic is a class that extends Core and adds some substance to it.
Basic itself isn't @Singleton annotated. There's also a basic guice module
that binds Core to Basic.

There's an app package which contains the actual logic. It contains an App
class that inherites Basic. App too isn't @Singleton annotated. There's
also an app guice module that binds Basic to App.

Both the basic and app guice modules are installed, so the binding chain
ends up being Core -> Basic -> App.

The problem is that the in the end multiple instances of App are
constructed in the infrastructre code even though it only takes Core
injections and Core is explicitly expected to be a singleton. I've been
able to work around this problem by copying the Singleton annotation
definition into my project and adding @Inherited to it. This results in
both Basic and App themselves being implicitly @Singleton annotated. This
makes sense since they inherit an explicitly supposed-singleton base.

On the other hand, ending up with multiple "singleton" instances for
whatever reason doesn't seem correct.


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" 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-dev?hl=en.

Reply via email to