Connection-scoped injection

There’s something I don’t quite understand: when you have an object bound in a ConnectionContainerModule, can it be injected into an object in another connection container module than the one it was defined in? If yes, how does the correct object get picked? By correct I mean the one bound to the same connection.

[original thread by Thomas Mäder]

Conceptually you can think that there is the application-wide scope and scope per a connection. Objects from a connection scope can access (via injection) any object from connection and application scopes. Objects from the application scope cannot access objects from any connection scope.

From implementation view, a new DI container is created for each connection and all connection container modules are loaded into it following topological order of extensions contributing them. Happens here:

Regarding your question: yes, you can inject an object contributed by one module into an object contributed by another since they belong to the same scope (DI container).