[weld-dev] Circular dependencies between dependent bean constructors

Marius Bogoevici marius.bogoevici at gmail.com
Sun Apr 11 01:49:14 EDT 2010


On 2010-04-11, at 1:08 AM, Gavin King wrote:

> On Sat, Apr 10, 2010 at 11:18 PM, Marius Bogoevici
> <marius.bogoevici at gmail.com> wrote:
>> 
>> 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.
> 
> Well, exactly. I mean, that's obvious from the definition of an
> @Dependent object, right?
> 
> I mean, I don't quite follow what the source of doubt here is. Section
> 6.4 is *very* explicit on this.

Yeah, it's not like the definition is ambiguous, but it's still good to have it summed up, I suppose -  especially since it's relatively easy to create such a use case (albeit inadvertently). 

Incidentally, in the preamble of chapter 5 is said that : "The container is not required to support circular chains of dependencies where every bean participating in the chain has a pseudo-scope."

So the question would be what happens in the case of @Dependent - it seems the spec should require a deployment error right away. Otherwise, implementors may choose to 'fix' this in a way that would violate the @Dependent definition. Also, it would be good to do the same if other pseudo-scopes are affected.

> 
> 
> -- 
> Gavin King
> gavin.king at gmail.com
> http://in.relation.to/Bloggers/Gavin
> http://hibernate.org
> http://seamframework.org




More information about the weld-dev mailing list