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

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Thu Jun 26 14:53:21 EDT 2008


Author: pete.muir at jboss.org
Date: 2008-06-26 14:53:21 -0400 (Thu, 26 Jun 2008)
New Revision: 17

Added:
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/DependentBinding.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ProductionBinding.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StandardBinding.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/util/AnnotatedWebBean.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedWebBean.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedWebBeanTest.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Animal.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalOrderStereotype.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalStereotype.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/RequestScopedAnimalStereotype.java
Removed:
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/EnhancedAnnotatedElement.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableEnhancedAnnotatedElement.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableEnhancedAnnotatedElementTest.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/ComponentInstanceTest.java
Log:
More work on meta model, and a meta model for stereotypes

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-06-26 18:52:46 UTC (rev 16)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -1,20 +1,21 @@
 package org.jboss.webbeans;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 import javax.webbeans.BindingType;
 import javax.webbeans.ComponentInstance;
 import javax.webbeans.Container;
-import javax.webbeans.Current;
 import javax.webbeans.DeploymentType;
 import javax.webbeans.Named;
 import javax.webbeans.ScopeType;
 import javax.webbeans.Stereotype;
 
-import org.jboss.webbeans.util.EnhancedAnnotatedElement;
+import org.jboss.webbeans.util.AnnotatedWebBean;
 
 /**
  * Web Beans Component meta model
@@ -29,23 +30,76 @@
    private Annotation componentType;
    private String name;
    private Annotation scopeType;
-   private Set<Annotation> stereotypes;
+   private Set<Annotation> possibleDeploymentTypes;
+   private Set<Annotation> possibleScopeTypes;
+   private boolean componentNameDefaulted;
+   private Set<Class<?>> requiredTypes;
+   private Set<Class<? extends Annotation>> supportedScopes;
    
-   public ComponentInstanceImpl(EnhancedAnnotatedElement annotatedElement)
+   public ComponentInstanceImpl(AnnotatedWebBean annotatedElement, ContainerImpl container)
    {
-      initSterotypes(annotatedElement);
+      initStereotypes(annotatedElement, container);
       initBindingTypes(annotatedElement);
-      initComponentType(annotatedElement);
+      initComponentType(annotatedElement, container);
       initScopeType(annotatedElement);
       initName(annotatedElement);
+      checkRequiredTypesImplemented(annotatedElement);
+      checkScopeAllowed(annotatedElement);
+      // TODO Interceptors
    }
    
-   private void initSterotypes(EnhancedAnnotatedElement annotatedElement)
+   private void initStereotypes(AnnotatedWebBean annotatedElement, ContainerImpl container)
    {
-      this.stereotypes = annotatedElement.getAnnotations(Stereotype.class);
+      possibleDeploymentTypes = new HashSet<Annotation>();
+      possibleScopeTypes = new HashSet<Annotation>();
+      requiredTypes = new HashSet<Class<?>>();
+      supportedScopes = new HashSet<Class<? extends Annotation>>();
+      for (Annotation stereotypeAnnotation : annotatedElement.getAnnotations(Stereotype.class))
+      {
+         StereotypeMetaModel stereotype = container.getStereotypeManager().getStereotype(stereotypeAnnotation.annotationType());
+         if (stereotype.getDefaultDeploymentType() != null)
+         {
+            possibleDeploymentTypes.add(stereotype.getDefaultDeploymentType());
+         }
+         if (stereotype.getDefaultScopeType() != null)
+         {
+            possibleScopeTypes.add(stereotype.getDefaultScopeType());
+         }
+         requiredTypes.addAll(stereotype.getRequiredTypes());
+         supportedScopes.addAll(stereotype.getSupportedScopes());
+         if (stereotype.isComponentNameDefaulted()) 
+         {
+            componentNameDefaulted = true;
+         }
+      }
    }
+   
+   private void checkScopeAllowed(AnnotatedWebBean annotatedClass)
+   {
+      if (supportedScopes.size() > 0)
+      {
+         if (!supportedScopes.contains(scopeType))
+         {
+            throw new RuntimeException("Scope " + scopeType + " is not an allowed by the component's stereotype");
+         }
+      }
+   }
+   
+   private void checkRequiredTypesImplemented(AnnotatedWebBean annotatedClass)
+   {
+      if (requiredTypes.size() > 0)
+      {
+         // TODO This needs to check a lot more. Or we do through checking assignability
+         List<Class> classes = Arrays.asList(annotatedClass.getAnnotatedClass().getInterfaces());
+         if (!classes.containsAll(requiredTypes))
+         {
+            // TODO Ugh, improve this exception
+            throw new RuntimeException("Not all required types are implemented");
+         }
+      }
+   }
 
-   private void initScopeType(EnhancedAnnotatedElement annotatedElement)
+   private void initScopeType(AnnotatedWebBean annotatedElement)
    {
       Set<Annotation> scopes = annotatedElement.getAnnotations(ScopeType.class);
       if (scopes.size() > 1)
@@ -56,13 +110,21 @@
       {
          this.scopeType = scopes.iterator().next();
       }
+      else if (possibleScopeTypes.size() == 1)
+      {
+         this.scopeType = possibleScopeTypes.iterator().next();
+      }
+      else if (possibleScopeTypes.size() > 0)
+      {
+         //TODO DO something
+      }
       else
       {
-         // TODO Look at sterotypes
+         this.scopeType = new DependentBinding();
       }
    }
 
-   private void initComponentType(EnhancedAnnotatedElement annotatedElement)
+   private void initComponentType(AnnotatedWebBean annotatedElement, ContainerImpl container)
    {
       Set<Annotation> deploymentTypes = annotatedElement.getAnnotations(DeploymentType.class);
       if (deploymentTypes.size() > 1)
@@ -75,11 +137,11 @@
       }
       else
       {
-         // TODO Look at sterotypes
+         this.componentType = getDeploymentType(container.getEnabledDeploymentTypes(), possibleDeploymentTypes);
       }
    }
 
-   private void initBindingTypes(EnhancedAnnotatedElement annotatedElement)
+   private void initBindingTypes(AnnotatedWebBean annotatedElement)
    {
       bindingTypes = annotatedElement.getAnnotations(BindingType.class);
       
@@ -90,19 +152,40 @@
       }
    }
 
-   private void initName(EnhancedAnnotatedElement annotatedElement)
+   private void initName(AnnotatedWebBean annotatedElement)
    {
       if (annotatedElement.isAnnotationPresent(Named.class))
       {
          String name = annotatedElement.getAnnotation(Named.class).value();
          if ("".equals(name))
          {
-            // TODO write default name algorithm
-            
+            componentNameDefaulted = true;
          }
-         this.name = name;
+         else
+         {
+            componentNameDefaulted = false;
+            this.name = name;
+         }
       }
+      if (componentNameDefaulted)
+      {
+         // TODO Write default name alogorithm
+      }
    }
+   
+   public static Annotation getDeploymentType(List<Annotation> enabledDeploymentTypes, Set<Annotation> possibleDeploymentTypes)
+   {
+      List<Annotation> l = new ArrayList<Annotation>(enabledDeploymentTypes);
+      l.retainAll(possibleDeploymentTypes);
+      if (l.size() > 0)
+      {
+         return l.get(0);
+      }
+      else
+      {
+         return new ProductionBinding();
+      }
+   }
 
    @Override
    public T create(Container container)
@@ -148,5 +231,7 @@
    {
       return scopeType;
    }
+   
+   
 
 }

Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,127 @@
+package org.jboss.webbeans;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.webbeans.ComponentInstance;
+import javax.webbeans.Container;
+import javax.webbeans.Context;
+import javax.webbeans.Observer;
+import javax.webbeans.TypeLiteral;
+
+public class ContainerImpl implements Container
+{
+   
+   private List<Annotation> enabledDeploymentTypes;
+   private StereotypeManager stereotypeManager;
+   
+   public ContainerImpl()
+   {
+      initEnabledDeploymentTypes();
+      this.stereotypeManager = new StereotypeManager();
+   }
+   
+   private void initEnabledDeploymentTypes()
+   {
+      this.enabledDeploymentTypes = new ArrayList<Annotation>();
+      // TODO Support enabling custom deployment types
+      if (this.enabledDeploymentTypes.size() == 0)
+      {
+         this.enabledDeploymentTypes.add(0, new StandardBinding());
+         this.enabledDeploymentTypes.add(1, new ProductionBinding());
+      }
+   }
+
+   public Container addComponent(ComponentInstance component)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public void addContext(Context context)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void addObserver(Observer observer)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void fireEvent(Object event, Annotation... bindings)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public Context getContext(Class<Annotation> scopeType)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public Object getInstanceByName(String name)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public <T> T getInstanceByType(Class<T> type, Annotation... bindingTypes)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public <T> T getInstanceByType(TypeLiteral<T> type,
+         Annotation... bindingTypes)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public void removeObserver(Observer observer)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public Set<ComponentInstance> resolveByName(String name)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public <T> T resolveByType(Class<T> apiType, Annotation... bindingTypes)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public <T> T resolveByType(TypeLiteral<T> apiType,
+         Annotation... bindingTypes)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public <T> Set<Observer<T>> resolveObservers(T event, Annotation... bindings)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+   
+   public List<Annotation> getEnabledDeploymentTypes()
+   {
+      return enabledDeploymentTypes;
+   }
+   
+   public StereotypeManager getStereotypeManager()
+   {
+      return this.stereotypeManager;
+   }
+   
+}


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

Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/DependentBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/DependentBinding.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/DependentBinding.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans;
+
+import javax.webbeans.Dependent;
+import javax.webbeans.DynamicBinding;
+
+public class DependentBinding extends DynamicBinding<Dependent> implements Dependent
+{
+
+}


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

Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ProductionBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ProductionBinding.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ProductionBinding.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans;
+
+import javax.webbeans.DynamicBinding;
+import javax.webbeans.Production;
+
+public class ProductionBinding extends DynamicBinding<Production> implements Production
+{
+
+}


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

Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StandardBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StandardBinding.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StandardBinding.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans;
+
+import javax.webbeans.DynamicBinding;
+import javax.webbeans.Standard;
+
+public class StandardBinding extends DynamicBinding<Standard> implements Standard
+{
+
+}


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

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-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,23 @@
+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);
+   }
+
+}


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

Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,193 @@
+package org.jboss.webbeans;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+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.AnnotatedWebBean;
+
+/**
+ * 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(AnnotatedWebBean 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(AnnotatedWebBean 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(AnnotatedWebBean 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(AnnotatedWebBean annotatedClass)
+   {
+      interceptorBindings = annotatedClass.getAnnotations(InterceptorBindingType.class);
+   }
+
+   private void initSupportedScopes(AnnotatedWebBean 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(AnnotatedWebBean 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(AnnotatedWebBean 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(AnnotatedWebBean 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(AnnotatedWebBean 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/StereotypeMetaModel.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedWebBean.java (from rev 15, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/EnhancedAnnotatedElement.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedWebBean.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedWebBean.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,50 @@
+package org.jboss.webbeans.util;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+/**
+ * AnnotatedWebBean provides a uniform access to the annotations on a Web Bean, 
+ * defined either in Java or XML 
+ * 
+ * @author Pete Muir
+ *
+ */
+public interface AnnotatedWebBean
+{
+   
+   /**
+    * Get all annotations on the item
+    * 
+    * An empty set is returned if no annotations are present
+    */
+   public abstract <T extends Annotation> Set<T> getAnnotations();
+   
+   /**
+    * Get all annotations which are annotated with the given meta annotation 
+    * type
+    * 
+    * If no annotations are present which are annotated with the given meta
+    * annotation an empty set is returned
+    */
+   public abstract <T extends Annotation> Set<Annotation> getAnnotations(
+         Class<T> metaAnnotationType);
+   
+   /**
+    * Get an annotation for the annotation type specified.
+    * 
+    * If the annotation isn't present, null is returned
+    */
+   public <T extends Annotation> T getAnnotation(Class<T> annotationType);
+   
+   /**
+    * Return true if the annotation type specified is present
+    */
+   public boolean isAnnotationPresent(Class<? extends Annotation> annotationType);
+   
+   /**
+    * Return the class of the annotated item
+    */
+   public Class<?> getAnnotatedClass();
+   
+}
\ No newline at end of file


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

Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/EnhancedAnnotatedElement.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/EnhancedAnnotatedElement.java	2008-06-26 18:52:46 UTC (rev 16)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/EnhancedAnnotatedElement.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -1,18 +0,0 @@
-package org.jboss.webbeans.util;
-
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
-public interface EnhancedAnnotatedElement
-{
-   
-   public abstract <T extends Annotation> Set<T> getAnnotations();
-   
-   public abstract <T extends Annotation> Set<Annotation> getAnnotations(
-         Class<T> metaAnnotationType);
-   
-   public <T extends Annotation> T getAnnotation(Class<T> arg0);
-   
-   public boolean isAnnotationPresent(Class<? extends Annotation> arg0);
-   
-}
\ No newline at end of file

Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedWebBean.java (from rev 15, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableEnhancedAnnotatedElement.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedWebBean.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedWebBean.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,112 @@
+package org.jboss.webbeans.util;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+public class MutableAnnotatedWebBean implements AnnotatedWebBean
+{
+
+   private Map<Class<? extends Annotation>, Annotation> annotations;
+   
+   private Map<Class<? extends Annotation>, Set<Annotation>> metaAnnotations;
+   private Set<Annotation> annotationSet;
+   private Class<?> annotatedClass;
+   
+   private MutableAnnotatedWebBean()
+   {
+      this.annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+   }
+   
+   public MutableAnnotatedWebBean(Class<?> clazz)
+   {
+      this();
+      this.annotatedClass = clazz;
+      for (Annotation annotation : clazz.getAnnotations())
+      {
+         add(annotation);
+      }
+   }
+
+   @SuppressWarnings("unchecked")
+   public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+   {
+      return (T) annotations.get(annotationType);
+   }
+   
+   private void setDirty()
+   {
+      metaAnnotations = null;
+      this.annotationSet = null;
+   }
+   
+   public <T extends Annotation> Set<Annotation> getAnnotations(Class<T> metaAnnotationType)
+   {
+      if (metaAnnotations == null)
+      {
+         metaAnnotations = new HashMap<Class<? extends Annotation>, Set<Annotation>>();
+      }
+      if (!metaAnnotations.containsKey(metaAnnotationType))
+      {
+         Set<Annotation> s = new HashSet<Annotation>();
+         for (Entry<Class<? extends Annotation>, Annotation> entry : annotations.entrySet())
+         {
+            if (entry.getValue().annotationType().isAnnotationPresent(metaAnnotationType))
+            {
+               s.add(entry.getValue());
+            }
+         }
+         metaAnnotations.put(metaAnnotationType, s);
+      }
+      return metaAnnotations.get(metaAnnotationType);
+   }
+   
+
+   public Set<Annotation> getAnnotations()
+   {
+      if (annotationSet == null)
+      {
+         annotationSet = new HashSet<Annotation>();
+         for (Entry<Class<? extends Annotation>, Annotation> entry : annotations.entrySet())
+         {
+            annotationSet.add(entry.getValue());
+         }
+      }
+      return annotationSet;
+   }
+
+   public boolean isAnnotationPresent(Class<? extends Annotation> annotatedType)
+   {
+      return annotations.containsKey(annotatedType);
+   }
+   
+   /**
+    * Add an annotation to the AnnotatedElement
+    * @param annotation
+    */
+   public void add(Annotation annotation)
+   {
+      setDirty();
+      annotations.put(annotation.annotationType(), annotation);
+   }
+   
+   public void addAll(Collection<Annotation> annotations)
+   {
+      for (Annotation annotation : annotations)
+      {
+         this.annotations.put(annotation.annotationType(), annotation);
+      }
+      setDirty();
+   }
+
+   public Class<?> getAnnotatedClass()
+   {
+      return annotatedClass;
+   }
+   
+}


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

Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableEnhancedAnnotatedElement.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableEnhancedAnnotatedElement.java	2008-06-26 18:52:46 UTC (rev 16)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableEnhancedAnnotatedElement.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -1,113 +0,0 @@
-package org.jboss.webbeans.util;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-/**
- * Helper class which allows us to store the annotations present on an object
- * 
- * Also allows you to discover meta annotations
- * 
- * @author pmuir
- *
- */
-public class MutableEnhancedAnnotatedElement implements EnhancedAnnotatedElement
-{
-
-   private Map<Class<? extends Annotation>, Annotation> annotations;
-   
-   private Map<Class<? extends Annotation>, Set<Annotation>> metaAnnotations;
-   private Set<Annotation> annotationSet;
-   
-   public MutableEnhancedAnnotatedElement()
-   {
-      this.annotations = new HashMap<Class<? extends Annotation>, Annotation>();
-   }
-   
-   public MutableEnhancedAnnotatedElement(AnnotatedElement annotatedElement)
-   {
-      this();
-      for (Annotation annotation : annotatedElement.getAnnotations())
-      {
-         add(annotation);
-      }
-   }
-
-   @SuppressWarnings("unchecked")
-   public <T extends Annotation> T getAnnotation(Class<T> annotationType)
-   {
-      return (T) annotations.get(annotationType);
-   }
-   
-   private void setDirty()
-   {
-      metaAnnotations = null;
-      this.annotationSet = null;
-   }
-   
-   public <T extends Annotation> Set<Annotation> getAnnotations(Class<T> metaAnnotationType)
-   {
-      if (metaAnnotations == null)
-      {
-         metaAnnotations = new HashMap<Class<? extends Annotation>, Set<Annotation>>();
-      }
-      if (!metaAnnotations.containsKey(metaAnnotationType))
-      {
-         Set<Annotation> s = new HashSet<Annotation>();
-         for (Entry<Class<? extends Annotation>, Annotation> entry : annotations.entrySet())
-         {
-            if (entry.getValue().annotationType().isAnnotationPresent(metaAnnotationType))
-            {
-               s.add(entry.getValue());
-            }
-         }
-         metaAnnotations.put(metaAnnotationType, s);
-      }
-      return metaAnnotations.get(metaAnnotationType);
-   }
-   
-
-   public Set<Annotation> getAnnotations()
-   {
-      if (annotationSet == null)
-      {
-         annotationSet = new HashSet<Annotation>();
-         for (Entry<Class<? extends Annotation>, Annotation> entry : annotations.entrySet())
-         {
-            annotationSet.add(entry.getValue());
-         }
-      }
-      return annotationSet;
-   }
-
-   public boolean isAnnotationPresent(Class<? extends Annotation> annotatedType)
-   {
-      return annotations.containsKey(annotatedType);
-   }
-   
-   /**
-    * Add an annotation to the AnnotatedElement
-    * @param annotation
-    */
-   public void add(Annotation annotation)
-   {
-      setDirty();
-      annotations.put(annotation.annotationType(), annotation);
-   }
-   
-   public void addAll(Collection<Annotation> annotations)
-   {
-      for (Annotation annotation : annotations)
-      {
-         this.annotations.put(annotation.annotationType(), annotation);
-      }
-      setDirty();
-   }
-
-}

Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java	2008-06-26 18:52:46 UTC (rev 16)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -1,22 +1,56 @@
 package org.jboss.webbeans.test;
 
 import javax.webbeans.ComponentInstance;
+import javax.webbeans.Current;
+import javax.webbeans.Dependent;
 import javax.webbeans.Production;
 
 import org.jboss.webbeans.ComponentInstanceImpl;
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.StereotypeMetaModel;
+import org.jboss.webbeans.test.components.AnimalStereotype;
+import org.jboss.webbeans.test.components.Gorilla;
 import org.jboss.webbeans.test.components.Order;
-import org.jboss.webbeans.util.MutableEnhancedAnnotatedElement;
+import org.jboss.webbeans.util.MutableAnnotatedWebBean;
+import org.junit.Before;
 import org.junit.Test;
 
 public class ComponentInstanceTest
 {
+   
+   private ContainerImpl container;
+   
+   @Before
+   public void before()
+   {
+      // TODO Probably need a mock container
+      container = new ContainerImpl();
+      StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(AnimalStereotype.class));
+      container.getStereotypeManager().addStereotype(animalStereotype);
+   }
 
+   @SuppressWarnings("unchecked")
    @Test
-   public void testMetaModel()
+   public void testOrder()
    {
-      ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new MutableEnhancedAnnotatedElement(Order.class));
+      
+      ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new MutableAnnotatedWebBean(Order.class), container);
       assert Production.class.equals(order.getComponentType().annotationType());
       assert "order".equals(order.getName());
