[jboss-user] [JBoss Microcontainer Development] New message: "Re: Web beans on top of Microcontainer deployment order"

Kabir Khan do-not-reply at jboss.com
Wed Feb 24 09:56:31 EST 2010


User development,

A new message was posted in the thread "Web beans on top of Microcontainer deployment order":

http://community.jboss.org/message/528213#528213

Author  : Kabir Khan
Profile : http://community.jboss.org/people/kabir.khan@jboss.com

Message:
--------------------------------------------------------------
I have updated the jsr330 branch and will merge to trunk once I have a added a few more tests. The kernel now supports the JSR 330 usage of @javax.inject.Inject, e.g.:
 
public class SomeBean
{
   @Inject @SomeQualifier Thing t;
 
   @Inject 
   public SomeBean(@SomeQualifier Thing t){}
 
   @Inject
   public void setThingA(@SomeQualifier Thing t){}
 
   @Inject @SomeQualifier
   public void setThingB(Thing t){}
 
   @Inject
   public void installMethod(@SomeQualifier Thing t, @OtherQualifier Thing t2){}
 
}

 
If we have the following MC bean
public class MyBean{
 
   @Inject Thing t;
 
   @Weld @Inject Other o;
 
}

+t+ will be injected from the MC using contextual injection, while +o+ will be injected from Weld. This is done by maintaining a registry of annotations that should be ignored by the @Inject annotation plugins, so if the member also has one of those annotations (e.g. @Weld) we don't create the standard MC injection value metadata for it.
 
When creating the weld injection we create a weld AnnotatedType for the bean, for which there is a decorator that looks at the MDR metadata for the bean. I modified the getAnnotations(), isAnnotationPresent() and getAnnotation() methods to strip out the @Inject unless @Weld is also present, so that weld does not try to inject into those members.
 
To make an MC bean injectable into Weld it needs the @WeldEnabled annotation, e.g.:
If we have the following MC bean
@WeldEnabled
public class McBeanForWeld{
}


--------------------------------------------------------------

To reply to this message visit the message page: http://community.jboss.org/message/528213#528213




More information about the jboss-user mailing list