[webbeans-commits] Webbeans SVN: r40 - in ri/trunk/webbeans-impl/src: main/java/org/jboss/webbeans/injectable and 2 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Thu Jul 3 13:42:40 EDT 2008


Author: pete.muir at jboss.org
Date: 2008-07-03 13:42:40 -0400 (Thu, 03 Jul 2008)
New Revision: 40

Added:
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ComponentConstructor.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Element.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/InjectableMethod.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Parameter.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/SimpleConstructor.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Unit.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/AbstractComponentModel.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/EnterpriseComponentModel.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/RemoteComponentModel.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/SimpleComponentModel.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/StereotypeModel.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/stereotypes/
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/EnterpriseComponentModelTest.java
Removed:
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ConstructorMetaModel.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ElementMetaModel.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ParameterMetaModel.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/UnitMetaModel.java
Modified:
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java
Log:
Refactor component model to have different classes for different component types


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-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -7,6 +7,7 @@
 import javax.webbeans.ComponentInstance;
 import javax.webbeans.Container;
 
+import org.jboss.webbeans.model.AbstractComponentModel;
 import org.jboss.webbeans.util.LoggerUtil;
 
 public class ComponentInstanceImpl<T> extends ComponentInstance<T>
@@ -16,9 +17,9 @@
    
    private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
    
-   private ComponentMetaModel<T> componentMetaModel;
+   private AbstractComponentModel<T> componentMetaModel;
 