+      assert order.getBindingTypes().size() == 1;
+      order.getBindingTypes().iterator().next().annotationType().equals(Current.class);
+      assert order.getScopeType().annotationType().equals(Dependent.class);
+      //assert order.getTypes() == ??
    }
    
+   @Test
+   public void testGorilla()
+   {
+      ComponentInstance<Gorilla> gorilla = new ComponentInstanceImpl<Gorilla>(new MutableAnnotatedWebBean(Gorilla.class), container);
+      assert gorilla.getName() == null;
+      // TODO Ensure that the a java declared component declares a deployment type
+      //assert gorilla.getComponentType() == null;
+      assert gorilla.getBindingTypes().iterator().next().annotationType().equals(Current.class);
+      assert gorilla.getScopeType().annotationType().equals(Dependent.class);
+   }
 }

Copied: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedWebBeanTest.java (from rev 15, ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableEnhancedAnnotatedElementTest.java)
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedWebBeanTest.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedWebBeanTest.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,81 @@
+package org.jboss.webbeans.test;
+
+import java.lang.annotation.Annotation;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.webbeans.BindingType;
+import javax.webbeans.Current;
+import javax.webbeans.DeploymentType;
+import javax.webbeans.Named;
+import javax.webbeans.Production;
+import javax.webbeans.ScopeType;
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.CurrentBinding;
+import org.jboss.webbeans.test.components.ClassWithNoAnnotations;
+import org.jboss.webbeans.test.components.Order;
+import org.jboss.webbeans.util.AnnotatedWebBean;
+import org.jboss.webbeans.util.MutableAnnotatedWebBean;
+import org.junit.Test;
+
+public class MutableAnnotatedWebBeanTest
+{
+   
+   @Test
+   public void testDeclaredAnnotations()
+   {
+      AnnotatedWebBean annotatedElement = new MutableAnnotatedWebBean(Order.class);
+      assert annotatedElement.getAnnotations().size() == 2;
+      assert annotatedElement.getAnnotation(Production.class) != null;
+      assert annotatedElement.getAnnotation(Named.class) != null;
+      System.out.println(annotatedElement.getAnnotatedClass());
+      assert annotatedElement.getAnnotatedClass().equals(Order.class);
+   }
+   
+   @Test
+   public void testMutability()
+   {
+      MutableAnnotatedWebBean annotatedElement = new MutableAnnotatedWebBean(Order.class);
+      assert annotatedElement.getAnnotations().size() == 2;
+      annotatedElement.add(new CurrentBinding());
+      assert annotatedElement.getAnnotations().size() == 3;
+      assert annotatedElement.getAnnotation(Production.class) != null;
+      assert annotatedElement.getAnnotation(Named.class) != null;
+      assert annotatedElement.getAnnotation(Current.class) != null;
+   }
+   
+   @Test
+   public void testMetaAnnotations()
+   {
+      AnnotatedWebBean annotatedElement = new MutableAnnotatedWebBean(Order.class);
+      Set<Annotation> annotations = annotatedElement.getAnnotations(DeploymentType.class);
+      assert annotations.size() == 1;
+      Iterator<Annotation> it = annotations.iterator();
+      Annotation production = it.next();
+      assert Production.class.equals(production.annotationType());
+   }
+   
+   @Test
+   public void testMutableMetaAnnotations()
+   {
+      MutableAnnotatedWebBean annotatedElement = new MutableAnnotatedWebBean(Order.class);
+      annotatedElement.add(new CurrentBinding());
+      Set<Annotation> annotations = annotatedElement.getAnnotations(BindingType.class);
+      assert annotations.size() == 1;
+      Iterator<Annotation> it = annotations.iterator();
+      Annotation production = it.next();
+      assert Current.class.equals(production.annotationType());
+   }
+   
+   @Test
+   public void testEmpty()
+   {
+      AnnotatedWebBean annotatedElement = new MutableAnnotatedWebBean(Order.class);
+      assert annotatedElement.getAnnotation(Stereotype.class) == null;
+      assert annotatedElement.getAnnotations(Stereotype.class).size() == 0;
+      AnnotatedWebBean classWithNoAnnotations = new MutableAnnotatedWebBean(ClassWithNoAnnotations.class);
+      assert classWithNoAnnotations.getAnnotations().size() == 0;
+   }
+   
+}


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

