Let's say I have two applications sharing the same library. This library contains common classes like DAOs, Utils, etc. Everything in the shared library is wired with Guice. My two apps depend on this library but do not have a direct dependency on Guice.
______ ______ ______
| | | | | |
| APP1 |->| LIB |<-| APP2 |
'------' '------' '------'
I currently use something like this:
static <T> Utils.getInstanceOf (Class<T> type);
which is simply a wrapper for:
injector.getInstance (Class<T> type);
But the guice docs say:
When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time.
So what's the best way to provide dependency injection for the two apps without having to manually bind them in a Guice module?