[webbeans-dev] Re: CreationalContext

Gavin King gavin at hibernate.org
Fri Jan 9 05:49:11 EST 2009


Hrm, after further thought I'm not sure this is necessary.

* for objects with normal scope types, you can just inject proxies, no
need to recurse
* dependent objects are unshared, so they don't get added to CreationalContext

So what cases, precisely, were you having problems with, Scott?

I guess I can that it might be useful for pseudo-scopes other than
@Dependent, or possibly as a performance optimization...

On Fri, Jan 9, 2009 at 5:03 AM, Gavin King <gavin at hibernate.org> wrote:
> Folks, I would like to go ahead and write up this change, unless anyone objects.
>
> It's a hole that needs fixing.
>
> On Fri, Jan 2, 2009 at 4:19 PM, Gavin King <gavin at hibernate.org> wrote:
>
>> The alternate solution is something like:
>>
>>   interface CreationalContext {
>>       <X> void add(Bean<X> bean, X instance); //registers an "incomplete" instance
>>   }
>>
>>   interface Contextual<T> {
>>       public abstract T create(CreationalContext ctx);
>>       ...
>>   }
>>
>>   interface Context {
>>       public <T> T get(Contextual<T> bean); //get any existing instance
>>       public <T> T get(Contextual<T> bean, CreationalContext ctx);
>>                                                                      //get or create an instance
>>
>>       public Class<? extends Annotation> getScopeType();
>>       boolean isActive();
>>   }
>>
>>   interface Manager {
>>       Object getInstanceToInject(CreationalContext ctx,
>>                             InjectionPoint ij, Type type, Annotation... bindings);
>>       ...
>>   }
>>
>> And getInstanceToInject() would be smart enough to return any object
>> that had already been registered with the CreationalContext.
>>
>> Note that this solution addresses the problem of circular references,
>> and also fixes a hole in how the Manager knows about the InjectionPoint.
>
>
> --
> Gavin King
> gavin.king at gmail.com
> http://in.relation.to/Bloggers/Gavin
> http://hibernate.org
> http://seamframework.org
>



-- 
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