Deleted: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableEnhancedAnnotatedElementTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableEnhancedAnnotatedElementTest.java	2008-06-26 18:52:46 UTC (rev 16)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableEnhancedAnnotatedElementTest.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -1,66 +0,0 @@
-package org.jboss.webbeans.test;
-
-import java.lang.annotation.Annotation;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.webbeans.Current;
-import javax.webbeans.DeploymentType;
-import javax.webbeans.Named;
-import javax.webbeans.Production;
-import javax.webbeans.ScopeType;
-
-import org.jboss.webbeans.CurrentBinding;
-import org.jboss.webbeans.test.components.Order;
-import org.jboss.webbeans.util.EnhancedAnnotatedElement;
-import org.jboss.webbeans.util.MutableEnhancedAnnotatedElement;
-import org.junit.Test;
-
-public class MutableEnhancedAnnotatedElementTest
-{
-   
-   @Test
-   public void testDeclaredAnnotations()
-   {
-      EnhancedAnnotatedElement annotatedElement = new MutableEnhancedAnnotatedElement(Order.class);
-      assert annotatedElement.getAnnotations().size() == 2;
-      assert annotatedElement.getAnnotation(Production.class) != null;
-      assert annotatedElement.getAnnotation(Named.class) != null;
-   }
-   
-   @Test
-   public void testMutability()
-   {
-      MutableEnhancedAnnotatedElement annotatedElement = new MutableEnhancedAnnotatedElement(Order.class);
-      assert annotatedElement.getAnnotations().size() == 2;
-      annotatedElement.add(new CurrentBinding());
-      assert annotatedElement.getAnnotations().size() == 3;
-      assert annotatedElement.getAnnotation(Production.class) != null;
-      assert annotatedElement.getAnnotation(Named.class) != null;
-      assert annotatedElement.getAnnotation(Current.class) != null;
-   }
-   
-   @Test
-   public void testMetaAnnotations()
-   {
-      EnhancedAnnotatedElement annotatedElement = new MutableEnhancedAnnotatedElement(Order.class);
-      Set<Annotation> annotations = annotatedElement.getAnnotations(DeploymentType.class);
-      assert annotations.size() == 1;
-      Iterator<Annotation> it = annotations.iterator();
-      Annotation production = it.next();
-      assert Production.class.equals(production.annotationType());
-   }
-   
-   @Test
-   public void testMutableMetaAnnotations()
-   {
-      MutableEnhancedAnnotatedElement annotatedElement = new MutableEnhancedAnnotatedElement(Order.class);
-      annotatedElement.add(new CurrentBinding());
-      Set<Annotation> annotations = annotatedElement.getAnnotations(ScopeType.class);
-      assert annotations.size() == 1;
-      Iterator<Annotation> it = annotations.iterator();
-      Annotation production = it.next();
-      assert Current.class.equals(production.annotationType());
-   }
-   
-}

