-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
When creating a multibinder with the same key as the parent module in a PrivateModule, guice produces an error. This check avoids the confusing situation of having different multibindings based on the location of injection, but it creates a problem: if a private module wants to "inherit" all of the multi-bindings from the parent in its own multibinder with a different key, it must manually re-state each binding. This is error-prone and cumbersome.
To support this use case, we could allow a multibinder to copy/inherit all the bindings from another multibinder of the same type. e.g. LinkedBindingBuilder<T> inheritBindings(Multibinder<T> multibinder)
Motivation: Multibinders are often used with AOP type patterns. I recently found a case in our code base where private datasource modules were not getting important execution listeners wired up to terminate long running database queries!