I'm only binding the class, e.g.
        bind(EventManager.class).asEagerSingleton();

The EventManager.class also has a @Singleton annotation, but my
understanding is that the binding in the module config takes
precedence.  In any case, shouldn't a singleton be instantiated just
once?

On Oct 8, 9:35 am, Jason Winnebeck <[email protected]> wrote:
> I'm not sure if this is your problem or not, but myself and a lot of other
> people have gotten confused when starting with guice that bindings have
> singleton scope, not classes. For example: if you bind A to X as singleton and
> B to X as singleton you will actually get two instances of X, because you're
> saying that A and B are singletons, not X. You need to bind A to X and B to X
> *then* bind X as singleton if you want both A and B injections to share the
> same X instance.
>
> Jason
>
> On 10/8/2010 9:26 AM, batkins wrote:
>
> > I'm seeing a class bound with asEagerSingleton() constructed 3 times
> > (based on a log message in the single, default constructor).  Why is
> > this the case?  Do I really have 3 instances running around?
>
> > 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.

Reply via email to