Multibinder extension not working with Roboguice 3

55 views
Skip to first unread message

Pawel Tschudnowsky

unread,
Jun 10, 2015, 10:50:14 AM6/10/15
to robo...@googlegroups.com
The version 3.0 of mutlibinder was working with roboguice 2.0 just fine. The version 4 (to match Guice 4) doesn't work with Roboguice 3 anymore.
I get Multibinder is not initialized Exception upon start which is cause by Multibinder check

private boolean
isInitialized() {
return binder == null;
}

So, if binder is not null, Exception is thrown because according to Multibinder-Description, it is set during configuration
and must be set to null after it. And here we come to the point, the method initialize

/**
* Invoked by Guice at Injector-creation time to prepare providers for each
* element in this set. At this time the set's size is known, but its
* contents are only evaluated when get() is invoked.
*/
@Toolable @Inject void initialize(Injector injector) {
List<Binding<T>> bindings = Lists.newArrayList();
Set<Indexer.IndexedBinding> index = Sets.newHashSet();
Indexer indexer = new Indexer(injector);
List<Dependency<?>> dependencies = Lists.newArrayList();
for (Binding<?> entry : injector.findBindingsByType(elementType)) {
if (keyMatches(entry.getKey())) {
@SuppressWarnings("unchecked") // protected by findBindingsByType()
Binding<T> binding = (Binding<T>) entry;
if (index.add(binding.acceptTargetVisitor(indexer))) {
bindings.add(binding);
dependencies.add(Dependency.get(binding.getKey()));
}
}
}

this.bindings = ImmutableList.copyOf(bindings);
this.dependencies = ImmutableSet.copyOf(dependencies);
this.permitDuplicates = permitsDuplicates(injector);
this.binder = null;
}

as you see from method description, it should be called from guice itself. and since Roboguice uses own version of guice
(or did I confuse something?) my question is, is it possible that roboguice version of guice is not calling this method
leaving Multibinder "unconfigured"?

Reply all
Reply to author
Forward
0 new messages