I want to conduct a chain of processing elements and wire them together via Guice. Let's assume the following path:
interface Aimplemented byclass AImplneeds some inputinterface Bimplemented byclass BImplneedsAinterface Cimplemented byclass CImplneedsBinterface Dimplemented byclass DImplneedsC
The dependency of A can only be resolved at runtime and not at configuration time. The usual approach would be to use Assisted Injection in this case to create a factory, that takes the missing instances as parameters, just like this:
public interface AFactory { public A createA(String input); } But what I actually want is something like this:
public interface DFactory { public D createD(String inputForA); } I don't want to manually pass AImpl-specific dependencies through the whole hierarchy. Is it possible to achieve this with Guice? If not, what's the best way to circumvent this problem elegantly while still retaining benefits of injection?