It looks like you basically donβt understand how dependency injection works. If you try to use the Injector link anywhere in your code except where you download the application, you do not use dependency injection, instead you use it as a service locator. You must prepare Injector when you need to test a class, and your classes do not specify in their constructors what their dependencies are (since who knows what they will choose from Injector in some if they have or can get a link to it). In fact, using enum , as you described here, is even worse: you cannot change the configuration at all, even for testing, because your modules are hard-coded into an enumeration.
With dependency injection, classes only declare their dependencies and allow Injector to work transparently (after the initial call to get the root application object) to provide all of these dependencies. This makes it easier to understand, test, and change the functionality of your code. Anyway, I would suggest learning more about how DI and Guice are meant to be used ... you really shouldn't.
source share