-   public ComponentInstanceImpl(ComponentMetaModel<T> componentMetaModel)
+   public ComponentInstanceImpl(AbstractComponentModel<T> componentMetaModel)
    {
       this.componentMetaModel = componentMetaModel;
    }

Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java	2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -1,526 +0,0 @@
-package org.jboss.webbeans;
-
-import static org.jboss.webbeans.ComponentMetaModel.ComponentType.*;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import javax.webbeans.ApplicationScoped;
-import javax.webbeans.BindingType;
-import javax.webbeans.Dependent;
-import javax.webbeans.DeploymentType;
-import javax.webbeans.Destroys;
-import javax.webbeans.Initializer;
-import javax.webbeans.Named;
-import javax.webbeans.ScopeType;
-
-import org.jboss.webbeans.bindings.CurrentBinding;
-import org.jboss.webbeans.bindings.DependentBinding;
-import org.jboss.webbeans.bindings.ProductionBinding;
-import org.jboss.webbeans.ejb.EJB;
-import org.jboss.webbeans.ejb.EjbMetaData;
-import org.jboss.webbeans.injectable.ConstructorMetaModel;
-import org.jboss.webbeans.injectable.MethodMetaModel;
-import org.jboss.webbeans.util.AnnotatedItem;
-import org.jboss.webbeans.util.LoggerUtil;
-import org.jboss.webbeans.util.Reflections;
-import org.jboss.webbeans.util.Strings;
-
-/**
- * Web Beans Component meta model
- * 
- * @author Pete Muir
- * 
- */
-public class ComponentMetaModel<T>
-{
-   
-   public enum ComponentType
-   {
-      SIMPLE,
-      ENTERPRISE;
-   }
-   
-   public static final String LOGGER_NAME = "componentMetaModel";
-   
-   private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
-   
-   private Class<? extends T> type;
-   private Set<Annotation> bindingTypes;
-   private Annotation deploymentType;
-   private String name;
-   private Annotation scopeType;
-   private ComponentType componentType;
-   private ConstructorMetaModel<T> constructor;
-   private EjbMetaData<T> ejbMetaData;
-   private MethodMetaModel<?> removeMethod;
-   /**
-    * 
-    * @param annotatedItem Annotations read from java classes
-    * @param xmlAnnotatedItem Annotations read from XML
-    * @param container
-    */
-   @SuppressWarnings("unchecked")
-   public ComponentMetaModel(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
-   {
-      if (annotatedItem == null)
-      {
-         throw new NullPointerException("annotatedItem must not be null. If the component is declared just in XML, pass in an empty annotatedItem");
-      }
-      
-      if (xmlAnnotatedItem == null)
-      {
-         throw new NullPointerException("xmlAnnotatedItem must not be null. If the component is declared just in Java, pass in an empty xmlAnnotatedItem");
-      }
-      
-      this.type = (Class<? extends T>) initType(annotatedItem, xmlAnnotatedItem);
-      log.fine("Building Web Bean component metadata for " +  type);
-      this.ejbMetaData = EJB.getEjbMetaData(type);
-      this.componentType = initComponentType(type, ejbMetaData);
-      checkComponentImplementation(componentType, type);
-      this.constructor = initConstructor(type);
-      MergedComponentStereotypes stereotypes = new MergedComponentStereotypes(annotatedItem, xmlAnnotatedItem, container);
-      this.bindingTypes = initBindingTypes(annotatedItem, xmlAnnotatedItem);
-      this.deploymentType = initDeploymentType(stereotypes, annotatedItem, xmlAnnotatedItem, container);
-      this.scopeType = initScopeType(stereotypes, annotatedItem, xmlAnnotatedItem);
-      this.name = initName(stereotypes, annotatedItem, xmlAnnotatedItem, componentType, type);
-      this.removeMethod = initRemoveMethod(componentType, ejbMetaData, type);
-      checkRequiredTypesImplemented(stereotypes, type);
-      checkScopeAllowed(stereotypes, scopeType, type, componentType, ejbMetaData);
-      // TODO Interceptors
-   }
-   
-   /*
-    * A series of static methods which implement the algorithms defined in the Web Beans spec for component meta data
-    */
-   
-   @SuppressWarnings("unchecked")
-   protected static <T> ConstructorMetaModel<T> initConstructor(Class<? extends T> type)
-   {
-      if (type.getConstructors().length == 1)
-      {
-         Constructor<T> constructor = type.getConstructors()[0];
-         log.finest("Exactly one constructor (" + constructor +") defined, using it as the component constructor for " + type);
-         return new ConstructorMetaModel<T>(constructor);
-      }
-      
-      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)
-            {
-               throw new RuntimeException("Cannot have more than one constructor annotated with @Initializer for " + type);
-            }
-            
-            else if (bindingTypeAnnotatedConstructors.size() > 1)
-            {
-               throw new RuntimeException("Cannot have more than one constructor with binding types specified on constructor parameters for " + type);
-            }
-            else
-            {
-               throw new RuntimeException("Specify a constructor either annotated with @Initializer or with parameters annotated with binding types for " + type);
-            }
-         }
-         else if (initializerAnnotatedConstructors.size() == 1)
-         {
-            Constructor<T> constructor = initializerAnnotatedConstructors.get(0);
-            log.finest("Exactly one constructor (" + constructor +") annotated with @Initializer defined, using it as the component constructor for " + type);
-            return new ConstructorMetaModel<T>(constructor);
-         }
-         else if (bindingTypeAnnotatedConstructors.size() == 1)
-         {
-            Constructor<T> constructor = bindingTypeAnnotatedConstructors.get(0);
-            log.finest("Exactly one constructor (" + constructor +") with parameters annotated with binding types defined, using it as the component constructor for " + type);
-            return new ConstructorMetaModel<T>(constructor);
-         }
-      }
-      
-      if (type.getConstructors().length == 0)
-      {      
-         Constructor<T> constructor = (Constructor<T>) Reflections.getConstructor(type);
-         log.finest("No constructor defined, using implicit no arguement constructor for " + type);
-         return new ConstructorMetaModel<T>(constructor);
-      }
-      
-      throw new RuntimeException("Cannot determine constructor to use for " + type);
-   }
-   
-   protected static <T> MethodMetaModel<?> initRemoveMethod(ComponentType componentType, EjbMetaData<T> ejbMetaData, Class<? extends T> type)
-   {
-      if (componentType.equals(ENTERPRISE) && ejbMetaData.isStateful())
-      {
-         if (ejbMetaData.getRemoveMethods().size() == 1)
-         {
-            return new MethodMetaModel<Object>(ejbMetaData.getRemoveMethods().get(0));
-         }
-         else if (ejbMetaData.getRemoveMethods().size() > 1)
-         {
-            List<Method> possibleRemoveMethods = new ArrayList<Method>();
-            for (Method removeMethod : ejbMetaData.getRemoveMethods())
-            {
-               if (removeMethod.isAnnotationPresent(Destroys.class))
-               {
-                  possibleRemoveMethods.add(removeMethod);
-               }
-            }
-            if (possibleRemoveMethods.size() == 1)
-            {
-               return new MethodMetaModel<Object>(possibleRemoveMethods.get(0)); 
-            }
-            else if (possibleRemoveMethods.size() > 1)
-            {
-               throw new RuntimeException("Multiple remove methods are annotated @Destroys for " + type);
-            }
-            else if (possibleRemoveMethods.size() == 0)
-            {
-               throw new RuntimeException("Multiple remove methods are declared, and none are annotated @Destroys for " + type);
-            }
-         }
-         else if (ejbMetaData.getRemoveMethods().size() == 0)
-         {
-            throw new RuntimeException("Stateful enterprise bean component has no remove methods declared for " + type);
-         }
-      }
-      else
-      {
-         List<Method> destroysMethods = Reflections.getMethods(type, Destroys.class);
-         if (destroysMethods.size() > 0)
-         {
-            throw new RuntimeException("Only stateful enterprise bean components can have methods annotated @Destroys; " + type + " is not a stateful enterprise bean component");
-         }
-      }
-      return null;
-   }
-   
-   protected static <T> ComponentType initComponentType(Class<? extends T> type, EjbMetaData<T> ejbMetaData)
-   {
-      if (ejbMetaData != null && (ejbMetaData.isMessageDriven() || ejbMetaData.isSingleton() || ejbMetaData.isStateful() || ejbMetaData.isStateless()))
-      {
-         log.finest(type + " is an enterprise bean component");
-         return ENTERPRISE;
-      }
-      else
-      {
-         log.finest(type + " is an simple component");
-         return SIMPLE;
-      }
-   }
-   
-   protected static void checkComponentImplementation(ComponentType componentType, Class<?> type)
-   {
-      switch (componentType)
-      {
-      case SIMPLE:
-         checkSimpleComponentImplementation(type);
-         break;
-      }
-   }
-   
-   protected static void checkSimpleComponentImplementation(Class<?> type)
-   {
-      if (Reflections.isAbstract(type))
-      {
-         throw new RuntimeException("Web Bean implementation class " + type + " cannot be declared abstract");
-      }
-   }
-   
-   protected static boolean isDeclaredFinal(Class<?> type)
-   {
-      if (Reflections.isFinal(type))
-      {
-         return true;
-      }
-      for (Method method : type.getDeclaredMethods())
-      {
-         if (Reflections.isFinal(method))
-         {
-            return true;
-         }
-      }
-      return false;
-   }
-
-   @SuppressWarnings("unchecked")
-   protected static Class<?> initType(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
-   {
-      if (annotatedItem.getAnnotatedClass() != null && xmlAnnotatedItem.getAnnotatedClass() != null && !annotatedItem.getAnnotatedClass().equals(xmlAnnotatedItem.getAnnotatedClass()))
-      {
-         throw new IllegalArgumentException("Cannot build a component which specifies different classes in XML and Java");
-      }
-      else if (xmlAnnotatedItem.getAnnotatedClass() != null)
-      {
-         log.finest("Component type specified in XML");
-         return xmlAnnotatedItem.getAnnotatedClass();
-      }
-      else if (annotatedItem.getAnnotatedClass() != null)
-      {
-         log.finest("Component type specified in Java");
-         return annotatedItem.getAnnotatedClass();
-      }
-      else
-      {
-         throw new IllegalArgumentException("Cannot build a component which doesn't specify a type");
-      }
-   }
-   
-   /**
-    * Check that the scope type is allowed by the stereotypes on the component and the component type
-    * @param type 
-    */
-   protected static void checkScopeAllowed(MergedComponentStereotypes stereotypes, Annotation scopeType, Class<?> type, ComponentType componentType, EjbMetaData ejbMetaData)
-   {
-      log.finest("Checking if " + scopeType + " is allowed for " + type);
-      if (stereotypes.getSupportedScopes().size() > 0)
-      {
-         if (!stereotypes.getSupportedScopes().contains(scopeType.annotationType()))
-         {
-            throw new RuntimeException("Scope " + scopeType + " is not an allowed by the stereotype for " + type);
-         }
-      }
-      if (isDeclaredFinal(type) && !scopeType.annotationType().equals(Dependent.class))
-      {
-         throw new RuntimeException("Scope " + scopeType + " is not allowed as the class is declared final or has methods declared final for " + type + ". Only @Dependent is allowed for final components");
-      }
-      if (componentType.equals(ComponentType.ENTERPRISE) && ejbMetaData.isStateless() && !scopeType.annotationType().equals(Dependent.class))
-      {
-         throw new RuntimeException("Scope " + scopeType + " is not allowed on stateless enterpise bean components for " + type + ". Only @Dependent is allowed on stateless enterprise bean components");
-      }
-      if (componentType.equals(ComponentType.ENTERPRISE) && ejbMetaData.isSingleton() && (!scopeType.annotationType().equals(Dependent.class) || !scopeType.annotationType().equals(ApplicationScoped.class)))
-      {
-         throw new RuntimeException("Scope " + scopeType + " is not allowed on singleton enterpise bean components for " + type + ". Only @Dependent or @ApplicationScoped is allowed on singleton enterprise bean components");
-      }
-   }
-   
-   /**
-    * Check that the types required by the stereotypes on the component are implemented
-    */
-   protected static void checkRequiredTypesImplemented(MergedComponentStereotypes stereotypes, Class<?> type)
-   {
-      for (Class<?> requiredType : stereotypes.getRequiredTypes())
-      {
-         log.finest("Checking if required type " + requiredType + " is implemented");
-         if (!requiredType.isAssignableFrom(type))
-         {
-            throw new RuntimeException("Required type " + requiredType + " isn't implement on " + type);
-         }
-      }
-   }
-
-   /**
-    * Return the scope of the component
-    */
-   protected static Annotation initScopeType(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
-   {
-      Set<Annotation> xmlScopes = xmlAnnotatedItem.getAnnotations(ScopeType.class);
-      if (xmlScopes.size() > 1)
-      {
-         throw new RuntimeException("At most one scope may be specified in XML");
-      }
-      
-      if (xmlScopes.size() == 1)
-      {
-         Annotation scope = xmlScopes.iterator().next();
-         log.finest("Scope " + scope + " specified in XML");
-         return scope;
-      }
-      
-      Set<Annotation> scopes = annotatedItem.getAnnotations(ScopeType.class);
-      if (scopes.size() > 1)
-      {
-         throw new RuntimeException("At most one scope may be specified");
-      }
-      
-      if (scopes.size() == 1)
-      {
-         Annotation scope = scopes.iterator().next();
-         log.finest("Scope " + scope + " specified b annotation");
-         return scope;
-      }
-      
-      if (stereotypes.getPossibleScopeTypes().size() == 1)
-      {
-         Annotation scope = stereotypes.getPossibleScopeTypes().iterator().next();
-         log.finest("Scope " + scope + " specified by stereotype");
-         return scope;
-      }
-      else if (stereotypes.getPossibleScopeTypes().size() > 1)
-      {
-         throw new RuntimeException("All stereotypes must specify the same scope OR a scope must be specified on the component");
-      }
-      
-      log.finest("Using default @Dependent scope");
-      return new DependentBinding();
-   }
-
-   protected static Annotation initDeploymentType(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
-   {
-      Set<Annotation> xmlDeploymentTypes = xmlAnnotatedItem.getAnnotations(DeploymentType.class);
-      
-      if (xmlDeploymentTypes.size() > 1)
-      {
-         throw new RuntimeException("At most one deployment type may be specified (" + xmlDeploymentTypes + " are specified)");
-      }
-      
-      if (xmlDeploymentTypes.size() == 1)
-      {
-         Annotation deploymentType = xmlDeploymentTypes.iterator().next(); 
-         log.finest("Deployment type " + deploymentType + " specified in XML");
-         return deploymentType;
-      }
-      
-      if (xmlAnnotatedItem.getAnnotatedClass() == null)
-      {
-      
-         Set<Annotation> deploymentTypes = annotatedItem.getAnnotations(DeploymentType.class);
-         
-         if (deploymentTypes.size() > 1)
-         {
-            throw new RuntimeException("At most one deployment type may be specified (" + deploymentTypes + " are specified)");
-         }
-         if (deploymentTypes.size() == 1)
-         {
-            Annotation deploymentType = deploymentTypes.iterator().next();
-            log.finest("Deployment type " + deploymentType + " specified by annotation");
-            return deploymentType;
-         }
-      }
-      
-      if (stereotypes.getPossibleDeploymentTypes().size() > 0)
-      {
-         Annotation deploymentType = getDeploymentType(container.getEnabledDeploymentTypes(), stereotypes.getPossibleDeploymentTypes());
-         log.finest("Deployment type " + deploymentType + " specified by stereotype");
-         return deploymentType;
-      }
-      
-      if (xmlAnnotatedItem.getAnnotatedClass() != null)
-      {
-         log.finest("Using default @Production deployment type");
-         return new ProductionBinding();
-      }
-      throw new RuntimeException("All Java annotated classes have a deployment type");
-   }
-
-   protected static Set<Annotation> initBindingTypes(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
-   {
-      Set<Annotation> xmlBindingTypes = xmlAnnotatedItem.getAnnotations(BindingType.class);
-      if (xmlBindingTypes.size() > 0)
-      {
-         // TODO support producer expression default binding type
-         log.finest("Using binding types " + xmlBindingTypes + " specified in XML");
-         return xmlBindingTypes;
-      }
-      
-      Set<Annotation> bindingTypes = annotatedItem.getAnnotations(BindingType.class);
-      
-      if (bindingTypes.size() == 0)
-      {
-         log.finest("Adding default @Current binding type");
-         bindingTypes.add(new CurrentBinding());
-      }
-      else
-      {
-         log.finest("Using binding types " + bindingTypes + " specified by annotations");
-      }
-      return bindingTypes;
-   }
-
-   protected static String initName(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ComponentType componentType, Class<?> type)
-   {
-      boolean componentNameDefaulted = false;
-      String name = null;
-      if (xmlAnnotatedItem.isAnnotationPresent(Named.class))
-      {
-         name = xmlAnnotatedItem.getAnnotation(Named.class).value();
-         if ("".equals(name))
-         {
-            log.finest("Using default name (specified in XML)");
-            componentNameDefaulted = true;
-         }
-         else
-         {
-            log.finest("Using name " + name + " specified in XML");
-         }
-      }
-      else if (annotatedItem.isAnnotationPresent(Named.class))
-      {
-         name = annotatedItem.getAnnotation(Named.class).value();
-         if ("".equals(name))
-         {
-            log.finest("Using default name (specified by annotations)");
-            componentNameDefaulted = true;
-         }
-         else
-         {
-            log.finest("Using name " + name + " specified in XML");
-         }
-      }
-      if ("".equals(name) && (componentNameDefaulted || stereotypes.isComponentNameDefaulted()))
-      {
-         if (ComponentType.SIMPLE.equals(componentType) || ComponentType.ENTERPRISE.equals(componentType))
-         {
-            name = Strings.decapitalize(type.getSimpleName());
-         }
-         log.finest("Default name of " + type + " is " + name );
-      }
-      return name;
-   }
-   
-   public static Annotation getDeploymentType(List<Annotation> enabledDeploymentTypes, Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes)
-   {
-      for (int i = (enabledDeploymentTypes.size() - 1); i > 0; i--)
-      {
-         if (possibleDeploymentTypes.containsKey((enabledDeploymentTypes.get(i).annotationType())))
-         {
-            return enabledDeploymentTypes.get(i); 
-         }
-      }
-      return null;
-   }
-
-   public Set<Annotation> getBindingTypes()
-   {
-      return bindingTypes;
-   }
-
-   public Annotation getDeploymentType()
-   {
-      return deploymentType;
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   public Annotation getScopeType()
-   {
-      return scopeType;
-   }
-   
-   public ConstructorMetaModel<T> getConstructor()
-   {
-      return constructor;
-   }
-   
-   public ComponentType getComponentType()
-   {
-      return componentType;
-   }
-   
-   public MethodMetaModel<?> getRemoveMethod()
-   {
-      return removeMethod;
-   }
-
-}

Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java	2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -1,89 +0,0 @@
-package org.jboss.webbeans;
-
-import java.lang.annotation.Annotation;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.webbeans.Stereotype;
-
-import org.jboss.webbeans.util.AnnotatedItem;
-
-/**
- * Meta model for the merged stereotype for a component
- * @author pmuir
- *
- */
-public class MergedComponentStereotypes
-{
-
-   private Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes;
-   private Set<Annotation> possibleScopeTypes;
-   private boolean componentNameDefaulted;
-   private Set<Class<?>> requiredTypes;
-   private Set<Class<? extends Annotation>> supportedScopes;
-   
-   public MergedComponentStereotypes(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
-   {
-      possibleDeploymentTypes = new HashMap<Class<? extends Annotation>, Annotation>();
-      possibleScopeTypes = new HashSet<Annotation>();
-      requiredTypes = new HashSet<Class<?>>();
-      supportedScopes = new HashSet<Class<? extends Annotation>>();
-      
-      // All stereotypes declared in java and xml are merged
-      Set<Annotation> stereotypeAnnotations = new HashSet<Annotation>();
-      stereotypeAnnotations.addAll(annotatedItem.getAnnotations(Stereotype.class));
-      stereotypeAnnotations.addAll(xmlAnnotatedItem.getAnnotations(Stereotype.class));
-      
-      for (Annotation stereotypeAnnotation : stereotypeAnnotations)
-      {
-         // Retrieve and merge all metadata from stereotypes
-         StereotypeMetaModel stereotype = container.getStereotypeManager().getStereotype(stereotypeAnnotation.annotationType());
-         if (stereotype == null)
-         {
-            throw new NullPointerException("Stereotype " + stereotypeAnnotation + " not registered with container");
-         }
-         if (stereotype.getDefaultDeploymentType() != null)
-         {
-            possibleDeploymentTypes.put(stereotype.getDefaultDeploymentType().annotationType(), stereotype.getDefaultDeploymentType());
-         }
-         if (stereotype.getDefaultScopeType() != null)
-         {
-            possibleScopeTypes.add(stereotype.getDefaultScopeType());
-         }
-         requiredTypes.addAll(stereotype.getRequiredTypes());
-         supportedScopes.addAll(stereotype.getSupportedScopes());
-         if (stereotype.isComponentNameDefaulted()) 
-         {
-            componentNameDefaulted = true;
-         }
-      }
-   }
-   
-   public Map<Class<? extends Annotation>, Annotation> getPossibleDeploymentTypes()
-   {
-      return possibleDeploymentTypes;
-   }
-   
-   public Set<Annotation> getPossibleScopeTypes()
-   {
-      return possibleScopeTypes;
-   }
-   
-   public boolean isComponentNameDefaulted()
-   {
-      return componentNameDefaulted;
-   }
-   
-   public Set<Class<?>> getRequiredTypes()
-   {
-      return requiredTypes;
-   }
-   
-   public Set<Class<? extends Annotation>> getSupportedScopes()
-   {
-      return supportedScopes;
-   }
-   
-}

Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java	2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -1,23 +0,0 @@
-package org.jboss.webbeans;
-
-import java.lang.annotation.Annotation;
-import java.util.HashMap;
-import java.util.Map;
-
-public class StereotypeManager
-{
-   
-   // TODO Store these in the application context (when it exists)
-   public static Map<Class<? extends Annotation>, StereotypeMetaModel> stereotypes = new HashMap<Class<? extends Annotation>, StereotypeMetaModel>();
-
-   public void addStereotype(StereotypeMetaModel stereotype)
-   {
-      stereotypes.put(stereotype.getStereotypeClass(), stereotype);
-   }
-   
-   public StereotypeMetaModel getStereotype(Class<? extends Annotation> annotationType)
-   {
-      return stereotypes.get(annotationType);
-   }
-
-}

Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,25 @@
+package org.jboss.webbeans;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.webbeans.model.StereotypeModel;
+
+public class StereotypeManager
+{
+   
+   // TODO Store these in the application context (when it exists)
+   public static Map<Class<? extends Annotation>, StereotypeModel> stereotypes = new HashMap<Class<? extends Annotation>, StereotypeModel>();
+
+   public void addStereotype(StereotypeModel stereotype)
+   {
+      stereotypes.put(stereotype.getStereotypeClass(), stereotype);
+   }
+   
+   public StereotypeModel getStereotype(Class<? extends Annotation> annotationType)
+   {
+      return stereotypes.get(annotationType);
+   }
+
+}

Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java	2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -1,191 +0,0 @@
-package org.jboss.webbeans;
-
-import java.lang.annotation.Annotation;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.webbeans.BindingType;
-import javax.webbeans.DeploymentType;
-import javax.webbeans.InterceptorBindingType;
-import javax.webbeans.Named;
-import javax.webbeans.ScopeType;
-import javax.webbeans.Stereotype;
-
-import org.jboss.webbeans.util.AnnotatedItem;
-
-/**
- * A meta model for a stereotype, allows us to cache a stereotype and to validate it
- * 
- * @author pmuir
- *
- */
-public class StereotypeMetaModel
-{
-   
-   private Class<? extends Annotation> stereotypeClass;
-   private Annotation defaultDeploymentType;
-   private Annotation defaultScopeType;
-   private boolean componentNameDefaulted;
-   private Set<Class<? extends Annotation>> supportedScopes;
-   private Set<Class<?>> requiredTypes;
-   private Set<Annotation> interceptorBindings;
-   
-   @SuppressWarnings("unchecked")
-   public StereotypeMetaModel(AnnotatedItem annotatedClass)
-   {
-      initStereotypeClass(annotatedClass);
-      Stereotype stereotype = annotatedClass.getAnnotation(Stereotype.class);
-      initDefaultDeploymentType(annotatedClass);
-      initDefaultScopeType(annotatedClass);
-      initComponentNameDefaulted(annotatedClass);
-      initSupportedScopes(annotatedClass, stereotype);
-      initRequiredTypes(annotatedClass, stereotype);
-      initInterceptorBindings(annotatedClass);
-      checkBindingTypes(annotatedClass);
-   }
-   
-   private void checkBindingTypes(AnnotatedItem annotatedClass)
-   {
-      Set<Annotation> bindingTypes = annotatedClass.getAnnotations(BindingType.class);
-      if (bindingTypes.size() > 0)
-      {
-         throw new RuntimeException("Cannot declare binding types on a stereotpe");
-      }
-   }
-   
-   @SuppressWarnings("unchecked")
-   private void initStereotypeClass(AnnotatedItem annotatedClass)
-   {
-      if (Annotation.class.isAssignableFrom(annotatedClass.getAnnotatedClass()))
-      {
-         this.stereotypeClass = (Class<? extends Annotation>) annotatedClass.getAnnotatedClass();
-      }
-      else
-      {
-         throw new RuntimeException("@Stereotype can only be applied to an annotation");
-      }
-   }
-
-   private void initInterceptorBindings(AnnotatedItem annotatedClass)
-   {
-      interceptorBindings = annotatedClass.getAnnotations(InterceptorBindingType.class);
-   }
-
-   private void initSupportedScopes(AnnotatedItem annotatedElement, Stereotype stereotype)
-   {
-      this.supportedScopes = new HashSet<Class<? extends Annotation>>();
-      Class<? extends Annotation>[] supportedScopes = stereotype.supportedScopes();
-      if (supportedScopes.length > 0)
-      {
-         this.supportedScopes.addAll(Arrays.asList(supportedScopes));
-      }
-   }
-   
-   private void initRequiredTypes(AnnotatedItem annotatedElement, Stereotype stereotype)
-   {
-      this.requiredTypes = new HashSet<Class<?>>();
-      Class<?>[] requiredTypes = stereotype.requiredTypes();
-      if (requiredTypes.length > 0)
-      {
-         this.requiredTypes.addAll(Arrays.asList(requiredTypes));
-      }
-   }
-
-   private void initComponentNameDefaulted(AnnotatedItem annotatedElement)
-   {
-      if (annotatedElement.isAnnotationPresent(Named.class))
-      {
-         if (!"".equals(annotatedElement.getAnnotation(Named.class).value()))
-         {
-            throw new RuntimeException("Cannot specify a value for a @Named stereotype");
-         }
-         componentNameDefaulted = true;
-      }
-   }
-
-   private void initDefaultScopeType(AnnotatedItem annotatedElement)
-   {
-      Set<Annotation> scopeTypes = annotatedElement.getAnnotations(ScopeType.class);
-      if (scopeTypes.size() > 1)
-      {
-         throw new RuntimeException("At most one scope type may be specified");
-      }
-      else if (scopeTypes.size() == 1)
-      {
-         this.defaultScopeType = scopeTypes.iterator().next();
-      }
-   }
-
-   private void initDefaultDeploymentType(AnnotatedItem annotatedElement)
-   {
-      Set<Annotation> deploymentTypes = annotatedElement.getAnnotations(DeploymentType.class);
-      if (deploymentTypes.size() > 1)
-      {
-         throw new RuntimeException("At most one deployment type may be specified");
-      }
-      else if (deploymentTypes.size() == 1)
-      {
-         this.defaultDeploymentType = deploymentTypes.iterator().next();
-      }
-   }
-   
-   /**
-    * Get the default deployment type the stereotype specifies, or null if none
-    * is specified
-    */
-   public Annotation getDefaultDeploymentType()
-   {
-      return defaultDeploymentType;
-   }
-   
-   /**
-    * Get the default scope type the stereotype specifies, or null if none is
-    * specified
-    */
-   public Annotation getDefaultScopeType()
-   {
-      return defaultScopeType;
-   }
-   
-   /**
-    * Get any interceptor bindings the the stereotype specifies, or an empty set
-    * if none are specified
-    */
-   public Set<Annotation> getInterceptorBindings()
-   {
-      return interceptorBindings;
-   }
-   
-   /**
-    * Returns true if the stereotype specifies the component name should be 
-    * defaulted
-    */
-   public boolean isComponentNameDefaulted()
-   {
-      return componentNameDefaulted;
-   }
-   
-   /**
-    * Returns the scopes this stereotype allows, or an empty set if none are 
-    * specified
-    */
-   public Set<Class<? extends Annotation>> getSupportedScopes()
-   {
-      return supportedScopes;
-   }
-   
-   /**
-    * Returns the types this stereotype requires, or an empty set if none are
-    * specified
-    */
-   public Set<Class<?>> getRequiredTypes()
-   {
-      return requiredTypes;
-   }
-   
-   public Class<? extends Annotation> getStereotypeClass()
-   {
-      return stereotypeClass;
-   }
-}

Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ComponentConstructor.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ComponentConstructor.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ComponentConstructor.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,10 @@
+package org.jboss.webbeans.injectable;
+
+import javax.webbeans.Container;
+
+public interface ComponentConstructor<T>
+{
+
+   public T invoke(Container container);
+   
+}


Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ComponentConstructor.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ConstructorMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ConstructorMetaModel.java	2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ConstructorMetaModel.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -1,45 +0,0 @@
-package org.jboss.webbeans.injectable;
-
-import java.lang.reflect.Constructor;
-import java.util.logging.Logger;
-
-import javax.webbeans.Container;
-
-import org.jboss.webbeans.util.LoggerUtil;
-
-public class ConstructorMetaModel<T> extends UnitMetaModel<T>
-{
-   
-   public static final String LOGGER_NAME = "componentConstructor";
-   
-   private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
-
-   private Constructor<T> constructor;
-   
-   @SuppressWarnings("unchecked")
-   public ConstructorMetaModel(Constructor<T> constructor)
-   {
-      super(constructor.getParameterTypes(), constructor.getParameterAnnotations());
-      this.constructor = constructor;
-      log.finest("Initialized metadata for " + constructor + " with injectable parameters " + getParameters());
-   }
-   
-   public Constructor<T> getConstructor()
-   {
-      return constructor;
-   }
-
-   public T invoke(Container container)
-   {
-      try
-      {
-         log.finest("Creating new instance of " + constructor.getDeclaringClass() + " with injected parameters " + getParameters());
-         return constructor.newInstance(getParameterValues(container));
-      }
-      catch (Exception e) 
-      {
-         throw new RuntimeException("Error instantiating " + constructor.getDeclaringClass(), e);
-      }
-   }
-   
-}

Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Element.java (from rev 38, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ElementMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Element.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Element.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,40 @@
+package org.jboss.webbeans.injectable;
+
+import java.lang.annotation.Annotation;
+
+import javax.webbeans.Container;
+
+public abstract class Element<T>
+{
+   
+   private Annotation[] bindingTypes;
+   
+   public Element(Annotation[] bindingTypes)
+   {
+      this.bindingTypes = bindingTypes;
+   }
+   
+   public Element()
+   {
+      this.bindingTypes = new Annotation[0];
+   }
+
+   public Annotation[] getBindingTypes()
+   {
+      return bindingTypes;
+   }
+   
+   @Override
+   public String toString()
+   {
+      return getType() + " with binding types " + getBindingTypes();
+   }
+
+   public T getValue(Container container)
+   {
+      return container.getInstanceByType(getType(), getBindingTypes());
+   }
+   
+   public abstract Class<? extends T> getType();
+   
+}


Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Element.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ElementMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ElementMetaModel.java	2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ElementMetaModel.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -1,40 +0,0 @@
-package org.jboss.webbeans.injectable;
-
-import java.lang.annotation.Annotation;
-
-import javax.webbeans.Container;
-
-public abstract class ElementMetaModel<T>
-{
-   
-   private Annotation[] bindingTypes;
-   
-   public ElementMetaModel(Annotation[] bindingTypes)
-   {
-      this.bindingTypes = bindingTypes;
-   }
-   
-   public ElementMetaModel()
-   {
-      this.bindingTypes = new Annotation[0];
-   }
-
-   public Annotation[] getBindingTypes()
-   {
-      return bindingTypes;
-   }
-   
-   @Override
-   public String toString()
-   {
-      return getType() + " with binding types " + getBindingTypes();
-   }
-
-   public T getValue(Container container)
-   {
-      return container.getInstanceByType(getType(), getBindingTypes());
-   }
-   
-   public abstract Class<? extends T> getType();
-   
-}

Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/InjectableMethod.java (from rev 39, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/InjectableMethod.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/InjectableMethod.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,36 @@
+package org.jboss.webbeans.injectable;
+
+import javax.webbeans.Container;
+
+// TODO Name this class better
+public class InjectableMethod<T> extends Unit<T>
+{
+
+   private java.lang.reflect.Method method;
+   
+   public InjectableMethod(java.lang.reflect.Method method)
+   {
+      super(method.getParameterTypes(), method.getParameterAnnotations());
+      this.method = method;
+   }
+
+   @SuppressWarnings("unchecked")
+   public T invoke(Container container, Object instance)
+   {
+      try
+      {
+         return (T) method.invoke(instance, getParameterValues(container));
+      }
+      catch (Exception e) 
+      {
+         throw new RuntimeException("Unable to invoke " + method + " on " + instance, e);
+      }
+   }
+   
+   public java.lang.reflect.Method getMethod()
+   {
+      return method;
+   }
+   
+   
+}


Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/InjectableMethod.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java	2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -1,37 +0,0 @@
-package org.jboss.webbeans.injectable;
-
-import java.lang.reflect.Method;
-
-import javax.webbeans.Container;
-
-public class MethodMetaModel<T> extends UnitMetaModel<T>
-{
-
-   private Method method;
-   
-   public MethodMetaModel(Method method)
-   {
-      super(method.getParameterTypes(), method.getParameterAnnotations());
-      this.method = method;
-   }
-
-   @SuppressWarnings("unchecked")
-   public T invoke(Container container, Object instance)
-   {
-      try
-      {
-         return (T) method.invoke(instance, getParameterValues(container));
-      }
-      catch (Exception e) 
-      {
-         throw new RuntimeException("Unable to invoke " + method + " on " + instance, e);
-      }
-   }
-   
-   public Method getMethod()
-   {
-      return method;
-   }
-   
-   
-}

Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Parameter.java (from rev 38, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ParameterMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Parameter.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Parameter.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,33 @@
+package org.jboss.webbeans.injectable;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.webbeans.bindings.CurrentBinding;
+
+public class Parameter<T> extends Element<T>
+{
+   
+   private static Annotation[] currentBinding = {new CurrentBinding()};
+   
+   private Class<? extends T> type;
+   
+   public Parameter(Annotation[] bindingTypes, Class<? extends T> type)
+   {
+      super(bindingTypes);
+      this.type = type;
+   }
+
+   public Parameter(Class<? extends T> type)
+   {
+      super(currentBinding);
+      this.type = type;
+   }
+
+   public Class<? extends T> getType()
+   {
+      return type;
+   }
+   
+   
+   
+}


Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Parameter.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ParameterMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ParameterMetaModel.java	2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ParameterMetaModel.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -1,33 +0,0 @@
-package org.jboss.webbeans.injectable;
-
-import java.lang.annotation.Annotation;
-
-import org.jboss.webbeans.bindings.CurrentBinding;
-
-public class ParameterMetaModel<T> extends ElementMetaModel<T>
-{
-   
-   private static Annotation[] currentBinding = {new CurrentBinding()};
-   
-   private Class<? extends T> type;
-   
-   public ParameterMetaModel(Annotation[] bindingTypes, Class<? extends T> type)
-   {
-      super(bindingTypes);
-      this.type = type;
-   }
-
-   public ParameterMetaModel(Class<? extends T> type)
-   {
-      super(currentBinding);
-      this.type = type;
-   }
-
-   public Class<? extends T> getType()
-   {
-      return type;
-   }
-   
-   
-   
-}

Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/SimpleConstructor.java (from rev 38, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ConstructorMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/SimpleConstructor.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/SimpleConstructor.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,45 @@
+package org.jboss.webbeans.injectable;
+
+import java.lang.reflect.Constructor;
+import java.util.logging.Logger;
+
+import javax.webbeans.Container;
+
+import org.jboss.webbeans.util.LoggerUtil;
+
+public class SimpleConstructor<T> extends Unit<T> implements ComponentConstructor<T>
+{
+   
+   public static final String LOGGER_NAME = "componentConstructor";
+   
+   private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
+
+   private Constructor<T> constructor;
+   
+   @SuppressWarnings("unchecked")
+   public SimpleConstructor(Constructor<T> constructor)
+   {
+      super(constructor.getParameterTypes(), constructor.getParameterAnnotations());
+      this.constructor = constructor;
+      log.finest("Initialized metadata for " + constructor + " with injectable parameters " + getParameters());
+   }
+   
+   public Constructor<T> getConstructor()
+   {
+      return constructor;
+   }
+
+   public T invoke(Container container)
+   {
+      try
+      {
+         log.finest("Creating new instance of " + constructor.getDeclaringClass() + " with injected parameters " + getParameters());
+         return constructor.newInstance(getParameterValues(container));
+      }
+      catch (Exception e) 
+      {
+         throw new RuntimeException("Error instantiating " + constructor.getDeclaringClass(), e);
+      }
+   }
+   
+}


Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/SimpleConstructor.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Unit.java (from rev 38, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/UnitMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Unit.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Unit.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,54 @@
+package org.jboss.webbeans.injectable;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.webbeans.Container;
+
+public abstract class Unit<T>
+{
+
+   private List<Element<Object>> parameters;
+   
+   public Unit(Class<?>[] parameterTypes, Annotation[][] parameterAnnotations)
+   {
+      parameters = initParameters(parameterTypes, parameterAnnotations);
+   }
+   
+   public List<Element<Object>> getParameters()
+   {
+      return parameters;
+   }
+
+   @SuppressWarnings("unchecked")
+   protected static List<Element<Object>> initParameters(Class<?>[] parameterTypes, Annotation[][] parameterAnnotations)
+   {
+      List<Element<Object>> injectedParameters = new ArrayList<Element<Object>>();
+      for (int i = 0; i < parameterTypes.length; i++)
+      {
+         if (parameterAnnotations[i].length > 0)
+         {
+            Parameter<Object> parameter = new Parameter(parameterAnnotations[i], parameterTypes[i]);
+            injectedParameters.add(i, parameter);
+         }
+         else
+         {
+            Parameter<Object> parameter = new Parameter(parameterTypes[i]);
+            injectedParameters.add(i, parameter);
+         }
+      }
+      return injectedParameters;
+   }
+   
+   public Object[] getParameterValues(Container container)
+   {
+      Object[] parameterValues = new Object[parameters.size()];
+      for (int i = 0; i < parameterValues.length; i++)
+      {
+         parameterValues[i] = parameters.get(i).getValue(container);
+      }
+      return parameterValues;
+   }
+
+}

Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/UnitMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/UnitMetaModel.java	2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/UnitMetaModel.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -1,54 +0,0 @@
-package org.jboss.webbeans.injectable;
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.webbeans.Container;
-
-public abstract class UnitMetaModel<T>
-{
-
-   private List<ElementMetaModel<Object>> parameters;
-   
-   public UnitMetaModel(Class<?>[] parameterTypes, Annotation[][] parameterAnnotations)
-   {
-      parameters = initParameters(parameterTypes, parameterAnnotations);
-   }
-   
-   public List<ElementMetaModel<Object>> getParameters()
-   {
-      return parameters;
-   }
-
-   @SuppressWarnings("unchecked")
-   protected static List<ElementMetaModel<Object>> initParameters(Class<?>[] parameterTypes, Annotation[][] parameterAnnotations)
-   {
-      List<ElementMetaModel<Object>> injectedParameters = new ArrayList<ElementMetaModel<Object>>();
-      for (int i = 0; i < parameterTypes.length; i++)
-      {
-         if (parameterAnnotations[i].length > 0)
-         {
-            ParameterMetaModel<Object> parameter = new ParameterMetaModel(parameterAnnotations[i], parameterTypes[i]);
-            injectedParameters.add(i, parameter);
-         }
-         else
-         {
-            ParameterMetaModel<Object> parameter = new ParameterMetaModel(parameterTypes[i]);
-            injectedParameters.add(i, parameter);
-         }
-      }
-      return injectedParameters;
-   }
-   
-   public Object[] getParameterValues(Container container)
-   {
-      Object[] parameterValues = new Object[parameters.size()];
-      for (int i = 0; i < parameterValues.length; i++)
-      {
-         parameterValues[i] = parameters.get(i).getValue(container);
-      }
-      return parameterValues;
-   }
-
-}

Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/AbstractComponentModel.java (from rev 39, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/AbstractComponentModel.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/AbstractComponentModel.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,473 @@
+package org.jboss.webbeans.model;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.webbeans.BindingType;
+import javax.webbeans.Dependent;
+import javax.webbeans.DeploymentType;
+import javax.webbeans.Destroys;
+import javax.webbeans.Initializer;
+import javax.webbeans.Named;
+import javax.webbeans.ScopeType;
+
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.bindings.CurrentBinding;
+import org.jboss.webbeans.bindings.DependentBinding;
+import org.jboss.webbeans.bindings.ProductionBinding;
+import org.jboss.webbeans.ejb.EjbMetaData;
+import org.jboss.webbeans.injectable.ComponentConstructor;
+import org.jboss.webbeans.injectable.SimpleConstructor;
+import org.jboss.webbeans.injectable.InjectableMethod;
+import org.jboss.webbeans.util.AnnotatedItem;
+import org.jboss.webbeans.util.LoggerUtil;
+import org.jboss.webbeans.util.Reflections;
+import org.jboss.webbeans.util.Strings;
+
+
+
+/**
+ * Web Beans Component meta model
+ * 
+ * @author Pete Muir
+ * 
+ */
+public abstract class AbstractComponentModel<T>
+{
+
+   public static final String LOGGER_NAME = "componentMetaModel";
+   
+   private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
+   
+   private Class<? extends T> type;
+   private Set<Annotation> bindingTypes;
+   private Annotation deploymentType;
+   private Annotation scopeType;
+   private MergedStereotypesModel mergedStereotypes;
+
+   private String name;
+   
+   /**
+    * 
+    * @param annotatedItem Annotations read from java classes
+    * @param xmlAnnotatedItem Annotations read from XML
+    * @param container
+    */
+   @SuppressWarnings("unchecked")
+   public AbstractComponentModel(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+   {
+      if (annotatedItem == null)
+      {
+         throw new NullPointerException("annotatedItem must not be null. If the component is declared just in XML, pass in an empty annotatedItem");
+      }
+      
+      if (xmlAnnotatedItem == null)
+      {
+         throw new NullPointerException("xmlAnnotatedItem must not be null. If the component is declared just in Java, pass in an empty xmlAnnotatedItem");
+      }
+      
+      this.type = (Class<? extends T>) initType(annotatedItem, xmlAnnotatedItem);
+      log.fine("Building Web Bean component metadata for " +  type);
+      mergedStereotypes = new MergedStereotypesModel(annotatedItem, xmlAnnotatedItem, container);
+      this.bindingTypes = initBindingTypes(annotatedItem, xmlAnnotatedItem);
+      this.deploymentType = initDeploymentType(mergedStereotypes, annotatedItem, xmlAnnotatedItem, container);
+      this.scopeType = initScopeType(mergedStereotypes, annotatedItem, xmlAnnotatedItem);
+      this.name = initName(getMergedStereotypes(), annotatedItem, xmlAnnotatedItem, type);
+      checkRequiredTypesImplemented(getMergedStereotypes(), type);
+      checkScopeAllowed(getMergedStereotypes(), getScopeType(), type);
+      checkComponentImplementation(type);
+      // TODO Interceptors
+   }
+   
+   @SuppressWarnings("unchecked")
+   protected static Class<?> initType(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
+   {
+      if (annotatedItem.getAnnotatedClass() != null && xmlAnnotatedItem.getAnnotatedClass() != null && !annotatedItem.getAnnotatedClass().equals(xmlAnnotatedItem.getAnnotatedClass()))
+      {
+         throw new IllegalArgumentException("Cannot build a component which specifies different classes in XML and Java");
+      }
+      else if (xmlAnnotatedItem.getAnnotatedClass() != null)
+      {
+         log.finest("Component type specified in XML");
+         return xmlAnnotatedItem.getAnnotatedClass();
+      }
+      else if (annotatedItem.getAnnotatedClass() != null)
+      {
+         log.finest("Component type specified in Java");
+         return annotatedItem.getAnnotatedClass();
+      }
+      else
+      {
+         throw new IllegalArgumentException("Cannot build a component which doesn't specify a type");
+      }
+   }
+   
+   protected static Set<Annotation> initBindingTypes(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
+   {
+      Set<Annotation> xmlBindingTypes = xmlAnnotatedItem.getAnnotations(BindingType.class);
+      if (xmlBindingTypes.size() > 0)
+      {
+         // TODO support producer expression default binding type
+         log.finest("Using binding types " + xmlBindingTypes + " specified in XML");
+         return xmlBindingTypes;
+      }
+      
+      Set<Annotation> bindingTypes = annotatedItem.getAnnotations(BindingType.class);
+      
+      if (bindingTypes.size() == 0)
+      {
+         log.finest("Adding default @Current binding type");
+         bindingTypes.add(new CurrentBinding());
+      }
+      else
+      {
+         log.finest("Using binding types " + bindingTypes + " specified by annotations");
+      }
+      return bindingTypes;
+   }
+   
+   protected static Annotation initDeploymentType(MergedStereotypesModel stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+   {
+      Set<Annotation> xmlDeploymentTypes = xmlAnnotatedItem.getAnnotations(DeploymentType.class);
+      
+      if (xmlDeploymentTypes.size() > 1)
+      {
+         throw new RuntimeException("At most one deployment type may be specified (" + xmlDeploymentTypes + " are specified)");
+      }
+      
+      if (xmlDeploymentTypes.size() == 1)
+      {
+         Annotation deploymentType = xmlDeploymentTypes.iterator().next(); 
+         log.finest("Deployment type " + deploymentType + " specified in XML");
+         return deploymentType;
+      }
+      
+      if (xmlAnnotatedItem.getAnnotatedClass() == null)
+      {
+      
+         Set<Annotation> deploymentTypes = annotatedItem.getAnnotations(DeploymentType.class);
+         
+         if (deploymentTypes.size() > 1)
+         {
+            throw new RuntimeException("At most one deployment type may be specified (" + deploymentTypes + " are specified)");
+         }
+         if (deploymentTypes.size() == 1)
+         {
+            Annotation deploymentType = deploymentTypes.iterator().next();
+            log.finest("Deployment type " + deploymentType + " specified by annotation");
+            return deploymentType;
+         }
+      }
+      
+      if (stereotypes.getPossibleDeploymentTypes().size() > 0)
+      {
+         Annotation deploymentType = getDeploymentType(container.getEnabledDeploymentTypes(), stereotypes.getPossibleDeploymentTypes());
+         log.finest("Deployment type " + deploymentType + " specified by stereotype");
+         return deploymentType;
+      }
+      
+      if (xmlAnnotatedItem.getAnnotatedClass() != null)
+      {
+         log.finest("Using default @Production deployment type");
+         return new ProductionBinding();
+      }
+      throw new RuntimeException("All Java annotated classes have a deployment type");
+   }
+   
+   /**
+    * Return the scope of the component
+    */
+   protected static Annotation initScopeType(MergedStereotypesModel stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
+   {
+      Set<Annotation> xmlScopes = xmlAnnotatedItem.getAnnotations(ScopeType.class);
+      if (xmlScopes.size() > 1)
+      {
+         throw new RuntimeException("At most one scope may be specified in XML");
+      }
+      
+      if (xmlScopes.size() == 1)
+      {
+         Annotation scope = xmlScopes.iterator().next();
+         log.finest("Scope " + scope + " specified in XML");
+         return scope;
+      }
+      
+      Set<Annotation> scopes = annotatedItem.getAnnotations(ScopeType.class);
+      if (scopes.size() > 1)
+      {
+         throw new RuntimeException("At most one scope may be specified");
+      }
+      
+      if (scopes.size() == 1)
+      {
+         Annotation scope = scopes.iterator().next();
+         log.finest("Scope " + scope + " specified b annotation");
+         return scope;
+      }
+      
+      if (stereotypes.getPossibleScopeTypes().size() == 1)
+      {
+         Annotation scope = stereotypes.getPossibleScopeTypes().iterator().next();
+         log.finest("Scope " + scope + " specified by stereotype");
+         return scope;
+      }
+      else if (stereotypes.getPossibleScopeTypes().size() > 1)
+      {
+         throw new RuntimeException("All stereotypes must specify the same scope OR a scope must be specified on the component");
+      }
+      
+      log.finest("Using default @Dependent scope");
+      return new DependentBinding();
+   }
+   
+   public static Annotation getDeploymentType(List<Annotation> enabledDeploymentTypes, Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes)
+   {
+      for (int i = (enabledDeploymentTypes.size() - 1); i > 0; i--)
+      {
+         if (possibleDeploymentTypes.containsKey((enabledDeploymentTypes.get(i).annotationType())))
+         {
+            return enabledDeploymentTypes.get(i); 
+         }
+      }
+      return null;
+   }
+   
+   @SuppressWarnings("unchecked")
+   protected static <T> SimpleConstructor<T> initConstructor(Class<? extends T> type)
+   {
+      if (type.getConstructors().length == 1)
+      {
+         Constructor<T> constructor = type.getConstructors()[0];
+         log.finest("Exactly one constructor (" + constructor +") defined, using it as the component constructor for " + type);
+         return new SimpleConstructor<T>(constructor);
+      }
+      
+      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)
+            {
+               throw new RuntimeException("Cannot have more than one constructor annotated with @Initializer for " + type);
+            }
+            
+            else if (bindingTypeAnnotatedConstructors.size() > 1)
+            {
+               throw new RuntimeException("Cannot have more than one constructor with binding types specified on constructor parameters for " + type);
+            }
+            else
+            {
+               throw new RuntimeException("Specify a constructor either annotated with @Initializer or with parameters annotated with binding types for " + type);
+            }
+         }
+         else if (initializerAnnotatedConstructors.size() == 1)
+         {
+            Constructor<T> constructor = initializerAnnotatedConstructors.get(0);
+            log.finest("Exactly one constructor (" + constructor +") annotated with @Initializer defined, using it as the component constructor for " + type);
+            return new SimpleConstructor<T>(constructor);
+         }
+         else if (bindingTypeAnnotatedConstructors.size() == 1)
+         {
+            Constructor<T> constructor = bindingTypeAnnotatedConstructors.get(0);
+            log.finest("Exactly one constructor (" + constructor +") with parameters annotated with binding types defined, using it as the component constructor for " + type);
+            return new SimpleConstructor<T>(constructor);
+         }
+      }
+      
+      if (type.getConstructors().length == 0)
+      {      
+         Constructor<T> constructor = (Constructor<T>) Reflections.getConstructor(type);
+         log.finest("No constructor defined, using implicit no arguement constructor for " + type);
+         return new SimpleConstructor<T>(constructor);
+      }
+      
+      throw new RuntimeException("Cannot determine constructor to use for " + type);
+   }
+   
+   protected static String initName(MergedStereotypesModel stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, Class<?> type)
+   {
+      boolean componentNameDefaulted = false;
+      String name = null;
+      if (xmlAnnotatedItem.isAnnotationPresent(Named.class))
+      {
+         name = xmlAnnotatedItem.getAnnotation(Named.class).value();
+         if ("".equals(name))
+         {
+            log.finest("Using default name (specified in XML)");
+            componentNameDefaulted = true;
+         }
+         else
+         {
+            log.finest("Using name " + name + " specified in XML");
+         }
+      }
+      else if (annotatedItem.isAnnotationPresent(Named.class))
+      {
+         name = annotatedItem.getAnnotation(Named.class).value();
+         if ("".equals(name))
+         {
+            log.finest("Using default name (specified by annotations)");
+            componentNameDefaulted = true;
+         }
+         else
+         {
+            log.finest("Using name " + name + " specified in XML");
+         }
+      }
+      if ("".equals(name) && (componentNameDefaulted || stereotypes.isComponentNameDefaulted()))
+      {
+          name = Strings.decapitalize(type.getSimpleName());
+         log.finest("Default name of " + type + " is " + name );
+      }
+      return name;
+   }
+   
+   /**
+    * Check that the types required by the stereotypes on the component are implemented
+    */
+   protected static void checkRequiredTypesImplemented(MergedStereotypesModel stereotypes, Class<?> type)
+   {
+      for (Class<?> requiredType : stereotypes.getRequiredTypes())
+      {
+         log.finest("Checking if required type " + requiredType + " is implemented");
+         if (!requiredType.isAssignableFrom(type))
+         {
+            throw new RuntimeException("Required type " + requiredType + " isn't implement on " + type);
+         }
+      }
+   }
+   
+   /**
+    * Check that the scope type is allowed by the stereotypes on the component and the component type
+    * @param type 
+    */
+   protected static void checkScopeAllowed(MergedStereotypesModel stereotypes, Annotation scopeType, Class<?> type)
+   {
+      log.finest("Checking if " + scopeType + " is allowed for " + type);
+      if (stereotypes.getSupportedScopes().size() > 0)
+      {
+         if (!stereotypes.getSupportedScopes().contains(scopeType.annotationType()))
+         {
+            throw new RuntimeException("Scope " + scopeType + " is not an allowed by the stereotype for " + type);
+         }
+      }
+      if (isDeclaredFinal(type) && !scopeType.annotationType().equals(Dependent.class))
+      {
+         throw new RuntimeException("Scope " + scopeType + " is not allowed as the class is declared final or has methods declared final for " + type + ". Only @Dependent is allowed for final components");
+      }
+   }
+   
+   protected static boolean isDeclaredFinal(Class<?> type)
+   {
+      if (Reflections.isFinal(type))
+      {
+         return true;
+      }
+      for (Method method : type.getDeclaredMethods())
+      {
+         if (Reflections.isFinal(method))
+         {
+            return true;
+         }
+      }
+      return false;
+   }
+   
+   protected static <T> InjectableMethod<?> initRemoveMethod(EjbMetaData<T> ejbMetaData, Class<? extends T> type)
+   {
+      if (ejbMetaData.isStateful())
+      {
+         if (ejbMetaData.getRemoveMethods().size() == 1)
+         {
+            return new InjectableMethod<Object>(ejbMetaData.getRemoveMethods().get(0));
+         }
+         else if (ejbMetaData.getRemoveMethods().size() > 1)
+         {
+            List<Method> possibleRemoveMethods = new ArrayList<Method>();
+            for (Method removeMethod : ejbMetaData.getRemoveMethods())
+            {
+               if (removeMethod.isAnnotationPresent(Destroys.class))
+               {
+                  possibleRemoveMethods.add(removeMethod);
+               }
+            }
+            if (possibleRemoveMethods.size() == 1)
+            {
+               return new InjectableMethod<Object>(possibleRemoveMethods.get(0)); 
+            }
+            else if (possibleRemoveMethods.size() > 1)
+            {
+               throw new RuntimeException("Multiple remove methods are annotated @Destroys for " + type);
+            }
+            else if (possibleRemoveMethods.size() == 0)
+            {
+               throw new RuntimeException("Multiple remove methods are declared, and none are annotated @Destroys for " + type);
+            }
+         }
+         else if (ejbMetaData.getRemoveMethods().size() == 0)
+         {
+            throw new RuntimeException("Stateful enterprise bean component has no remove methods declared for " + type);
+         }
+      }
+      else
+      {
+         List<Method> destroysMethods = Reflections.getMethods(type, Destroys.class);
+         if (destroysMethods.size() > 0)
+         {
+            throw new RuntimeException("Only stateful enterprise bean components can have methods annotated @Destroys; " + type + " is not a stateful enterprise bean component");
+         }
+      }
+      return null;
+   }
+   
+   protected static void checkComponentImplementation(Class<?> type)
+   {
+      if (Reflections.isAbstract(type))
+      {
+         throw new RuntimeException("Web Bean implementation class " + type + " cannot be declared abstract");
+      }
+   }
+
+   public Set<Annotation> getBindingTypes()
+   {
+      return bindingTypes;
+   }
+
+   public Annotation getDeploymentType()
+   {
+      return deploymentType;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public Annotation getScopeType()
+   {
+      return scopeType;
+   }
+   
+   protected Class<? extends T> getType()
+   {
+      return type;
+   }
+   
+   protected MergedStereotypesModel getMergedStereotypes()
+   {
+      return mergedStereotypes;
+   }
+   
+   public abstract ComponentConstructor<T> getConstructor();
+
+}


Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/AbstractComponentModel.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/EnterpriseComponentModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/EnterpriseComponentModel.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/EnterpriseComponentModel.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,57 @@
+package org.jboss.webbeans.model;
+
+import java.lang.annotation.Annotation;
+
+import javax.webbeans.ApplicationScoped;
+import javax.webbeans.Dependent;
+
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.ejb.EJB;
+import org.jboss.webbeans.ejb.EjbMetaData;
+import org.jboss.webbeans.injectable.SimpleConstructor;
+import org.jboss.webbeans.injectable.InjectableMethod;
+import org.jboss.webbeans.util.AnnotatedItem;
+
+public class EnterpriseComponentModel<T> extends AbstractComponentModel<T>
+{
+
+   private SimpleConstructor<T> constructor;
+   private InjectableMethod<?> removeMethod;  
+   
+   public EnterpriseComponentModel(AnnotatedItem annotatedItem,
+         AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+   {
+      super(annotatedItem, xmlAnnotatedItem, container);
+      this.constructor = initConstructor(getType());
+      EjbMetaData<T> ejbMetaData = EJB.getEjbMetaData(getType());
+      EnterpriseComponentModel.checkScopeAllowed(getMergedStereotypes(), getScopeType(), getType(), ejbMetaData);
+      this.removeMethod = initRemoveMethod(ejbMetaData, getType());
+   }
+   
+   /**
+    * Check that the scope type is allowed by the stereotypes on the component and the component type
+    * @param type 
+    */
+   protected static <T> void checkScopeAllowed(MergedStereotypesModel stereotypes, Annotation scopeType, Class<?> type, EjbMetaData<T> ejbMetaData)
+   {
+      if (ejbMetaData.isStateless() && !scopeType.annotationType().equals(Dependent.class))
+      {
+         throw new RuntimeException("Scope " + scopeType + " is not allowed on stateless enterpise bean components for " + type + ". Only @Dependent is allowed on stateless enterprise bean components");
+      }
+      if (ejbMetaData.isSingleton() && (!scopeType.annotationType().equals(Dependent.class) || !scopeType.annotationType().equals(ApplicationScoped.class)))
+      {
+         throw new RuntimeException("Scope " + scopeType + " is not allowed on singleton enterpise bean components for " + type + ". Only @Dependent or @ApplicationScoped is allowed on singleton enterprise bean components");
+      }
+   }
+   
+   public SimpleConstructor<T> getConstructor()
+   {
+      return constructor;
+   }
+   
+   public InjectableMethod<?> getRemoveMethod()
+   {
+      return removeMethod;
+   }
+
+}


Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/EnterpriseComponentModel.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java (from rev 21, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,90 @@
+package org.jboss.webbeans.model;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.util.AnnotatedItem;
+
+/**
+ * Meta model for the merged stereotype for a component
+ * @author pmuir
+ *
+ */
+public class MergedStereotypesModel
+{
+
+   private Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes;
+   private Set<Annotation> possibleScopeTypes;
+   private boolean componentNameDefaulted;
+   private Set<Class<?>> requiredTypes;
+   private Set<Class<? extends Annotation>> supportedScopes;
+   
+   public MergedStereotypesModel(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+   {
+      possibleDeploymentTypes = new HashMap<Class<? extends Annotation>, Annotation>();
+      possibleScopeTypes = new HashSet<Annotation>();
+      requiredTypes = new HashSet<Class<?>>();
+      supportedScopes = new HashSet<Class<? extends Annotation>>();
+      
+      // All stereotypes declared in java and xml are merged
+      Set<Annotation> stereotypeAnnotations = new HashSet<Annotation>();
+      stereotypeAnnotations.addAll(annotatedItem.getAnnotations(Stereotype.class));
+      stereotypeAnnotations.addAll(xmlAnnotatedItem.getAnnotations(Stereotype.class));
+      
+      for (Annotation stereotypeAnnotation : stereotypeAnnotations)
+      {
+         // Retrieve and merge all metadata from stereotypes
+         StereotypeModel stereotype = container.getStereotypeManager().getStereotype(stereotypeAnnotation.annotationType());
+         if (stereotype == null)
+         {
+            throw new NullPointerException("Stereotype " + stereotypeAnnotation + " not registered with container");
+         }
+         if (stereotype.getDefaultDeploymentType() != null)
+         {
+            possibleDeploymentTypes.put(stereotype.getDefaultDeploymentType().annotationType(), stereotype.getDefaultDeploymentType());
+         }
+         if (stereotype.getDefaultScopeType() != null)
+         {
+            possibleScopeTypes.add(stereotype.getDefaultScopeType());
+         }
+         requiredTypes.addAll(stereotype.getRequiredTypes());
+         supportedScopes.addAll(stereotype.getSupportedScopes());
+         if (stereotype.isComponentNameDefaulted()) 
+         {
+            componentNameDefaulted = true;
+         }
+      }
+   }
+   
+   public Map<Class<? extends Annotation>, Annotation> getPossibleDeploymentTypes()
+   {
+      return possibleDeploymentTypes;
+   }
+   
+   public Set<Annotation> getPossibleScopeTypes()
+   {
+      return possibleScopeTypes;
+   }
+   
+   public boolean isComponentNameDefaulted()
+   {
+      return componentNameDefaulted;
+   }
+   
+   public Set<Class<?>> getRequiredTypes()
+   {
+      return requiredTypes;
+   }
+   
+   public Set<Class<? extends Annotation>> getSupportedScopes()
+   {
+      return supportedScopes;
+   }
+   
+}


Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/RemoteComponentModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/RemoteComponentModel.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/RemoteComponentModel.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,26 @@
+package org.jboss.webbeans.model;
+
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.injectable.ComponentConstructor;
+import org.jboss.webbeans.util.AnnotatedItem;
+
+public class RemoteComponentModel<T> extends AbstractComponentModel<T>
+{
+   
+   public RemoteComponentModel(AnnotatedItem annotatedItem,
+         AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+   {
+      super(annotatedItem, xmlAnnotatedItem, container);
+      // TODO Auto-generated constructor stub
+   }
+
+   @Override
+   public ComponentConstructor<T> getConstructor()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   
+
+}


Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/RemoteComponentModel.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/SimpleComponentModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/SimpleComponentModel.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/SimpleComponentModel.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,39 @@
+package org.jboss.webbeans.model;
+
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.injectable.SimpleConstructor;
+import org.jboss.webbeans.injectable.InjectableMethod;
+import org.jboss.webbeans.util.AnnotatedItem;
+
+public class SimpleComponentModel<T> extends AbstractComponentModel<T>
+{
+   
+   private SimpleConstructor<T> constructor;
+   private InjectableMethod<?> removeMethod;
+   
+   /**
+    * 
+    * @param annotatedItem Annotations read from java classes
+    * @param xmlAnnotatedItem Annotations read from XML
+    * @param container
+    */
+   @SuppressWarnings("unchecked")
+   public SimpleComponentModel(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+   {
+      super(annotatedItem, xmlAnnotatedItem, container);
+      this.constructor = initConstructor(getType());
+      // TODO Interceptors
+   }
+
+   public SimpleConstructor<T> getConstructor()
+   {
+      return constructor;
+   }
+   
+   public InjectableMethod<?> getRemoveMethod()
+   {
+      return removeMethod;
+   }
+
+   
+}


Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/SimpleComponentModel.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/StereotypeModel.java (from rev 19, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/StereotypeModel.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/StereotypeModel.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,191 @@
+package org.jboss.webbeans.model;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.webbeans.BindingType;
+import javax.webbeans.DeploymentType;
+import javax.webbeans.InterceptorBindingType;
+import javax.webbeans.Named;
+import javax.webbeans.ScopeType;
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.util.AnnotatedItem;
+
+/**
+ * A meta model for a stereotype, allows us to cache a stereotype and to validate it
+ * 
+ * @author pmuir
+ *
+ */
+public class StereotypeModel
+{
+   
+   private Class<? extends Annotation> stereotypeClass;
+   private Annotation defaultDeploymentType;
+   private Annotation defaultScopeType;
+   private boolean componentNameDefaulted;
+   private Set<Class<? extends Annotation>> supportedScopes;
+   private Set<Class<?>> requiredTypes;
+   private Set<Annotation> interceptorBindings;
+   
+   @SuppressWarnings("unchecked")
+   public StereotypeModel(AnnotatedItem annotatedClass)
+   {
+      initStereotypeClass(annotatedClass);
+      Stereotype stereotype = annotatedClass.getAnnotation(Stereotype.class);
+      initDefaultDeploymentType(annotatedClass);
+      initDefaultScopeType(annotatedClass);
+      initComponentNameDefaulted(annotatedClass);
+      initSupportedScopes(annotatedClass, stereotype);
+      initRequiredTypes(annotatedClass, stereotype);
+      initInterceptorBindings(annotatedClass);
+      checkBindingTypes(annotatedClass);
+   }
+   
+   private void checkBindingTypes(AnnotatedItem annotatedClass)
+   {
+      Set<Annotation> bindingTypes = annotatedClass.getAnnotations(BindingType.class);
+      if (bindingTypes.size() > 0)
+      {
+         throw new RuntimeException("Cannot declare binding types on a stereotpe");
+      }
+   }
+   
+   @SuppressWarnings("unchecked")
+   private void initStereotypeClass(AnnotatedItem annotatedClass)
+   {
+      if (Annotation.class.isAssignableFrom(annotatedClass.getAnnotatedClass()))
+      {
+         this.stereotypeClass = (Class<? extends Annotation>) annotatedClass.getAnnotatedClass();
+      }
+      else
+      {
+         throw new RuntimeException("@Stereotype can only be applied to an annotation");
+      }
+   }
+
+   private void initInterceptorBindings(AnnotatedItem annotatedClass)
+   {
+      interceptorBindings = annotatedClass.getAnnotations(InterceptorBindingType.class);
+   }
+
+   private void initSupportedScopes(AnnotatedItem annotatedElement, Stereotype stereotype)
+   {
+      this.supportedScopes = new HashSet<Class<? extends Annotation>>();
+      Class<? extends Annotation>[] supportedScopes = stereotype.supportedScopes();
+      if (supportedScopes.length > 0)
+      {
+         this.supportedScopes.addAll(Arrays.asList(supportedScopes));
+      }
+   }
+   
+   private void initRequiredTypes(AnnotatedItem annotatedElement, Stereotype stereotype)
+   {
+      this.requiredTypes = new HashSet<Class<?>>();
+      Class<?>[] requiredTypes = stereotype.requiredTypes();
+      if (requiredTypes.length > 0)
+      {
+         this.requiredTypes.addAll(Arrays.asList(requiredTypes));
+      }
+   }
+
+   private void initComponentNameDefaulted(AnnotatedItem annotatedElement)
+   {
+      if (annotatedElement.isAnnotationPresent(Named.class))
+      {
+         if (!"".equals(annotatedElement.getAnnotation(Named.class).value()))
+         {
+            throw new RuntimeException("Cannot specify a value for a @Named stereotype");
+         }
+         componentNameDefaulted = true;
+      }
+   }
+
+   private void initDefaultScopeType(AnnotatedItem annotatedElement)
+   {
+      Set<Annotation> scopeTypes = annotatedElement.getAnnotations(ScopeType.class);
+      if (scopeTypes.size() > 1)
+      {
+         throw new RuntimeException("At most one scope type may be specified");
+      }
+      else if (scopeTypes.size() == 1)
+      {
+         this.defaultScopeType = scopeTypes.iterator().next();
+      }
+   }
+
+   private void initDefaultDeploymentType(AnnotatedItem annotatedElement)
+   {
+      Set<Annotation> deploymentTypes = annotatedElement.getAnnotations(DeploymentType.class);
+      if (deploymentTypes.size() > 1)
+      {
+         throw new RuntimeException("At most one deployment type may be specified");
+      }
+      else if (deploymentTypes.size() == 1)
+      {
+         this.defaultDeploymentType = deploymentTypes.iterator().next();
+      }
+   }
+   
+   /**
+    * Get the default deployment type the stereotype specifies, or null if none
+    * is specified
+    */
+   public Annotation getDefaultDeploymentType()
+   {
+      return defaultDeploymentType;
+   }
+   
+   /**
+    * Get the default scope type the stereotype specifies, or null if none is
+    * specified
+    */
+   public Annotation getDefaultScopeType()
+   {
+      return defaultScopeType;
+   }
+   
+   /**
+    * Get any interceptor bindings the the stereotype specifies, or an empty set
+    * if none are specified
+    */
+   public Set<Annotation> getInterceptorBindings()
+   {
+      return interceptorBindings;
+   }
+   
+   /**
+    * Returns true if the stereotype specifies the component name should be 
+    * defaulted
+    */
+   public boolean isComponentNameDefaulted()
+   {
+      return componentNameDefaulted;
+   }
+   
+   /**
+    * Returns the scopes this stereotype allows, or an empty set if none are 
+    * specified
+    */
+   public Set<Class<? extends Annotation>> getSupportedScopes()
+   {
+      return supportedScopes;
+   }
+   
+   /**
+    * Returns the types this stereotype requires, or an empty set if none are
+    * specified
+    */
+   public Set<Class<?>> getRequiredTypes()
+   {
+      return requiredTypes;
+   }
+   
+   public Class<? extends Annotation> getStereotypeClass()
+   {
+      return stereotypeClass;
+   }
+}


Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/StereotypeModel.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java	2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -16,16 +16,15 @@
 import javax.webbeans.Production;
 import javax.webbeans.RequestScoped;
 
-import org.jboss.webbeans.ComponentMetaModel;
 import org.jboss.webbeans.ContainerImpl;
-import org.jboss.webbeans.StereotypeMetaModel;
-import org.jboss.webbeans.ComponentMetaModel.ComponentType;
 import org.jboss.webbeans.bindings.ConversationScopedBinding;
 import org.jboss.webbeans.bindings.CurrentBinding;
 import org.jboss.webbeans.bindings.DependentBinding;
 import org.jboss.webbeans.bindings.NamedBinding;
 import org.jboss.webbeans.bindings.RequestScopedBinding;
 import org.jboss.webbeans.bindings.StandardBinding;
+import org.jboss.webbeans.model.SimpleComponentModel;
+import org.jboss.webbeans.model.StereotypeModel;
 import org.jboss.webbeans.test.annotations.AnimalStereotype;
 import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
 import org.jboss.webbeans.test.annotations.Asynchronous;
@@ -45,30 +44,20 @@
 import org.jboss.webbeans.test.bindings.RiverFishStereotypeBinding;
 import org.jboss.webbeans.test.bindings.SynchronousBinding;
 import org.jboss.webbeans.test.components.Antelope;
-import org.jboss.webbeans.test.components.Bear;
 import org.jboss.webbeans.test.components.Carp;
 import org.jboss.webbeans.test.components.Cat;
 import org.jboss.webbeans.test.components.Chair;
-import org.jboss.webbeans.test.components.Cheetah;
 import org.jboss.webbeans.test.components.ComponentWithTooManyDeploymentTypes;
 import org.jboss.webbeans.test.components.ComponentWithTooManyScopeTypes;
-import org.jboss.webbeans.test.components.Cougar;
 import org.jboss.webbeans.test.components.Cow;
-import org.jboss.webbeans.test.components.Elephant;
-import org.jboss.webbeans.test.components.Giraffe;
 import org.jboss.webbeans.test.components.Goldfish;
 import org.jboss.webbeans.test.components.Gorilla;
 import org.jboss.webbeans.test.components.Haddock;
 import org.jboss.webbeans.test.components.Horse;
-import org.jboss.webbeans.test.components.Leopard;
-import org.jboss.webbeans.test.components.Lion;
 import org.jboss.webbeans.test.components.Moose;
 import org.jboss.webbeans.test.components.Order;
-import org.jboss.webbeans.test.components.Panther;
 import org.jboss.webbeans.test.components.Pig;
-import org.jboss.webbeans.test.components.Puma;
 import org.jboss.webbeans.test.components.SeaBass;
-import org.jboss.webbeans.test.components.Tiger;
 import org.jboss.webbeans.test.components.Tuna;
 import org.jboss.webbeans.test.mock.MockContainerImpl;
 import org.jboss.webbeans.util.AnnotatedItem;
@@ -100,12 +89,12 @@
    
    private void initStereotypes(ContainerImpl container)
    {
-      container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(AnimalStereotype.class)));
-      container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(HornedMammalStereotype.class)));
-      container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(MammalStereotype.class)));
-      container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(FishStereotype.class)));
-      container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(RiverFishStereotype.class)));
-      container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(RequestScopedAnimalStereotype.class)));
+      container.getStereotypeManager().addStereotype(new StereotypeModel(new ClassAnnotatedItem(AnimalStereotype.class)));
+      container.getStereotypeManager().addStereotype(new StereotypeModel(new ClassAnnotatedItem(HornedMammalStereotype.class)));
+      container.getStereotypeManager().addStereotype(new StereotypeModel(new ClassAnnotatedItem(MammalStereotype.class)));
+      container.getStereotypeManager().addStereotype(new StereotypeModel(new ClassAnnotatedItem(FishStereotype.class)));
+      container.getStereotypeManager().addStereotype(new StereotypeModel(new ClassAnnotatedItem(RiverFishStereotype.class)));
+      container.getStereotypeManager().addStereotype(new StereotypeModel(new ClassAnnotatedItem(RequestScopedAnimalStereotype.class)));
    }
    
    @Test
@@ -114,7 +103,7 @@
       boolean exception = false;
       try
       {
-         new ComponentMetaModel<ComponentWithTooManyDeploymentTypes>(new ClassAnnotatedItem(ComponentWithTooManyDeploymentTypes.class), emptyAnnotatedItem, container);
+         new SimpleComponentModel<ComponentWithTooManyDeploymentTypes>(new ClassAnnotatedItem(ComponentWithTooManyDeploymentTypes.class), emptyAnnotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -132,7 +121,7 @@
       xmlDefinedDeploymentTypeAnnotations.put(AnotherDeploymentType.class, new AnotherDeploymentTypeBinding());
       AnnotatedItem xmlDefinedDeploymentTypeAnnotatedItem = new MutableAnnotatedItem(ComponentWithTooManyDeploymentTypes.class, xmlDefinedDeploymentTypeAnnotations);
       
-      ComponentMetaModel<ComponentWithTooManyDeploymentTypes> component = new ComponentMetaModel<ComponentWithTooManyDeploymentTypes>(new ClassAnnotatedItem(ComponentWithTooManyDeploymentTypes.class), xmlDefinedDeploymentTypeAnnotatedItem, container);
+      SimpleComponentModel<ComponentWithTooManyDeploymentTypes> component = new SimpleComponentModel<ComponentWithTooManyDeploymentTypes>(new ClassAnnotatedItem(ComponentWithTooManyDeploymentTypes.class), xmlDefinedDeploymentTypeAnnotatedItem, container);
       assert component.getDeploymentType().annotationType().equals(AnotherDeploymentType.class);
    }
    
@@ -140,7 +129,7 @@
    public void testXmlDefaultDeploymentType()
    {
       AnnotatedItem antelopeAnnotatedItem = new MutableAnnotatedItem(Antelope.class, new HashMap<Class<? extends Annotation>, Annotation>());
-      ComponentMetaModel<Antelope> antelope = new ComponentMetaModel<Antelope>(emptyAnnotatedItem, antelopeAnnotatedItem, container);
+      SimpleComponentModel<Antelope> antelope = new SimpleComponentModel<Antelope>(emptyAnnotatedItem, antelopeAnnotatedItem, container);
       assert antelope.getDeploymentType().annotationType().equals(Production.class);
    }
    
@@ -148,7 +137,7 @@
    public void testXmlIgnoresJavaDeploymentType()
    {
       AnnotatedItem annotatedItem = new MutableAnnotatedItem(Tuna.class, new HashMap<Class<? extends Annotation>, Annotation>());
-      ComponentMetaModel<Tuna> tuna = new ComponentMetaModel<Tuna>(new ClassAnnotatedItem(Tuna.class), annotatedItem, container);
+      SimpleComponentModel<Tuna> tuna = new SimpleComponentModel<Tuna>(new ClassAnnotatedItem(Tuna.class), annotatedItem, container);
       assert tuna.getDeploymentType().annotationType().equals(Production.class);
    }
    
@@ -159,7 +148,7 @@
       annotations.put(HornedMammalStereotype.class, new HornedMamalStereotypeBinding());
       AnnotatedItem annotatedItem = new MutableAnnotatedItem(Moose.class, annotations);
       
-      ComponentMetaModel<Moose> moose = new ComponentMetaModel<Moose>(new ClassAnnotatedItem(Moose.class), annotatedItem, container);
+      SimpleComponentModel<Moose> moose = new SimpleComponentModel<Moose>(new ClassAnnotatedItem(Moose.class), annotatedItem, container);
       assert moose.getDeploymentType().annotationType().equals(HornedAnimalDeploymentType.class);
       
    }
@@ -174,7 +163,7 @@
       annotations.put(Asynchronous.class, new AsynchronousBinding());
       AnnotatedItem annotatedItem = new MutableAnnotatedItem(Cat.class, annotations);
       
-      ComponentMetaModel<Cat> cat = new ComponentMetaModel<Cat>(new ClassAnnotatedItem(Cat.class), annotatedItem, container);
+      SimpleComponentModel<Cat> cat = new SimpleComponentModel<Cat>(new ClassAnnotatedItem(Cat.class), annotatedItem, container);
       assert cat.getBindingTypes().size() == 1;
       assert annotationSetMatches(cat.getBindingTypes(), Asynchronous.class);
    }
@@ -183,7 +172,7 @@
    @Test
    public void testBindingTypesDeclaredInJava()
    {
-      ComponentMetaModel<Cat> cat = new ComponentMetaModel<Cat>(new ClassAnnotatedItem(Cat.class), emptyAnnotatedItem, container);
+      SimpleComponentModel<Cat> cat = new SimpleComponentModel<Cat>(new ClassAnnotatedItem(Cat.class), emptyAnnotatedItem, container);
       assert cat.getBindingTypes().size() == 1;
       assert annotationSetMatches(cat.getBindingTypes(), Synchronous.class);
    }
@@ -196,7 +185,7 @@
       annotations.put(Asynchronous.class, new AsynchronousBinding());
       AnnotatedItem annotatedItem = new MutableAnnotatedItem(Antelope.class, annotations);
       
-      ComponentMetaModel<Antelope> antelope = new ComponentMetaModel<Antelope>(emptyAnnotatedItem, annotatedItem, container);
+      SimpleComponentModel<Antelope> antelope = new SimpleComponentModel<Antelope>(emptyAnnotatedItem, annotatedItem, container);
       assert annotationSetMatches(antelope.getBindingTypes(), Asynchronous.class);
    }
    
@@ -204,7 +193,7 @@
    @Test
    public void testDefaultBindingType()
    {
-      ComponentMetaModel<Order> order = new ComponentMetaModel<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container);
+      SimpleComponentModel<Order> order = new SimpleComponentModel<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container);
       assert order.getBindingTypes().size() == 1;
       order.getBindingTypes().iterator().next().annotationType().equals(Current.class);
    }
@@ -214,7 +203,7 @@
    @Test
    public void testScopeDeclaredInJava()
    {
-      ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), emptyAnnotatedItem, container);
+      SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), emptyAnnotatedItem, container);
       assert trout.getScopeType().annotationType().equals(RequestScoped.class);
    }
    
