oghenez / mycila

Automatically exported from code.google.com/p/mycila
0 stars 0 forks source link

JSR-250 @PostConstruct does not help for circular dependencies #34

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
In case of a circular dependency, Guice injects a Proxy instead, that throws an 
Exception upon usage. @PostConstruct methods are called directly after 
injection and therefore do not help doing stuff on creation. Such methods 
should rather be called after Proxies have been resolved.

Original issue reported on code.google.com by oreissig on 27 Sep 2011 at 2:47

GoogleCodeExporter commented 8 years ago

Original comment by mathieu....@gmail.com on 27 Sep 2011 at 3:21

GoogleCodeExporter commented 8 years ago
Hi,

Do you have a working unit test to easily reproduce the case to facilitate the 
fix ? I don't have a lot of time right now...

Thanks a lot,

Mathieu.

Original comment by mathieu....@gmail.com on 29 Sep 2011 at 7:47

GoogleCodeExporter commented 8 years ago
Hi,

during construction of the test case I noticed, that the problem only arises 
when using constructor injection. Field and setter injection pass the test case.

Regards,
Oli

Original comment by oreissig on 30 Sep 2011 at 12:53

Attachments:

GoogleCodeExporter commented 8 years ago
Hi,

Ok I see your case. Actually since you are using circular dependencies, you 
must have to inject Provider<A> Provider<B> instead of A and B directly because 
Guice creates some proxies.

It works by modifying the injections by using providers.

Original comment by mathieu....@gmail.com on 30 Sep 2011 at 1:56