[webbeans-dev] Re: Bean.getInjectionPoints()

Gavin King gavin at hibernate.org
Fri Jan 2 00:19:20 EST 2009


On Fri, Jan 2, 2009 at 3:42 PM, Gavin King <gavin at hibernate.org> wrote:

> Actually I think there is a better way to solve the problem, but I
> need to talk it over with Pete.

The alternate solution is something like:

   interface CreationalContext {
       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