@@ -225,7 +214,7 @@
       annotations.put(RequestScoped.class, new RequestScopedBinding());
       AnnotatedItem annotatedItem = new MutableAnnotatedItem(Order.class, annotations);
       
-      ComponentMetaModel<Order> order = new ComponentMetaModel<Order>(new ClassAnnotatedItem(Order.class), annotatedItem, container);
+      SimpleComponentModel<Order> order = new SimpleComponentModel<Order>(new ClassAnnotatedItem(Order.class), annotatedItem, container);
       assert order.getScopeType().annotationType().equals(RequestScoped.class);
    }
    
@@ -235,7 +224,7 @@
       Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
       annotations.put(ConversationScoped.class, new ConversationScopedBinding());
       AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
-      ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+      SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
       assert trout.getScopeType().annotationType().equals(ConversationScoped.class);
    }
    
@@ -245,14 +234,14 @@
       Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
       AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
       
-      ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+      SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
       assert trout.getScopeType().annotationType().equals(RequestScoped.class);
    }
    
    @Test
    public void testNoScopeSpecified()
    {
-      ComponentMetaModel<Order> order = new ComponentMetaModel<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container);
+      SimpleComponentModel<Order> order = new SimpleComponentModel<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container);
       assert order.getScopeType().annotationType().equals(Dependent.class);
    }
    
