properly bind ClassSet extensions as singletons

The ExtensionPoint.ClassSet binds adds the extension classes to a a Multibinder and binds
the classes and calls the asEagerSingleton method on the multibinder. This does not actually
create a singleton. Instead we first bind the class as a singleton and add then add the class
to the multibinder.

Closes #14194
This commit is contained in:
jaymode 2015-10-21 15:01:24 -04:00
parent 75cedca0da
commit ec4307f080
1 changed files with 2 additions and 1 deletions

View File

@ -191,7 +191,8 @@ public abstract class ExtensionPoint {
protected final void bindExtensions(Binder binder) { protected final void bindExtensions(Binder binder) {
Multibinder<T> allocationMultibinder = Multibinder.newSetBinder(binder, extensionClass); Multibinder<T> allocationMultibinder = Multibinder.newSetBinder(binder, extensionClass);
for (Class<? extends T> clazz : extensions) { for (Class<? extends T> clazz : extensions) {
allocationMultibinder.addBinding().to(clazz).asEagerSingleton(); binder.bind(clazz).asEagerSingleton();
allocationMultibinder.addBinding().to(clazz);
} }
} }
} }