hjohn / Dirk

Dirk DI, a light-weight DI framework which can have its dependencies changed at runtime

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Injector enforces consistency during add or removal, but how to allow replacing?

hjohn opened this issue · comments

Currently there is no way to replace a type with another type if this type is currently used as a dependency. Adding a replacement would lead to an AmbiguousRequiredDependencyException while first removing the existing type would lead to an UnsatisfiedRequiredDependencyException. It should not be impossible to allow for an addition and removal simultaneously with the end result still satisfying all required dependencies.

This may have a use case during testing where a registered bean may be replaced completely with a mock.