@@ -262,7 +251,7 @@
       boolean exception = false;
       try
       {
-         new ComponentMetaModel<ComponentWithTooManyScopeTypes>(new ClassAnnotatedItem(ComponentWithTooManyScopeTypes.class), emptyAnnotatedItem, container);
+         new SimpleComponentModel<ComponentWithTooManyScopeTypes>(new ClassAnnotatedItem(ComponentWithTooManyScopeTypes.class), emptyAnnotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -281,7 +270,7 @@
          annotations.put(RequestScoped.class, new RequestScopedBinding());
          annotations.put(ConversationScoped.class, new ConversationScopedBinding());
          AnnotatedItem antelopeAnnotatedItem = new MutableAnnotatedItem(Antelope.class, annotations);
-         new ComponentMetaModel<Antelope>(emptyAnnotatedItem, antelopeAnnotatedItem, container);
+         new SimpleComponentModel<Antelope>(emptyAnnotatedItem, antelopeAnnotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -296,7 +285,7 @@
       Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
       annotations.put(FishStereotype.class, new FishStereotypeBinding());
       AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
-      ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+      SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
       assert trout.getScopeType().annotationType().equals(RequestScoped.class);
    }
    
@@ -311,7 +300,7 @@
       boolean exception = false;
       try
       {
-         new ComponentMetaModel<Haddock>(new ClassAnnotatedItem(Haddock.class), annotatedItem, container);
+         new SimpleComponentModel<Haddock>(new ClassAnnotatedItem(Haddock.class), annotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -328,7 +317,7 @@
       annotations.put(AnimalStereotype.class, new AnimalStereotypeBinding());
       AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
       
-      ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+      SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
       assert trout.getScopeType().annotationType().equals(RequestScoped.class);     
    }
    
@@ -340,7 +329,7 @@
       annotations.put(RiverFishStereotype.class, new RiverFishStereotypeBinding());
       AnnotatedItem annotatedItem = new MutableAnnotatedItem(Haddock.class, annotations);
       
-      ComponentMetaModel<Haddock> haddock = new ComponentMetaModel<Haddock>(new ClassAnnotatedItem(Haddock.class), annotatedItem, container);
+      SimpleComponentModel<Haddock> haddock = new SimpleComponentModel<Haddock>(new ClassAnnotatedItem(Haddock.class), annotatedItem, container);
       assert haddock.getScopeType().annotationType().equals(ApplicationScoped.class);
    }
    
@@ -349,9 +338,8 @@
    @Test
    public void testNamed()
    {
-      ComponentMetaModel<Haddock> haddock = new ComponentMetaModel<Haddock>(new ClassAnnotatedItem(Haddock.class), emptyAnnotatedItem, container);
+      SimpleComponentModel<Haddock> haddock = new SimpleComponentModel<Haddock>(new ClassAnnotatedItem(Haddock.class), emptyAnnotatedItem, container);
       assert haddock.getName() != null;
-      haddock.getComponentType().equals(ComponentType.SIMPLE);
       assert haddock.getName().equals("haddock");
    }
    
@@ -368,10 +356,9 @@
          }
       });
       AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
