diff --git a/matsim/src/main/java/org/matsim/core/controler/AbstractModule.java b/matsim/src/main/java/org/matsim/core/controler/AbstractModule.java index fec41cc88f6..d6d3eb94efa 100644 --- a/matsim/src/main/java/org/matsim/core/controler/AbstractModule.java +++ b/matsim/src/main/java/org/matsim/core/controler/AbstractModule.java @@ -113,6 +113,14 @@ public final void configure(Binder binder) { // not in this class. this.binder = binder.skipSources(AbstractModule.class); + initializeMultibinders(); + + this.install(); + } + + private void initializeMultibinders() { + // We do need to make these calls here in order to register the multi binders. Otherwise, guice doesn't know, that they exist. In particular, + // if none of the corresponding addXXXBinding methods was called, the set binder would not be registered, and guice would complain. this.mobsimListenerMultibinder = Multibinder.newSetBinder(this.binder, MobsimListener.class); this.snapshotWriterMultibinder = Multibinder.newSetBinder(this.binder, SnapshotWriter.class); this.eventHandlerMultibinder = Multibinder.newSetBinder(this.binder, EventHandler.class); @@ -124,7 +132,6 @@ public final void configure(Binder binder) { new TypeLiteral>() {} ); this.qsimModulesMultibinder = Multibinder.newSetBinder(this.binder, AbstractQSimModule.class); this.qsimOverridingModulesMultibinder = Multibinder.newSetBinder( this.binder, AbstractQSimModule.class, Names.named( "overridesFromAbstractModule" ) ); - this.install(); } public abstract void install();