On 08/10/10 15:35, Jason Winnebeck 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.
That's an excellent point. I encountered another strange situation where guice
instantiates a singleton multiple times:
In case the bootstrapping fails, guice tries to continue and collect
any error that occurs to produce that javac-like error message.
During that boot it may happen that your broken singleton is required
three times and guice attempts to create it three times.

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