openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1429694 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation: AbstractBeanCreator.java AbstractInjecionTargetBeanCreator.java
Date Mon, 07 Jan 2013 07:40:25 GMT
Author: arne
Date: Mon Jan  7 07:40:24 2013
New Revision: 1429694

URL: http://svn.apache.org/viewvc?rev=1429694&view=rev
Log:
OWB-745: Delayed setting of injection targets

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java?rev=1429694&r1=1429693&r2=1429694&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
Mon Jan  7 07:40:24 2013
@@ -101,6 +101,11 @@ public abstract class AbstractBeanCreato
         this.webBeansContext = bean.getWebBeansContext();
     }
 
+    public Class<? extends Annotation> getScope()
+    {
+        return scope;
+    }
+
     /**
      * {@inheritDoc}
      */

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java?rev=1429694&r1=1429693&r2=1429694&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java
Mon Jan  7 07:40:24 2013
@@ -38,6 +38,7 @@ import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.Specializes;
 import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMember;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
 import javax.enterprise.inject.spi.AnnotatedType;
@@ -73,6 +74,7 @@ public abstract class AbstractInjecionTa
 {    
     
     private WebBeansContext webBeansContext;
+    private Set<AnnotatedMember<? super T>> injectionPoints = new HashSet<AnnotatedMember<?
super T>>();
 
     /**
      * Creates a new instance.
@@ -217,10 +219,10 @@ public abstract class AbstractInjecionTa
         {
             if(Modifier.isPublic(annotatedField.getJavaMember().getModifiers()) &&
!annotatedField.isStatic())
             {
-                if(webBeansContext.getBeanManagerImpl().isNormalScope(getBean().getScope()))
+                if(webBeansContext.getBeanManagerImpl().isNormalScope(getScope()))
                 {
                     throw new WebBeansConfigurationException("If bean has a public field,
bean scope must be defined as @Scope. Bean is : "
-                            + getBean().toString());
+                            + getBeanType().getName());
                 }
             }                
             
@@ -238,7 +240,7 @@ public abstract class AbstractInjecionTa
             Annotation[] anns = AnnotationUtil.asArray(annotatedField.getAnnotations());
             if(Modifier.isPublic(field.getModifiers()))
             {
-                if(!getBean().getScope().equals(Dependent.class))
+                if(!getScope().equals(Dependent.class))
                 {
                     throw new WebBeansConfigurationException("Error in annotated field :
" + annotatedField
                                                     +" while definining injected field. If
bean has a public modifier injection point, bean scope must be defined as @Dependent");
@@ -322,7 +324,7 @@ public abstract class AbstractInjecionTa
         
         }
 
-        AnnotationManager annotationManager = getBean().getWebBeansContext().getAnnotationManager();
+        AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
 
         List<AnnotatedParameter<T>> annotatedParameters = annotatedMethod.getParameters();
         for (AnnotatedParameter<T> annotatedParameter : annotatedParameters)
@@ -364,7 +366,7 @@ public abstract class AbstractInjecionTa
             if(found)
             {
                 checkObserverMethodConditions((AnnotatedMethod<T>) annotatedMethod,
annotatedMethod.getDeclaringType().getJavaClass());
-                if (getBean().getScope().equals(Dependent.class))
+                if (getScope().equals(Dependent.class))
                 {
                     //Check Reception
                      AnnotationUtil.getAnnotatedMethodFirstParameterWithAnnotation(annotatedMethod,
Observes.class);
@@ -373,7 +375,7 @@ public abstract class AbstractInjecionTa
                      Reception reception = observes.notifyObserver();
                      if(reception.equals(Reception.IF_EXISTS))
                      {
-                         throw new WebBeansConfigurationException("Dependent Bean : " + getBean()
+ " can not define observer method with @Receiver = IF_EXIST");
+                         throw new WebBeansConfigurationException("Dependent Bean : " + getBeanType()
+ " can not define observer method with @Receiver = IF_EXIST");
                      }
                 }
                 
@@ -460,7 +462,7 @@ public abstract class AbstractInjecionTa
                     //WebBeansUtil.checkForValidResources(annotatedField.getDeclaringType().getJavaClass(),
field.getType(), field.getName(), anns);
                     if(!Modifier.isStatic(field.getModifiers()))
                     {
-                        ResourceReference<T, Annotation> resourceRef = new ResourceReference<T,
Annotation>(getBean().getBeanClass(), field.getName(),
+                        ResourceReference<T, Annotation> resourceRef = new ResourceReference<T,
Annotation>(getBeanType(), field.getName(),
                                                                                         
                   (Class<T>)field.getType(), resourceAnnotation);
                         
                         //Can not define EL name
@@ -623,7 +625,19 @@ public abstract class AbstractInjecionTa
      */
     public AbstractInjectionTargetBean<T> getBean()
     {
-        return (AbstractInjectionTargetBean<T>)super.getBean();
+        AbstractInjectionTargetBean<T> bean = (AbstractInjectionTargetBean<T>)super.getBean();
+        for (AnnotatedMember<? super T> member : injectionPoints)
+        {
+            if (member instanceof AnnotatedField)
+            {
+                addFieldInjectionPointMetaData((AnnotatedField<?>) member);
+            }
+            else if (member instanceof AnnotatedMethod)
+            {
+                addMethodInjectionPointMetaData((AnnotatedMethod<?>) member);
+            }
+        }
+        return bean;
     }
 
     protected AnnotatedType<T> getAnnotated()



Mime
View raw message