You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2009/04/14 16:38:15 UTC

svn commit: r764794 - in /incubator/openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/spi/deployer/ main/java/org/apache/webbeans/spi/ee/deployer/ main/java/org/apache/webbeans/spi/se/deployer/ te...

Author: struberg
Date: Tue Apr 14 14:38:15 2009
New Revision: 764794

URL: http://svn.apache.org/viewvc?rev=764794&view=rev
Log:
OWB-89 remove all scannotation specific imports from the MetaDataDiscoveryService SPI

Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/config/WebBeansScannerTest.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java?rev=764794&r1=764793&r2=764794&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java Tue Apr 14 14:38:15 2009
@@ -214,7 +214,7 @@
         logger.info("Deploying configurations from class files is started");
 
         // Start from the class
-        Map<String, Set<String>> classIndex = scanner.getANNOTATION_DB().getClassIndex();
+        Map<String, Set<String>> classIndex = scanner.getClassIndex();
         
         if (classIndex != null)
         {
@@ -247,7 +247,7 @@
     {
         logger.info("Deploying configurations from XML files is started");
 
-        Map<String, InputStream> xmls = scanner.getWEBBEANS_XML_LOCATIONS();
+        Map<String, InputStream> xmls = scanner.getWebBeansXmlLocations();
         Set<String> keySet = xmls.keySet();
         Iterator<String> it = keySet.iterator();
 
@@ -265,7 +265,7 @@
         logger.info("Configuring the Interceptors is started");
 
         // Interceptors Set
-        Map<String, Set<String>> annotIndex = scanner.getANNOTATION_DB().getAnnotationIndex();
+        Map<String, Set<String>> annotIndex = scanner.getAnnotationIndex();
         Set<String> classes = annotIndex.get(Interceptor.class.getName());
 
         if (classes != null)
@@ -288,7 +288,7 @@
     {
         logger.info("Configuring the Decorators is started");
 
-        Map<String, Set<String>> annotIndex = scanner.getANNOTATION_DB().getAnnotationIndex();
+        Map<String, Set<String>> annotIndex = scanner.getAnnotationIndex();
         Set<String> classes = annotIndex.get(Decorator.class.getName());
 
         if (classes != null)
@@ -312,7 +312,7 @@
         
         try
         {
-            Map<String, Set<String>> specialMap = scanner.getANNOTATION_DB().getAnnotationIndex();
+            Map<String, Set<String>> specialMap = scanner.getAnnotationIndex();
             if (specialMap != null && specialMap.size() > 0)
             {
                 if (specialMap.containsKey(Specializes.class.getName()))
@@ -423,7 +423,7 @@
 
         addDefaultStereoTypes();
         
-        Map<String, Set<String>> stereotypeMap = scanner.getANNOTATION_DB().getClassIndex();
+        Map<String, Set<String>> stereotypeMap = scanner.getClassIndex();
         if (stereotypeMap != null && stereotypeMap.size() > 0)
         {
             Set<String> stereoClassSet = stereotypeMap.keySet();

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java?rev=764794&r1=764793&r2=764794&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java Tue Apr 14 14:38:15 2009
@@ -18,8 +18,10 @@
 
 
 import java.io.InputStream;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.WebBeansDeploymentException;
@@ -28,25 +30,25 @@
 public abstract class AbstractMetaDataDiscovery implements MetaDataDiscoveryService
 {
     /** Location of the beans.xml files. */
-    protected Map<String, InputStream> WEBBEANS_XML_LOCATIONS = new HashMap<String, InputStream>();
+    private Map<String, InputStream> webBeansXmlLocations = new HashMap<String, InputStream>();
 
     //private Map<String, InputStream> EJB_XML_LOCATIONS = new HashMap<String, InputStream>();
 
     /** Annotation Database */
-    protected AnnotationDB ANNOTATION_DB = null;
+    private AnnotationDB annotationDB = null;
 
     protected AbstractMetaDataDiscovery()
     {
         try
         {
-            if (ANNOTATION_DB == null)
+            if (annotationDB == null)
             {
-                ANNOTATION_DB = new AnnotationDB();
-                ANNOTATION_DB.setScanClassAnnotations(true);
-                ANNOTATION_DB.crossReferenceMetaAnnotations();    
-                ANNOTATION_DB.setScanFieldAnnotations(false);
-                ANNOTATION_DB.setScanMethodAnnotations(false);
-                ANNOTATION_DB.setScanParameterAnnotations(false);
+                annotationDB = new AnnotationDB();
+                annotationDB.setScanClassAnnotations(true);
+                annotationDB.crossReferenceMetaAnnotations();    
+                annotationDB.setScanFieldAnnotations(false);
+                annotationDB.setScanMethodAnnotations(false);
+                annotationDB.setScanParameterAnnotations(false);
             }            
             
         }
@@ -85,19 +87,33 @@
     /**
      * @return the wEBBEANS_XML_LOCATIONS
      */
-    public Map<String, InputStream> getWEBBEANS_XML_LOCATIONS()
+    public Map<String, InputStream> getWebBeansXmlLocations()
     {
-        return WEBBEANS_XML_LOCATIONS;
+        return Collections.unmodifiableMap(webBeansXmlLocations);
     }
 
     /**
      * @return the aNNOTATION_DB
      */
-    public AnnotationDB getANNOTATION_DB()
+    protected AnnotationDB getAnnotationDB()
     {
-        return ANNOTATION_DB;
+        return annotationDB;
     }
     
+    public Map<String, Set<String>> getAnnotationIndex()
+    {
+        return annotationDB.getAnnotationIndex();
+    }
+
+    public Map<String, Set<String>> getClassIndex()
+    {
+        return annotationDB.getClassIndex();
+    }
     
-    
+    protected void addWebBeansXmlLocation(String file, InputStream openStream)
+    {
+        webBeansXmlLocations.put(file, openStream);
+        
+    }
+
 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java?rev=764794&r1=764793&r2=764794&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java Tue Apr 14 14:38:15 2009
@@ -18,17 +18,49 @@
 
 import java.io.InputStream;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.webbeans.exception.WebBeansDeploymentException;
-import org.scannotation.AnnotationDB;
 
+/**
+ * This SPI is for abstracting the class scanning.  
+ *
+ * In a production environment Many different modules need to perform 
+ * class scanning (EJB, JSF, JPA, ...). This SPI allows us to only have one 
+ * central class scanner for the whole application server
+ * which only performs the scanning once at startup of each WebApp.
+ */
 public interface MetaDataDiscoveryService
 {
+    /**
+     * initialise the class scanner
+     * @param object
+     */
+    public void init(Object object);
+
+    /**
+     * Perform the actual class scanning.
+     * @throws WebBeansDeploymentException
+     */
     public void scan() throws WebBeansDeploymentException;
     
-    public Map<String, InputStream> getWEBBEANS_XML_LOCATIONS();
+    /**
+     * get the locations of the beans.xml files.
+     * @return key is the 
+     */
+    public Map<String, InputStream> getWebBeansXmlLocations();
     
-    public AnnotationDB getANNOTATION_DB();
+    /**
+     * Get all scanned classes and all annotations used by each very class.
+     * @return key is the list of scanned classes, Set is a list of annotations used by that class.
+     */
+    Map<String, Set<String>> getClassIndex();
+
+    /**
+     * Get all used annotations with all classes which usess this annotation somehow.   
+     * @return key is the fully qualified string name of a annotation class, Set is a 
+     * list of classes that use that annotation somehow.
+     */
+    Map<String, Set<String>> getAnnotationIndex();
     
-    public void init(Object object);
 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java?rev=764794&r1=764793&r2=764794&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java Tue Apr 14 14:38:15 2009
@@ -57,7 +57,7 @@
                 URL[] urls = new URL[arcs.size()];
                 arcs.toArray(urls);
 
-                ANNOTATION_DB.scanArchives(urls);
+                getAnnotationDB().scanArchives(urls);
                 
                 configure = true;
             }
@@ -114,7 +114,7 @@
 
                 listURL.add(url);
 
-                WEBBEANS_XML_LOCATIONS.put(addPath.getFile(), addPath.openStream());
+                addWebBeansXmlLocation(addPath.getFile(), addPath.openStream());
             }
         }
 
@@ -133,7 +133,7 @@
 
         if (url != null)
         {
-            WEBBEANS_XML_LOCATIONS.put(url.getFile(), url.openStream());
+            addWebBeansXmlLocation(url.getFile(), url.openStream());
 
             return WarUrlFinder.findWebInfClassesPath(this.servletContext);
         }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java?rev=764794&r1=764793&r2=764794&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java Tue Apr 14 14:38:15 2009
@@ -17,6 +17,8 @@
 
 import java.net.URL;
 import java.util.Enumeration;
+import java.util.Map;
+import java.util.Set;
 
 import org.apache.webbeans.spi.deployer.AbstractMetaDataDiscovery;
 import org.apache.webbeans.util.WebBeansUtil;
@@ -41,7 +43,7 @@
 
         URL[] urls = ClasspathUrlFinder.findResourceBases("META-INF/beans.xml", loader);
         
-        this.ANNOTATION_DB.scanArchives(urls);
+        this.getAnnotationDB().scanArchives(urls);
 
         configureXML();
 
@@ -56,7 +58,7 @@
             while (resources.hasMoreElements())
             {
                 URL resource = resources.nextElement();
-                this.WEBBEANS_XML_LOCATIONS.put(resource.getFile(), resource.openStream());
+                addWebBeansXmlLocation(resource.getFile(), resource.openStream());
             }
 
         }
@@ -66,4 +68,5 @@
         }
     }
 
+
 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/config/WebBeansScannerTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/config/WebBeansScannerTest.java?rev=764794&r1=764793&r2=764794&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/config/WebBeansScannerTest.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/config/WebBeansScannerTest.java Tue Apr 14 14:38:15 2009
@@ -58,7 +58,7 @@
         // try to re-run the scan
         scanner.scan();
 
-        Map<String, Set<String>> classMap = scanner.getANNOTATION_DB().getClassIndex();
+        Map<String, Set<String>> classMap = scanner.getClassIndex();
         Assert.assertNotNull(classMap);
         Assert.assertFalse(classMap.isEmpty());
         Set<String> testBeanAnnotations = classMap.get(ScannerTestBean.class.getName());