Using Guice with circular dependencies

Posted by Yury Litvinov on Stack Overflow See other posts from Stack Overflow or by Yury Litvinov
Published on 2009-09-26T18:15:17Z Indexed on 2010/05/25 21:21 UTC
Read the original article Hit count: 267

Filed under:
|

Consider this simple example.

Class A {
   B b;
   A() {
       this.b = new B(this);
   }
}

In this example instance A knows about instance B, and instance B knows about instance A.

My question is: how to instantiate instance A with Guice, i.e. how to make Guice take care of this complex circle dependencies?

© Stack Overflow or respective owner

Related posts about dependency-injection

Related posts about guice