[webbeans-commits] Webbeans SVN: r34 - ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Tue Jul 1 13:28:51 EDT 2008


Author: pete.muir at jboss.org
Date: 2008-07-01 13:28:51 -0400 (Tue, 01 Jul 2008)
New Revision: 34

Modified:
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ConstructorMetaModel.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/InjectedParameterMetaModel.java
Log:
Tests and fixes for chapter 3.1, no support for @Specializes yet

Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java	2008-07-01 17:25:14 UTC (rev 33)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java	2008-07-01 17:28:51 UTC (rev 34)
@@ -1,6 +1,7 @@
 package org.jboss.webbeans;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.util.List;
 import java.util.Map;
@@ -345,9 +346,9 @@
       {
          if (ComponentType.SIMPLE.equals(componentType))
          {
-            name = Strings.decapitalize(type.getName());
+            name = Strings.decapitalize(type.getSimpleName());
          }
-         log.finest("Default name is TODO" );
+         log.finest("Default name of " + type + " is " + name );
       }
       return name;
    }
@@ -408,6 +409,14 @@
       return scopeType;
    }
    
+   public ConstructorMetaModel<T> getConstructor()
+   {
+      return constructor;
+   }
    
+   public ComponentType getComponentType()
+   {
+      return componentType;
+   }
 
 }

Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ConstructorMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ConstructorMetaModel.java	2008-07-01 17:25:14 UTC (rev 33)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ConstructorMetaModel.java	2008-07-01 17:28:51 UTC (rev 34)
@@ -3,6 +3,7 @@
 import java.lang.reflect.Constructor;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.webbeans.BindingType;
@@ -17,6 +18,8 @@
    
 public static final String LOGGER_NAME = "componentConstructor";
    
+   
+
    private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
 
    private Constructor<T> constructor;
@@ -34,9 +37,10 @@
       }
       else if (type.getConstructors().length > 1)
       {
-         
          List<Constructor<T>> initializerAnnotatedConstructors = Reflections.getConstructors(type, Initializer.class);
          List<Constructor<T>> bindingTypeAnnotatedConstructors = Reflections.getConstructorsForMetaAnnotatedParameter(type, BindingType.class);
+         log.finest("Found " + initializerAnnotatedConstructors + " constructors annotated with @Initializer for " + type);
+         log.finest("Found " + bindingTypeAnnotatedConstructors + " with parameters annotated with binding types for " + type);
          if ((initializerAnnotatedConstructors.size() + bindingTypeAnnotatedConstructors.size()) > 1)
          {
             if (initializerAnnotatedConstructors.size() > 1)
@@ -68,9 +72,14 @@
       else if (type.getConstructors().length == 0)
       {      
          this.constructor = (Constructor<T>) Reflections.getConstructor(type);
-         log.finest("No constructor defined, using implicit no arguement constructor");
+         log.finest("No constructor defined, using implicit no arguement constructor for " + type);
       }
       
+      if (this.constructor == null)
+      {
+         throw new RuntimeException("Cannot determine constructor to use for " + type);
+      }
+      
       for (int i = 0; i < constructor.getParameterTypes().length; i++)
       {
          if (constructor.getParameterAnnotations()[i].length > 0)
@@ -85,10 +94,7 @@
          }
       }
       log.finest("Initialized metadata for " + constructor + " with injectable parameters " + injectedParameters);
-      if (this.constructor == null)
-      {
-         throw new RuntimeException("Cannot determine constructor to use");
-      }
+      
    }
    
    public Constructor<T> getConstructor()

Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/InjectedParameterMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/InjectedParameterMetaModel.java	2008-07-01 17:25:14 UTC (rev 33)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/InjectedParameterMetaModel.java	2008-07-01 17:28:51 UTC (rev 34)
@@ -2,9 +2,13 @@
 
 import java.lang.annotation.Annotation;
 
+import org.jboss.webbeans.bindings.CurrentBinding;
+
 public class InjectedParameterMetaModel extends AbstractInjectedThingMetaModel
 {
    
+   private static Annotation[] currentBinding = {new CurrentBinding()};
+   
    private Class<?> type;
    
    public InjectedParameterMetaModel(Annotation[] bindingTypes, Class<?> type)
@@ -15,7 +19,7 @@
 
    public InjectedParameterMetaModel(Class<?> type)
    {
-      super();
+      super(currentBinding);
       this.type = type;
    }
 




More information about the weld-commits mailing list