[webbeans-commits] Webbeans SVN: r3261 - in ri/trunk/impl/src/main/java/org/jboss/webbeans: bean and 1 other directory.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Sun Jul 26 17:23:34 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-07-26 17:23:33 -0400 (Sun, 26 Jul 2009)
New Revision: 3261

Modified:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
Log:
move ip validation logic to validator to apply to all beans

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java	2009-07-26 20:02:03 UTC (rev 3260)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java	2009-07-26 21:23:33 UTC (rev 3261)
@@ -117,12 +117,27 @@
 
    }
    
+   /**
+    * Validate an injection point
+    * 
+    * @param ij the injection point to validate
+    * @param declaringBean the bean into which the injectionPoint has been injected, if null, certain validations aren't available
+    * @param beanManager
+    */
    public void validateInjectionPoint(InjectionPoint ij, BeanManagerImpl beanManager)
    {
       if (ij.getAnnotated().getAnnotation(New.class) != null && ij.getBindings().size() > 1)
       {
          throw new DefinitionException("The injection point " + ij + " is annotated with @New which cannot be combined with other binding types");
       }
+      if (!Dependent.class.equals(ij.getBean().getScopeType()) && ij.getType().equals(InjectionPoint.class))
+      {
+         throw new DefinitionException("Cannot inject an InjectionPoint into a non @Dependent scoped bean " + ij); 
+      }
+      if (ij.getType() instanceof TypeVariable<?>)
+      {
+         throw new DefinitionException("Cannot declare an injection point with a type variable " + ij);
+      }
       if (ij.getType() instanceof ParameterizedType)
       {
          ParameterizedType parameterizedType = (ParameterizedType) ij.getType();

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java	2009-07-26 20:02:03 UTC (rev 3260)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java	2009-07-26 21:23:33 UTC (rev 3261)
@@ -18,7 +18,6 @@
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
@@ -33,7 +32,6 @@
 import javax.enterprise.inject.Specializes;
 import javax.enterprise.inject.deployment.Standard;
 import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.stereotype.Stereotype;
 
 import org.jboss.webbeans.BeanManagerImpl;
@@ -159,7 +157,6 @@
       initSerializable();
       initProxyable();
       initInjectionPoints();
-      checkInjectionPoints();
       initDecorates();
       checkDecorates();
    }
@@ -296,23 +293,6 @@
       }
       return true;
    }
-   
-   protected boolean checkInjectionPoints()
-   {
-      // TODO Merge serializable check in here
-      for (WBInjectionPoint<?, ?> injectionPoint : getAnnotatedInjectionPoints())
-      {
-         if (!Dependent.class.equals(getScopeType()) && injectionPoint.getType().equals(InjectionPoint.class))
-         {
-            throw new DefinitionException("Cannot inject an InjectionPoint into a non @Dependent scoped bean " + injectionPoint); 
-         }
-         if (injectionPoint.getType() instanceof TypeVariable<?>)
-         {
-            throw new DefinitionException("Cannot declare an injection point with a type variable " + injectionPoint);
-         }
-      }
-      return true;
-   }
 
    /**
     * Initializes the scope type




More information about the weld-commits mailing list