-      ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+      SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
       
       assert trout.getName() != null;
-      trout.getComponentType().equals(ComponentType.SIMPLE);
       assert trout.getName().equals("seaBass");
    }
    
@@ -388,7 +375,7 @@
          }
       });
       AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
-      ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+      SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
       
       assert trout.getName().equals("aTrout");
    }
@@ -396,14 +383,14 @@
    @Test
    public void testNotNamed()
    {
-      ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), emptyAnnotatedItem, container);
+      SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), emptyAnnotatedItem, container);
       assert trout.getName() == null;
    }
    
    @Test
    public void testNonDefaultNamed()
    {
-      ComponentMetaModel<Moose> moose = new ComponentMetaModel<Moose>(new ClassAnnotatedItem(Moose.class), emptyAnnotatedItem, container);
+      SimpleComponentModel<Moose> moose = new SimpleComponentModel<Moose>(new ClassAnnotatedItem(Moose.class), emptyAnnotatedItem, container);
       assert moose.getName().equals("aMoose");
    }
    
@@ -426,7 +413,7 @@
       });
       AnnotatedItem currentSynchronousOrderAnnotatedItem = new MutableAnnotatedItem(Order.class, orderXmlAnnotations);
       
-      ComponentMetaModel<Order> order = new ComponentMetaModel<Order>(new ClassAnnotatedItem(Order.class), currentSynchronousOrderAnnotatedItem, container);
+      SimpleComponentModel<Order> order = new SimpleComponentModel<Order>(new ClassAnnotatedItem(Order.class), currentSynchronousOrderAnnotatedItem, container);
       assert Production.class.equals(order.getDeploymentType().annotationType());
       assert "currentSynchronousOrder".equals(order.getName());
       assert order.getBindingTypes().size() == 2;
