Hi,
Suppose the following classes/interfaces are given:
interface IA { }
public final class A implements IA {
IB b;
@Inject
public A(IB b) { this.b = b; }
}
public final class A2 implements IA { }
interface IB { }
public final class B implements IB {
IA a;
@Inject
public B(IA a) { this.a = a; }
}
public final class B2 implements IB { }
Ie. there are two implementations of IB, one of which depends on IA, and there are two implementations of IA, one of which depends on IB.
Is it possible to create a single injector for which:
(a) injector.getInstance(IA.class) returns an instance of A whose field 'b' is an instance of B2,
(b) injector.getInstance(IB.class) returns an instance of B whose field 'a' is an instance of A2, and
(c) no extra annotations are added to the above classes.
Apologies if this actually has a straightforward solution. Examples appreciated.