Closed GoogleCodeExporter closed 8 years ago
[deleted comment]
The following patch successfully passes all unit tests:
Index: src/com/google/gwt/inject/rebind/BindingsProcessor.java
===================================================================
--- src/com/google/gwt/inject/rebind/BindingsProcessor.java (revision 135)
+++ src/com/google/gwt/inject/rebind/BindingsProcessor.java (working copy)
@@ -566,10 +566,6 @@
}
private void addBinding(Key<?> key, Binding binding) {
- if (bindings.containsKey(key)) {
- logError("Double-bound: " + key + ". " + bindings.get(key) + ", " +
binding);
- return;
- }
JClassType classType = keyUtil.getRawClassType(key);
if (classType != null && !isClassAccessibleFromGinjector(classType)) {
Original comment by jarrod.c...@gmail.com
on 15 Mar 2010 at 1:59
Guice does not allow duplicate bindings. There is no ordering between modules,
so
there would be no way to resolve the duplication.
Guice does support Modules.override as a way to override some bindings. That
would
be a fine feature request for Gin (and I think it's filed).
Original comment by bstoler+code@google.com
on 15 Mar 2010 at 3:32
And I'd add that for "default bindings" you can annotate your interfaces and
classes
with @ImplementedBy or @ProvidedBy, and these are "JIT bindings" so they can be
overridden by "explicit bindings".
Original comment by t.broyer
on 15 Mar 2010 at 9:53
Well, okay, maybe I didn't read the Guice documentation clearly enough or I
didn't
understand it well enough.
In either case, unless I'm missing something, this still doesn't provide me a
way to
bind my singletons eagerly. Meaning, there is no @Singleton(eager = true), or
@ImplementedBy(eager = true).
So if I want my singleton binding to be eager, I have to explicitly bind it in a
module. And that means then that I can't provide default implementations left
for
other modules to override.
Or maybe I'm just going about it all wrong?
Original comment by jarrod.c...@gmail.com
on 20 Mar 2010 at 6:27
Original issue reported on code.google.com by
jarrod.c...@gmail.com
on 15 Mar 2010 at 1:49