I created a class that uses the the Java Executor API to create/manage a pool with fixed number of threads. Each thread needs a new instance of a particular object, and I would like to inject this object with Guice. For the moment I'm using a Provider which provides new instances of the object through its get() method.
But now this class has a dependency to the Provider, which is Guice specific, effectively coupling the code to the Guice framework. I would really like the class to be truly Guice agnostic, is this possible?
Just creating new instances of using the 'new' keyword is not an option, as this makes it impossible to replace those object by a mock implementation in the unit test.
Dependency injection is probably not suited for this and I would be better of creating a factory to get these objects?