On Tue, Apr 5, 2011 at 11:46 AM, Ori <[email protected]> wrote:
> I have an interface whose implementations are by definition
> singletons.
>
> Is there a way for me to bind all its instances as Guice singletons
> without annotating every single one?
>
> In other words, by default Guice will inject implementations of this
> interface in NO_SCOPE. I'd like the default scope for implementations
> of this interface to be SINGLETON.

You can achieve something like this in you module by using explicit
singleton scope binding
---
List<Class> classes = [get implementors of interface]
foreach (Class c : classes) {
  bind(c).in(Scopes.SINGLETON);
}
---
>
> Thanks.
>
> --
> 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.
>
>



-- 
want to chat with me? http://tinyurl.com/5u3ohp

-- 
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.

Reply via email to