Problem with annotated and scoped provider binding

10 views
Skip to first unread message

Drew

unread,
Sep 7, 2011, 10:17:04 PM9/7/11
to google-guice
Hi Everyone,

I have the following in my module:

bind(Datastore.class).annotatedWith(DocumentStore.class).toProvider(DocumentDatastoreProvider.class).in(Singleton.class);
bind(SomeDao.class).to(SomeDaoImpl.class).in(Singleton.class);

And here's SomeDaoImpl constructor

@Inject
public SomeDaoImp(final @DocumentStore Datastore datastore) {
super(datastore);
}


But seems like the Datastore is not singleton and
DocumentDatastoreProvider.get() gets called many times.

What's the issue?

- Drew

Sam Berlin

unread,
Sep 9, 2011, 11:32:27 AM9/9/11
to google...@googlegroups.com
Is anything else binding to DocumentDatastoreProvider?

sam


--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To post to this group, send email to google...@googlegroups.com.
To unsubscribe from this group, send email to google-guice...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.


bklough

unread,
Sep 13, 2011, 11:06:33 AM9/13/11
to google...@googlegroups.com
I believe DocumentDatastoreProvider needs @Singleton or skip the Provider and bind as you do but directly to the implementation class.
Reply all
Reply to author
Forward
0 new messages