0

im using GIN and want to avoid carrying dependency without using a Singleton.

I have this scenario: 3 clases, A uses B wich uses C. A -> B -> C

I have an instance into A (with its own member values) and want to use the same instance (not create a new one nor use a singleton) on class C without pass my instance throught B.

Is this possible?? If so how can i achieve this? Thank you in advance!

Lben
  • 83
  • 1
  • 12
  • Check this out:- http://stackoverflow.com/questions/2856004/how-to-inject-into-existing-object-hierarchy-using-guice – Rahul Tripathi Aug 25 '13 at 19:32
  • Mmmm i think he ask for inject NEW instances into an existing hierarchy and i am trying to inject an EXISTING instance. Thats what i see, hope i am not wrong. Besides the first answer suggest the visitor pattern and i want to use GIN. The second answer uses an example without dependency carrying, justo A and B.. No C. – Lben Aug 25 '13 at 20:07
  • Not sure you can get it much better than this way using child injectors: http://stackoverflow.com/questions/16316719/guice-assisted-injection-deeper-down-the-dependency-hierarchy/16331859#16331859 – Jeff Bowman Aug 26 '13 at 06:28

0 Answers0