Discussion:
[guice] Multibinder Bindings Don't Always Respect Singleton Scope (#791)
Grégory Joseph
2015-02-25 18:38:38 UTC
Permalink
Is there no way around this ? (e.g is it unreasonable to _not_ want to explicitly bind using ```FooImpl``` as a key, or at least not make it injectable? If ```Foo implements Bar``` want to be able to inject ```Foo``` as well as ```Set<Bar>```, but not ```FooImpl```)

---
Reply to this email directly or view it on GitHub:
https://github.com/google/guice/issues/791#issuecomment-76026542
--
You received this message because you are subscribed to the Google Groups "google-guice-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+***@googlegroups.com.
To post to this group, send email to google-guice-***@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice-dev.
For more options, visit https://groups.google.com/d/optout.
Sam Berlin
2015-02-25 18:46:38 UTC
Permalink
The best way to make FooImpl not injectable is to make it package-private, so others can't refer to it.

---
Reply to this email directly or view it on GitHub:
https://github.com/google/guice/issues/791#issuecomment-76028164
--
You received this message because you are subscribed to the Google Groups "google-guice-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+***@googlegroups.com.
To post to this group, send email to google-guice-***@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice-dev.
For more options, visit https://groups.google.com/d/optout.
Grégory Joseph
2015-02-26 11:43:08 UTC
Permalink
Sure; that works if I have a Module in that same package. I'm dealing with a ball of legacy code, and can't really do that (or ensure that everyone does it, anyway). That said, the extra binding is also probably no big deal, but I have no way of checking (in plugin-based environment, my only option now is to let the bindings fail at runtime, and it might not fail for everyone)

---
Reply to this email directly or view it on GitHub:
https://github.com/google/guice/issues/791#issuecomment-76164516
--
You received this message because you are subscribed to the Google Groups "google-guice-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+***@googlegroups.com.
To post to this group, send email to google-guice-***@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice-dev.
For more options, visit https://groups.google.com/d/optout.
Grégory Joseph
2015-03-02 10:00:36 UTC
Permalink
Sam and OP, I got this to work this way:
Op's original binding:
````
binder.addBinding().to(B.class).in(Singleton.class);
````
replaced by this:
````
binder().bind(B.class).in(Singleton.class);
binder.addBinding().to(Key.get(B.class));
````
makes it work as we expect. WDYT ?

---
Reply to this email directly or view it on GitHub:
https://github.com/google/guice/issues/791#issuecomment-76685159
--
You received this message because you are subscribed to the Google Groups "google-guice-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+***@googlegroups.com.
To post to this group, send email to google-guice-***@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice-dev.
For more options, visit https://groups.google.com/d/optout.
Loading...