@@ -437,7 +424,7 @@
    @Test
    public void testSingleStereotype()
    {
-      ComponentMetaModel<Gorilla> gorilla = new ComponentMetaModel<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
+      SimpleComponentModel<Gorilla> gorilla = new SimpleComponentModel<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
       assert gorilla.getName() == null;
       assert gorilla.getDeploymentType().annotationType().equals(Production.class);
       assert gorilla.getBindingTypes().iterator().next().annotationType().equals(Current.class);
@@ -449,7 +436,7 @@
    {
       try
       {
-         new ComponentMetaModel<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
+         new SimpleComponentModel<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -464,7 +451,7 @@
       boolean exception = false;
       try
       {
-         new ComponentMetaModel<Chair>(new ClassAnnotatedItem(Chair.class), emptyAnnotatedItem, container);
+         new SimpleComponentModel<Chair>(new ClassAnnotatedItem(Chair.class), emptyAnnotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -479,7 +466,7 @@
    {
       try
       {
-         new ComponentMetaModel<Goldfish>(new ClassAnnotatedItem(Goldfish.class), emptyAnnotatedItem, container);
+         new SimpleComponentModel<Goldfish>(new ClassAnnotatedItem(Goldfish.class), emptyAnnotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -495,7 +482,7 @@
       boolean exception = false;
       try
       {
-         new ComponentMetaModel<Carp>(new ClassAnnotatedItem(Carp.class), emptyAnnotatedItem, container);
+         new SimpleComponentModel<Carp>(new ClassAnnotatedItem(Carp.class), emptyAnnotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -513,7 +500,7 @@
       boolean exception = false;
       try
       {
-         new ComponentMetaModel<Cow>(new ClassAnnotatedItem(Cow.class), emptyAnnotatedItem, container);
+         new SimpleComponentModel<Cow>(new ClassAnnotatedItem(Cow.class), emptyAnnotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -528,7 +515,7 @@
       boolean exception = false;
       try
       {
-         new ComponentMetaModel<Horse>(new ClassAnnotatedItem(Horse.class), emptyAnnotatedItem, container);
+         new SimpleComponentModel<Horse>(new ClassAnnotatedItem(Horse.class), emptyAnnotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -541,7 +528,7 @@
       AnnotatedItem annotatedItem = new MutableAnnotatedItem(Horse.class, annotations);
       try
       {
-         new ComponentMetaModel<Horse>(new ClassAnnotatedItem(Horse.class), annotatedItem, container);
+         new SimpleComponentModel<Horse>(new ClassAnnotatedItem(Horse.class), annotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -555,7 +542,7 @@
       boolean exception = false;
       try
       {
-         new ComponentMetaModel<Pig>(new ClassAnnotatedItem(Pig.class), emptyAnnotatedItem, container);
+         new SimpleComponentModel<Pig>(new ClassAnnotatedItem(Pig.class), emptyAnnotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -568,7 +555,7 @@
       AnnotatedItem annotatedItem = new MutableAnnotatedItem(Pig.class, annotations);
       try
       {
-         new ComponentMetaModel<Pig>(new ClassAnnotatedItem(Pig.class), annotatedItem, container);
+         new SimpleComponentModel<Pig>(new ClassAnnotatedItem(Pig.class), annotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -576,152 +563,4 @@
       }
    }
    
-   @SuppressWarnings("unchecked")
-   @Test
-   public void testStateless()
-   {
-      ComponentMetaModel<Lion> lion = new ComponentMetaModel<Lion>(new ClassAnnotatedItem(Lion.class), emptyAnnotatedItem, container);
-      assert lion.getComponentType().equals(ComponentType.ENTERPRISE);
-      assert lion.getScopeType().annotationType().equals(Dependent.class);
-      annotationSetMatches(lion.getBindingTypes(), Current.class);
-      assert lion.getName().equals("lion");
-   }
-   
-   @SuppressWarnings("unchecked")
-   @Test
-   public void testStatelessDefinedInXml()
-   {
-      Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
-      AnnotatedItem annotatedItem = new MutableAnnotatedItem(Giraffe.class, annotations);
-      
-      ComponentMetaModel<Giraffe> giraffe = new ComponentMetaModel<Giraffe>(new ClassAnnotatedItem(Giraffe.class), annotatedItem, container);
-      assert giraffe.getComponentType().equals(ComponentType.ENTERPRISE);
-      assert giraffe.getScopeType().annotationType().equals(Dependent.class);
-      annotationSetMatches(giraffe.getBindingTypes(), Current.class);
-   }
-   
-   @Test
-   public void testStatelessWithRequestScope()
-   {
-      boolean exception = false;
-      try
-      {
-         new ComponentMetaModel<Bear>(new ClassAnnotatedItem(Bear.class), emptyAnnotatedItem, container);
-      }
-      catch (Exception e) 
-      {
-         exception = true;
-      }
-      assert exception;
-   }
-   
-   // TODO Need EJB3.1 @Test
-   public void testSingleton()
-   {
-      //ComponentMetaModel<Lion> lion = new ComponentMetaModel<Lion>(new ClassAnnotatedItem(Lion.class), emptyAnnotatedItem, container);
-      //assert lion.getComponentType().equals(ComponentType.ENTERPRISE);
-      //assert lion.getScopeType().annotationType().equals(ApplicationScoped.class);
-   }
-   
-   // TODO Need EJB3.1 @Test
-   public void testSingletonWithRequestScope()
-   {
-      //ComponentMetaModel<Lion> lion = new ComponentMetaModel<Lion>(new ClassAnnotatedItem(Lion.class), emptyAnnotatedItem, container);
-      //assert lion.getComponentType().equals(ComponentType.ENTERPRISE);
-      //assert lion.getScopeType().annotationType().equals(ApplicationScoped.class);
-   }
-   
-   @SuppressWarnings("unchecked")
-   @Test
-   public void testStateful()
-   {
-
-      ComponentMetaModel<Tiger> tiger = new ComponentMetaModel<Tiger>(new ClassAnnotatedItem(Tiger.class), emptyAnnotatedItem, container);
-      assert tiger.getComponentType().equals(ComponentType.ENTERPRISE);
-      annotationSetMatches(tiger.getBindingTypes(), Synchronous.class);
-      assert tiger.getRemoveMethod().getMethod().getName().equals("remove");
-      assert tiger.getName() == null;
-   }
-   
-   @SuppressWarnings("unchecked")
-   @Test
-   public void testMultipleRemoveMethodsWithDestroys()
-   {
-
-      ComponentMetaModel<Elephant> elephant = new ComponentMetaModel<Elephant>(new ClassAnnotatedItem(Elephant.class), emptyAnnotatedItem, container);
-      assert elephant.getComponentType().equals(ComponentType.ENTERPRISE);
-      assert elephant.getRemoveMethod().getMethod().getName().equals("remove2");
-   }
-   
-   @SuppressWarnings("unchecked")
-   @Test
-   public void testMultipleRemoveMethodsWithoutDestroys()
-   {
-      boolean exception = false;
-      try
-      {
-         new ComponentMetaModel<Puma>(new ClassAnnotatedItem(Puma.class), emptyAnnotatedItem, container);
-      }
-      catch (Exception e) 
-      {
-         exception = true;
-      }
-      assert exception;
-   }
-   
-   @SuppressWarnings("unchecked")
-   @Test
-   public void testMultipleRemoveMethodsWithMultipleDestroys()
-   {
-      boolean exception = false;
-      try
-      {
-         new ComponentMetaModel<Cougar>(new ClassAnnotatedItem(Cougar.class), emptyAnnotatedItem, container);
-      }
-      catch (Exception e) 
-      {
-         exception = true;
-      }
-      assert exception;
-   }
-   
-   @SuppressWarnings("unchecked")
-   @Test
-   public void testNonStatefulEnterpriseComponentWithDestroys()
-   {
-      boolean exception = false;
-      try
-      {
-         new ComponentMetaModel<Cheetah>(new ClassAnnotatedItem(Cheetah.class), emptyAnnotatedItem, container);
-      }
-      catch (Exception e) 
-      {
-         exception = true;
-      }
-      assert exception;
-   }
-   
-   @Test
-   public void testRemoveMethodWithDefaultBinding()
-   {
-
-      ComponentMetaModel<Panther> panther = new ComponentMetaModel<Panther>(new ClassAnnotatedItem(Panther.class), emptyAnnotatedItem, container);
-      assert panther.getComponentType().equals(ComponentType.ENTERPRISE);
-      assert panther.getRemoveMethod().getMethod().getName().equals("remove");
-      assert panther.getRemoveMethod().getParameters().size() == 1;
-      assert panther.getRemoveMethod().getParameters().get(0).getType().equals(String.class);
-      assert panther.getRemoveMethod().getParameters().get(0).getBindingTypes().length == 1;
-      assert panther.getRemoveMethod().getParameters().get(0).getBindingTypes()[0].annotationType().equals(Current.class);
-   }
-   
-   @SuppressWarnings("unchecked")
-   @Test
-   public void testMessageDriven()
-   {
-      ComponentMetaModel<Leopard> leopard = new ComponentMetaModel<Leopard>(new ClassAnnotatedItem(Leopard.class), emptyAnnotatedItem, container);
-      assert leopard.getComponentType().equals(ComponentType.ENTERPRISE);
-      annotationSetMatches(leopard.getBindingTypes(), Current.class);
-   }
-   
-   
 }

Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java	2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -5,9 +5,9 @@
 
 import javax.webbeans.Current;
 
-import org.jboss.webbeans.ComponentMetaModel;
 import org.jboss.webbeans.ContainerImpl;
-import org.jboss.webbeans.injectable.ConstructorMetaModel;
+import org.jboss.webbeans.injectable.SimpleConstructor;
+import org.jboss.webbeans.model.SimpleComponentModel;
 import org.jboss.webbeans.test.annotations.Synchronous;
 import org.jboss.webbeans.test.components.Chicken;
 import org.jboss.webbeans.test.components.Donkey;
@@ -42,7 +42,7 @@
    @Test
    public void testImplicitConstructor()
    {
-      ConstructorMetaModel<Order> constructor = new ComponentMetaModel<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container).getConstructor();
+      SimpleConstructor<Order> constructor = new SimpleComponentModel<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container).getConstructor();
       assert constructor.getConstructor().getDeclaringClass().equals(Order.class);
       assert constructor.getConstructor().getParameterTypes().length == 0;
       assert constructor.getParameters().size() == 0;
@@ -51,7 +51,7 @@
    @Test
    public void testSingleConstructor()
    {
-      ConstructorMetaModel<Donkey> constructor = new ComponentMetaModel<Donkey>(new ClassAnnotatedItem(Donkey.class), emptyAnnotatedItem, container).getConstructor();
+      SimpleConstructor<Donkey> constructor = new SimpleComponentModel<Donkey>(new ClassAnnotatedItem(Donkey.class), emptyAnnotatedItem, container).getConstructor();
       assert constructor.getConstructor().getDeclaringClass().equals(Donkey.class);
       assert constructor.getConstructor().getParameterTypes().length == 1;
       assert constructor.getConstructor().getParameterTypes()[0].equals(String.class);
@@ -64,7 +64,7 @@
    @Test
    public void testInitializerAnnotatedConstructor()
    {
-      ConstructorMetaModel<Sheep> constructor = new ComponentMetaModel<Sheep>(new ClassAnnotatedItem(Sheep.class), emptyAnnotatedItem, container).getConstructor();
+      SimpleConstructor<Sheep> constructor = new SimpleComponentModel<Sheep>(new ClassAnnotatedItem(Sheep.class), emptyAnnotatedItem, container).getConstructor();
       assert constructor.getConstructor().getDeclaringClass().equals(Sheep.class);
       assert constructor.getConstructor().getParameterTypes().length == 2;
       assert constructor.getConstructor().getParameterTypes()[0].equals(String.class);
@@ -81,7 +81,7 @@
    @Test
    public void testBindingTypeAnnotatedConstructor()
    {
-      ConstructorMetaModel<Duck> constructor = new ComponentMetaModel<Duck>(new ClassAnnotatedItem(Duck.class), emptyAnnotatedItem, container).getConstructor();
+      SimpleConstructor<Duck> constructor = new SimpleComponentModel<Duck>(new ClassAnnotatedItem(Duck.class), emptyAnnotatedItem, container).getConstructor();
       assert constructor.getConstructor().getDeclaringClass().equals(Duck.class);
       assert constructor.getConstructor().getParameterTypes().length == 2;
       assert constructor.getConstructor().getParameterTypes()[0].equals(String.class);
@@ -101,7 +101,7 @@
       boolean exception = false;
       try
       {
-         new ComponentMetaModel<Chicken>(new ClassAnnotatedItem(Chicken.class), emptyAnnotatedItem, container);
+         new SimpleComponentModel<Chicken>(new ClassAnnotatedItem(Chicken.class), emptyAnnotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -117,7 +117,7 @@
       boolean exception = false;
       try
       {
-         new ComponentMetaModel<Turkey>(new ClassAnnotatedItem(Turkey.class), emptyAnnotatedItem, container);
+         new SimpleComponentModel<Turkey>(new ClassAnnotatedItem(Turkey.class), emptyAnnotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -133,7 +133,7 @@
       boolean exception = false;
       try
       {
-         new ComponentMetaModel<Goat>(new ClassAnnotatedItem(Goat.class), emptyAnnotatedItem, container);
+         new SimpleComponentModel<Goat>(new ClassAnnotatedItem(Goat.class), emptyAnnotatedItem, container);
       }
       catch (Exception e) 
       {
@@ -149,7 +149,7 @@
       boolean exception = false;
       try
       {
-         new ComponentMetaModel<Goose>(new ClassAnnotatedItem(Goose.class), emptyAnnotatedItem, container);
+         new SimpleComponentModel<Goose>(new ClassAnnotatedItem(Goose.class), emptyAnnotatedItem, container);
       }
       catch (Exception e) 
       {

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/EnterpriseComponentModelTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/EnterpriseComponentModelTest.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/EnterpriseComponentModelTest.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,188 @@
+package org.jboss.webbeans.test;
+
+import static org.jboss.webbeans.test.util.Util.annotationSetMatches;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.webbeans.Current;
+import javax.webbeans.Dependent;
+
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.model.EnterpriseComponentModel;
+import org.jboss.webbeans.test.annotations.Synchronous;
+import org.jboss.webbeans.test.components.Bear;
+import org.jboss.webbeans.test.components.Cheetah;
+import org.jboss.webbeans.test.components.Cougar;
+import org.jboss.webbeans.test.components.Elephant;
+import org.jboss.webbeans.test.components.Giraffe;
+import org.jboss.webbeans.test.components.Leopard;
+import org.jboss.webbeans.test.components.Lion;
+import org.jboss.webbeans.test.components.Panther;
+import org.jboss.webbeans.test.components.Puma;
+import org.jboss.webbeans.test.components.Tiger;
+import org.jboss.webbeans.test.mock.MockContainerImpl;
+import org.jboss.webbeans.util.AnnotatedItem;
+import org.jboss.webbeans.util.ClassAnnotatedItem;
+import org.jboss.webbeans.util.MutableAnnotatedItem;
+import org.junit.Before;
+import org.junit.Test;
+
+public class EnterpriseComponentModelTest
+{
+   
+private ContainerImpl container;
+   
+   private AnnotatedItem emptyAnnotatedItem;
+   
+   @Before
+   public void before()
+   {
+      emptyAnnotatedItem = new MutableAnnotatedItem(null, new HashMap<Class<? extends Annotation>, Annotation>());
+      container = new MockContainerImpl(null);
+   }
+   
+   @SuppressWarnings("unchecked")
+   @Test
+   public void testStateless()
+   {
+      EnterpriseComponentModel<Lion> lion = new EnterpriseComponentModel<Lion>(new ClassAnnotatedItem(Lion.class), emptyAnnotatedItem, container);
+      assert lion.getScopeType().annotationType().equals(Dependent.class);
+      annotationSetMatches(lion.getBindingTypes(), Current.class);
+      assert lion.getName().equals("lion");
+   }
+   
+   @SuppressWarnings("unchecked")
+   @Test
+   public void testStatelessDefinedInXml()
+   {
+      Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+      AnnotatedItem annotatedItem = new MutableAnnotatedItem(Giraffe.class, annotations);
+      
+      EnterpriseComponentModel<Giraffe> giraffe = new EnterpriseComponentModel<Giraffe>(new ClassAnnotatedItem(Giraffe.class), annotatedItem, container);
+      assert giraffe.getScopeType().annotationType().equals(Dependent.class);
+      annotationSetMatches(giraffe.getBindingTypes(), Current.class);
+   }
+   
+   @Test
+   public void testStatelessWithRequestScope()
+   {
+      boolean exception = false;
+      try
+      {
+         new EnterpriseComponentModel<Bear>(new ClassAnnotatedItem(Bear.class), emptyAnnotatedItem, container);
+      }
+      catch (Exception e) 
+      {
+         exception = true;
+      }
+      assert exception;
+   }
+   
+   // TODO Need EJB3.1 @Test
+   public void testSingleton()
+   {
+      //ComponentMetaModel<Lion> lion = new ComponentMetaModel<Lion>(new ClassAnnotatedItem(Lion.class), emptyAnnotatedItem, container);
+      //assert lion.getComponentType().equals(ComponentType.ENTERPRISE);
+      //assert lion.getScopeType().annotationType().equals(ApplicationScoped.class);
+   }
+   
+   // TODO Need EJB3.1 @Test
+   public void testSingletonWithRequestScope()
+   {
+      //ComponentMetaModel<Lion> lion = new ComponentMetaModel<Lion>(new ClassAnnotatedItem(Lion.class), emptyAnnotatedItem, container);
+      //assert lion.getComponentType().equals(ComponentType.ENTERPRISE);
+      //assert lion.getScopeType().annotationType().equals(ApplicationScoped.class);
+   }
+   
+   @SuppressWarnings("unchecked")
+   @Test
+   public void testStateful()
+   {
+
+      EnterpriseComponentModel<Tiger> tiger = new EnterpriseComponentModel<Tiger>(new ClassAnnotatedItem(Tiger.class), emptyAnnotatedItem, container);
+      annotationSetMatches(tiger.getBindingTypes(), Synchronous.class);
+      assert tiger.getRemoveMethod().getMethod().getName().equals("remove");
+      assert tiger.getName() == null;
+   }
+   
+   @SuppressWarnings("unchecked")
+   @Test
+   public void testMultipleRemoveMethodsWithDestroys()
+   {
+
+      EnterpriseComponentModel<Elephant> elephant = new EnterpriseComponentModel<Elephant>(new ClassAnnotatedItem(Elephant.class), emptyAnnotatedItem, container);
+      assert elephant.getRemoveMethod().getMethod().getName().equals("remove2");
+   }
+   
+   @SuppressWarnings("unchecked")
+   @Test
+   public void testMultipleRemoveMethodsWithoutDestroys()
+   {
+      boolean exception = false;
+      try
+      {
+         new EnterpriseComponentModel<Puma>(new ClassAnnotatedItem(Puma.class), emptyAnnotatedItem, container);
+      }
+      catch (Exception e) 
+      {
+         exception = true;
+      }
+      assert exception;
+   }
+   
+   @SuppressWarnings("unchecked")
+   @Test
+   public void testMultipleRemoveMethodsWithMultipleDestroys()
+   {
+      boolean exception = false;
+      try
+      {
+         new EnterpriseComponentModel<Cougar>(new ClassAnnotatedItem(Cougar.class), emptyAnnotatedItem, container);
+      }
+      catch (Exception e) 
+      {
+         exception = true;
+      }
+      assert exception;
+   }
+   
+   @SuppressWarnings("unchecked")
+   @Test
+   public void testNonStatefulEnterpriseComponentWithDestroys()
+   {
+      boolean exception = false;
+      try
+      {
+         new EnterpriseComponentModel<Cheetah>(new ClassAnnotatedItem(Cheetah.class), emptyAnnotatedItem, container);
+      }
+      catch (Exception e) 
+      {
+         exception = true;
+      }
+      assert exception;
+   }
+   
+   @Test
+   public void testRemoveMethodWithDefaultBinding()
+   {
+
+      EnterpriseComponentModel<Panther> panther = new EnterpriseComponentModel<Panther>(new ClassAnnotatedItem(Panther.class), emptyAnnotatedItem, container);
+      
+      assert panther.getRemoveMethod().getMethod().getName().equals("remove");
+      assert panther.getRemoveMethod().getParameters().size() == 1;
+      assert panther.getRemoveMethod().getParameters().get(0).getType().equals(String.class);
+      assert panther.getRemoveMethod().getParameters().get(0).getBindingTypes().length == 1;
+      assert panther.getRemoveMethod().getParameters().get(0).getBindingTypes()[0].annotationType().equals(Current.class);
+   }
+   
+   @SuppressWarnings("unchecked")
+   @Test
+   public void testMessageDriven()
+   {
+      EnterpriseComponentModel<Leopard> leopard = new EnterpriseComponentModel<Leopard>(new ClassAnnotatedItem(Leopard.class), emptyAnnotatedItem, container);
+      annotationSetMatches(leopard.getBindingTypes(), Current.class);
+   }
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/EnterpriseComponentModelTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java	2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java	2008-07-03 17:42:40 UTC (rev 40)
@@ -7,7 +7,7 @@
 import javax.webbeans.Production;
 import javax.webbeans.RequestScoped;
 
-import org.jboss.webbeans.StereotypeMetaModel;
+import org.jboss.webbeans.model.StereotypeModel;
 import org.jboss.webbeans.test.annotations.AnimalOrderStereotype;
 import org.jboss.webbeans.test.annotations.AnimalStereotype;
 import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
@@ -26,7 +26,7 @@
    @Test
    public void testComponentStereotype()
    {
-      StereotypeMetaModel componentStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(Component.class));
+      StereotypeModel componentStereotype = new StereotypeModel(new ClassAnnotatedItem(Component.class));
       
       assert Production.class.equals(componentStereotype.getDefaultDeploymentType().annotationType());
       assert componentStereotype.getDefaultScopeType() == null;
@@ -39,7 +39,7 @@
    @Test
    public void testModelStereotype()
    {
-      StereotypeMetaModel modelStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(Model.class));
+      StereotypeModel modelStereotype = new StereotypeModel(new ClassAnnotatedItem(Model.class));
       assert Production.class.equals(modelStereotype.getDefaultDeploymentType().annotationType());
       assert RequestScoped.class.equals(modelStereotype.getDefaultScopeType().annotationType());
       assert modelStereotype.isComponentNameDefaulted();
@@ -51,7 +51,7 @@
    @Test
    public void testAnimalStereotype()
    {
-      StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(AnimalStereotype.class));
+      StereotypeModel animalStereotype = new StereotypeModel(new ClassAnnotatedItem(AnimalStereotype.class));
       assert animalStereotype.getDefaultScopeType().annotationType().equals(RequestScoped.class);
       assert animalStereotype.getInterceptorBindings().size() == 0;
       assert animalStereotype.getRequiredTypes().size() == 1;
@@ -64,7 +64,7 @@
    @Test
    public void testAnimalOrderStereotype()
    {
-      StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(AnimalOrderStereotype.class));
+      StereotypeModel animalStereotype = new StereotypeModel(new ClassAnnotatedItem(AnimalOrderStereotype.class));
       assert animalStereotype.getDefaultScopeType() == null;
       assert animalStereotype.getInterceptorBindings().size() == 0;
       assert animalStereotype.getRequiredTypes().size() == 2;
@@ -78,7 +78,7 @@
    @Test
    public void testRequestScopedAnimalStereotype()
    {
-      StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(RequestScopedAnimalStereotype.class));
+      StereotypeModel animalStereotype = new StereotypeModel(new ClassAnnotatedItem(RequestScopedAnimalStereotype.class));
       assert animalStereotype.getDefaultScopeType() == null;
       assert animalStereotype.getInterceptorBindings().size() == 0;
       assert animalStereotype.getRequiredTypes().size() == 1;
@@ -95,7 +95,7 @@
       boolean exception = false;
       try
       {
-         new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithTooManyScopeTypes.class));
+         new StereotypeModel(new ClassAnnotatedItem(StereotypeWithTooManyScopeTypes.class));
       }
       catch (Exception e) 
       {
@@ -110,7 +110,7 @@
       boolean exception = false;
       try
       {
-         new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithTooManyDeploymentTypes.class));
+         new StereotypeModel(new ClassAnnotatedItem(StereotypeWithTooManyDeploymentTypes.class));
       }
       catch (Exception e) 
       {
@@ -125,7 +125,7 @@
       boolean exception = false;
       try
       {
-         new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithNonEmptyNamed.class));
+         new StereotypeModel(new ClassAnnotatedItem(StereotypeWithNonEmptyNamed.class));
       }
       catch (Exception e) 
       {
@@ -140,7 +140,7 @@
       boolean exception = false;
       try
       {
-         new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithBindingTypes.class));
+         new StereotypeModel(new ClassAnnotatedItem(StereotypeWithBindingTypes.class));
       }
       catch (Exception e) 
       {




More information about the weld-commits mailing list