[webbeans-dev] Re: CreationalContext

Scott Ferguson ferg at caucho.com
Thu Jan 8 13:35:16 EST 2009


On Jan 8, 2009, at 10:03 AM, Gavin King wrote:

> Folks, I would like to go ahead and write up this change, unless  
> anyone objects.
>
> It's a hole that needs fixing.

Is there a need for a separate Contextual<T> or is it essentially  
Bean<T>?  I mean, it's fine, but I don't understand how the extra  
interface helps.

(I'd prefer CreationContext, but that's a very minor preference.)

Also, doesn't InjectionPoint include the <type,bindings> for  
getInstanceToInject?  How do the extra type, bindings parameters  
interact with the InjectionPoint values?

In other words, isn't it sufficient to define the following?

class Manager {
   Object getInstanceToInject(CreationContext cxt, InjectionPoint ip)
}

-- Scott

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




More information about the weld-dev mailing list