[weld-dev] Circular dependencies between dependent bean constructors

Marius Bogoevici marius.bogoevici at gmail.com
Sun Apr 11 00:18:48 EDT 2010


On 2010-04-11, at 12:07 AM, Gavin King wrote:

> It's the nature of @Dependent scope that two injection points never
> refer to the same instance, and that circularities are therefore an
> impossibility.

Gavin, could you clarify that? From reading your comment, it seems like this use case implies unbound recursion: Foo injects Bar which in turns injects another instance of Foo (which is dependent on the first instance of Bar) which injects another instance of Bar etc. 

Secondly, for enabled @Dependent beans without alternatives, is there a real difference between them and their @New counterparts? 

> 
> On Fri, Apr 9, 2010 at 3:29 AM, Pete Muir <pmuir at redhat.com> wrote:
>> Further, Stuart and I are wondering if "(Beans with scope @Dependent never have circular dependencies.)" from 5.4 means that dependent beans are not allowed to have circular dependencies (definition error) or whether it means that they just don't have circular deps (and that the container must break the circularity.
>> 
>> On 9 Apr 2010, at 09:06, Pete Muir wrote:
>> 
>>> class Foo {
>>> 
>>>   @Inject
>>>   Foo (Bar bar) {}
>>> }
>>> 
>>> class Bar {
>>> 
>>>   @Inject
>>>   Bar (Foo foo) {}
>>> 
>>> }
>>> 
>>> The spec implies that this circularity is breakable without a proxy, but I never saw a good way to do it.
>>> 
>>> Any ideas?
>>> 
>>> This relates to https://jira.jboss.org/jira/browse/WELD-479 which I don't believe is the intent of the spec.
>>> _______________________________________________
>>> weld-dev mailing list
>>> weld-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/weld-dev
>> 
>> 
>> _______________________________________________
>> weld-dev mailing list
>> weld-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/weld-dev
>> 
> 
> 
> 
> -- 
> Gavin King
> gavin.king at gmail.com
> http://in.relation.to/Bloggers/Gavin
> http://hibernate.org
> http://seamframework.org
> 
> _______________________________________________
> weld-dev mailing list
> weld-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev




More information about the weld-dev mailing list