No, I this is not possible. The injector injects the same class independent of the target. This means if there are no additional annotations it will always inject either A1 or A2 (depends on the configuration in the module) for IA. The same holds for the Bs.
Am 2. September 2015 14:33:57 MESZ, schrieb jh24 <[email protected]>: >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. > >-- >You received this message because you are subscribed to the Google >Groups "google-guice" group. >To unsubscribe from this group and stop receiving emails from it, send >an email to [email protected]. >To post to this group, send email to [email protected]. >Visit this group at http://groups.google.com/group/google-guice. >To view this discussion on the web visit >https://groups.google.com/d/msgid/google-guice/b30fa4f3-c3e2-42e7-bd4d-d2154af443ec%40googlegroups.com. >For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-guice. To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/E64A4CBA-FD83-4417-9E0D-8A04CCF0C8B6%40gmx.ch. For more options, visit https://groups.google.com/d/optout.
