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

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Tue Aug 5 19:05:22 EDT 2008


Author: pete.muir at jboss.org
Date: 2008-08-05 19:05:22 -0400 (Tue, 05 Aug 2008)
New Revision: 64

Modified:
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/deployment/DeploymentStrategy.java
Log:
method for unit tests

Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/deployment/DeploymentStrategy.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/deployment/DeploymentStrategy.java	2008-08-05 23:04:16 UTC (rev 63)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/deployment/DeploymentStrategy.java	2008-08-05 23:05:22 UTC (rev 64)
@@ -1,17 +1,22 @@
 package org.jboss.webbeans.deployment;
 
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.logging.Logger;
 
 import javax.webbeans.Container;
 import javax.webbeans.DeploymentType;
+import javax.webbeans.Stereotype;
 
 import org.jboss.webbeans.ComponentInstanceImpl;
 import org.jboss.webbeans.ContainerImpl;
 import org.jboss.webbeans.model.SimpleComponentModel;
+import org.jboss.webbeans.model.StereotypeModel;
 import org.jboss.webbeans.util.ClassAnnotatedItem;
 import org.jboss.webbeans.util.LoggerUtil;
 import org.jboss.webbeans.util.MutableAnnotatedItem;
@@ -26,7 +31,7 @@
  */
 public class DeploymentStrategy
 {
-   private static final Logger log = LoggerUtil.getLogger(DeploymentStrategy.class.getName());     
+   private static final Logger log = LoggerUtil.getLogger("deploymentStrategy");     
    
    private ClassLoader classLoader;
    private ContainerImpl container;
@@ -43,9 +48,8 @@
       this.container = (ContainerImpl) container;
    }
    
-   public void scan()
+   public void scan(URL[] urls)
    {
-      URL[] urls = ClasspathUrlFinder.findResourceBases("META-INF/web-beans.xml");
            
       AnnotationDB db = new AnnotationDB();
       try
@@ -59,17 +63,47 @@
       }
       
       Map<String,Set<String>> index = db.getAnnotationIndex();
+      addStereotypes(index);
+      addComponents(index);
+   }
+   
+   private void addStereotypes(Map<String, Set<String>> index)
+   {
+      Set<String> stereotypeClassNames = index.get(Stereotype.class.getName());
+      try
+      {
+         for (String className : stereotypeClassNames)
+         {
+            log.info("Creating stereotype " + className);
+            StereotypeModel stereotypeModel = new StereotypeModel(new ClassAnnotatedItem(Reflections.classForName(className)));
+            container.getStereotypeManager().addStereotype(stereotypeModel);
+            log.info("Stereotype: " + stereotypeModel);
+         }
+      }
+      catch (Exception e) 
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   private void addComponents(Map<String, Set<String>> index)
+   {
+      Set<String> annotationNames = index.get(DeploymentType.class.getName());
       
-      Set<String> classNames = index.get(DeploymentType.class.getName());
-      
       try
       {
-         for (String className : classNames)
+         for (String annotationType : annotationNames)
          {
-            SimpleComponentModel componentModel = new SimpleComponentModel(
-                  new ClassAnnotatedItem(Reflections.classForName(className)), 
-                  new MutableAnnotatedItem(null, new HashMap()), container);         
-            container.addComponent(new ComponentInstanceImpl(componentModel));
+            Set<String> classNames = index.get(annotationType);
+            for (String className : classNames)
+            {
+               log.finest("Creating componnt" + className);
+               SimpleComponentModel componentModel = new SimpleComponentModel(
+                     new ClassAnnotatedItem(Reflections.classForName(className)), 
+                     new MutableAnnotatedItem(null, new HashMap()), container);  
+               container.addComponent(new ComponentInstanceImpl(componentModel));
+               log.info("Web Bean: " + componentModel);
+            }
          }
       }
       catch (ClassNotFoundException ex)
@@ -77,6 +111,14 @@
          throw new RuntimeException(ex);
       }
    }
+   
+   public void scan()
+   {
+      URL[] urls = ClasspathUrlFinder.findResourceBases("META-INF/web-beans.xml");
+      scan(urls);
+   }
+   
+   
 
    public ClassLoader getClassLoader()
    {




More information about the weld-commits mailing list