Added: 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	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,88 @@
+package org.jboss.webbeans.test;
+
+import java.util.Arrays;
+
+import javax.webbeans.Component;
+import javax.webbeans.Model;
+import javax.webbeans.Production;
+import javax.webbeans.RequestScoped;
+
+import org.jboss.webbeans.StereotypeMetaModel;
+import org.jboss.webbeans.test.components.Animal;
+import org.jboss.webbeans.test.components.AnimalOrderStereotype;
+import org.jboss.webbeans.test.components.AnimalStereotype;
+import org.jboss.webbeans.test.components.Order;
+import org.jboss.webbeans.test.components.RequestScopedAnimalStereotype;
+import org.jboss.webbeans.util.MutableAnnotatedWebBean;
+import org.junit.Test;
+
+public class StereotypeMetaModelTest
+{
+   
+   @Test
+   public void testComponentStereotype()
+   {
+      StereotypeMetaModel componentStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(Component.class));
+      
+      assert Production.class.equals(componentStereotype.getDefaultDeploymentType().annotationType());
+      assert componentStereotype.getDefaultScopeType() == null;
+      assert componentStereotype.getInterceptorBindings().size() == 0;
+      assert componentStereotype.getRequiredTypes().size() == 0;
+      assert componentStereotype.getSupportedScopes().size() == 0;
+      assert !componentStereotype.isComponentNameDefaulted();
+   }
+   
+   @Test
+   public void testModelStereotype()
+   {
+      StereotypeMetaModel modelStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(Model.class));
+      assert Production.class.equals(modelStereotype.getDefaultDeploymentType().annotationType());
+      assert RequestScoped.class.equals(modelStereotype.getDefaultScopeType().annotationType());
+      assert modelStereotype.isComponentNameDefaulted();
+      assert modelStereotype.getInterceptorBindings().size() == 0;
+      assert modelStereotype.getRequiredTypes().size() == 0;
+      assert modelStereotype.getSupportedScopes().size() == 0;
+   }
+   
+   @Test
+   public void testAnimalStereotype()
+   {
+      StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(AnimalStereotype.class));
+      assert animalStereotype.getDefaultScopeType() == null;
+      assert animalStereotype.getInterceptorBindings().size() == 0;
+      assert animalStereotype.getRequiredTypes().size() == 1;
+      assert Animal.class.equals(animalStereotype.getRequiredTypes().iterator().next());
+      assert animalStereotype.getSupportedScopes().size() == 0;
+      assert !animalStereotype.isComponentNameDefaulted();
+      assert animalStereotype.getDefaultDeploymentType() == null;
+   }
+   
+   @Test
+   public void testAnimalOrderStereotype()
+   {
+      StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(AnimalOrderStereotype.class));
+      assert animalStereotype.getDefaultScopeType() == null;
+      assert animalStereotype.getInterceptorBindings().size() == 0;
+      assert animalStereotype.getRequiredTypes().size() == 2;
+      Class<?> [] requiredTypes = {Animal.class, Order.class};
+      assert animalStereotype.getRequiredTypes().containsAll(Arrays.asList(requiredTypes));
+      assert animalStereotype.getSupportedScopes().size() == 0;
+      assert !animalStereotype.isComponentNameDefaulted();
+      assert animalStereotype.getDefaultDeploymentType() == null;
+   }
+   
+   @Test
+   public void testRequestScopedAnimalStereotype()
+   {
+      StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(RequestScopedAnimalStereotype.class));
+      assert animalStereotype.getDefaultScopeType() == null;
+      assert animalStereotype.getInterceptorBindings().size() == 0;
+      assert animalStereotype.getRequiredTypes().size() == 1;
+      assert Animal.class.equals(animalStereotype.getRequiredTypes().iterator().next());
+      assert animalStereotype.getSupportedScopes().size() == 1;
+      assert RequestScoped.class.equals(animalStereotype.getSupportedScopes().iterator().next());
+      assert !animalStereotype.isComponentNameDefaulted();
+      assert animalStereotype.getDefaultDeploymentType() == null;
+   }
+   
+}


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

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Animal.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Animal.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Animal.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.components;
+
+public interface Animal
+{
+
+}


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

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalOrderStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalOrderStereotype.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalOrderStereotype.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,17 @@
+package org.jboss.webbeans.test.components;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.Stereotype;
+
+ at Stereotype(requiredTypes={Animal.class, Order.class})
+ at Target( { TYPE })
+ at Retention(RUNTIME)
+public @interface AnimalOrderStereotype
+{
+
+}


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

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalStereotype.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalStereotype.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,17 @@
+package org.jboss.webbeans.test.components;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.Stereotype;
+
+ at Stereotype(requiredTypes=Animal.class)
+ at Target( { TYPE })
+ at Retention(RUNTIME)
+public @interface AnimalStereotype
+{
+
+}


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

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.components;
+
+public class ClassWithNoAnnotations
+{
+
+}


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

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,7 @@
+package org.jboss.webbeans.test.components;
+
+ at AnimalStereotype
+public class Gorilla implements Animal
+{
+
+}


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

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/RequestScopedAnimalStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/RequestScopedAnimalStereotype.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/RequestScopedAnimalStereotype.java	2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,18 @@
+package org.jboss.webbeans.test.components;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.RequestScoped;
+import javax.webbeans.Stereotype;
+
+ at Stereotype(requiredTypes=Animal.class, supportedScopes=RequestScoped.class)
+ at Target( { TYPE })
+ at Retention(RUNTIME)
+public @interface RequestScopedAnimalStereotype
+{
+
+}


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




More information about the weld-commits mailing list