[seam-commits] Seam SVN: r7182 - trunk/src/main/org/jboss/seam/deployment.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Jan 22 08:11:59 EST 2008


Author: pete.muir at jboss.org
Date: 2008-01-22 08:11:59 -0500 (Tue, 22 Jan 2008)
New Revision: 7182

Modified:
   trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java
   trunk/src/main/org/jboss/seam/deployment/GroovyHotDeploymentStrategy.java
   trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java
   trunk/src/main/org/jboss/seam/deployment/Scanner.java
   trunk/src/main/org/jboss/seam/deployment/StandardDeploymentStrategy.java
   trunk/src/main/org/jboss/seam/deployment/URLScanner.java
Log:
Rework deployment to not rely on classloader scanning

Modified: trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java	2008-01-22 13:05:54 UTC (rev 7181)
+++ trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java	2008-01-22 13:11:59 UTC (rev 7182)
@@ -37,25 +37,8 @@
    /**
     * Do the scan for resources
     * 
-    * If {@link #getResourceNames()} are specified, then {@link Scanner#scanResources()}
-    * will be used, otherwise {@link Scanner#scanClassLoader()} will be used.
     */
-   public void scan()
-   {
-      if (getResourceNames() == null)
-      {
-         getScanner().scanClassLoader();
-      }
-      else
-      {
-         getScanner().scanResources();
-      }
-   }
-
-   /**
-    * Get the resource names which this {@link DeploymentStrategy} will scan for.
-    */
-   public abstract String[] getResourceNames();
+   public abstract void scan();
    
    /**
     * Get the scanner being used
@@ -73,17 +56,6 @@
     * Get the classloader to use
     */
    public abstract ClassLoader getClassLoader();
-   
-   /**
-    * Sometimes the main classloader cannot be scanned, so a scannable 
-    * classloader can be provided
-    * 
-    * By default the classloader specified in {@link #getClassLoader()}
-    */
-   public ClassLoader getScannableClassLoader()
-   {
-      return getClassLoader();
-   }
 
    /**
     * Get (or modify) any registered {@link DeploymentHandler}s

Modified: trunk/src/main/org/jboss/seam/deployment/GroovyHotDeploymentStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/GroovyHotDeploymentStrategy.java	2008-01-22 13:05:54 UTC (rev 7181)
+++ trunk/src/main/org/jboss/seam/deployment/GroovyHotDeploymentStrategy.java	2008-01-22 13:11:59 UTC (rev 7182)
@@ -64,19 +64,6 @@
    }
    
    @Override
-   public ClassLoader getScannableClassLoader()
-   {
-      if (classLoader != null)
-      {
-         return classLoader.getParent();
-      }
-      else
-      {
-         return null;
-      }
-   }
-   
-   @Override
    public Set<Class<Object>> getScannedComponentClasses()
    {
       Set<Class<Object>> set = new HashSet<Class<Object>>();

Modified: trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java	2008-01-22 13:05:54 UTC (rev 7181)
+++ trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java	2008-01-22 13:11:59 UTC (rev 7182)
@@ -103,12 +103,6 @@
    {
       return hotDeployClassLoader;
    }
-
-   @Override
-   public String[] getResourceNames()
-   {
-      return null;
-   }
    
    /**
     * Get all Components which the strategy has scanned and handled
@@ -117,4 +111,11 @@
    {
       return componentDeploymentHandler.getClasses();
    }
+
+   @Override
+   public void scan()
+   {
+      getScanner().scanDirectories(getHotDeploymentPaths());
+      
+   }
 }

Modified: trunk/src/main/org/jboss/seam/deployment/Scanner.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/Scanner.java	2008-01-22 13:05:54 UTC (rev 7181)
+++ trunk/src/main/org/jboss/seam/deployment/Scanner.java	2008-01-22 13:11:59 UTC (rev 7182)
@@ -1,5 +1,7 @@
 package org.jboss.seam.deployment;
 
+import java.io.File;
+
 /**
  * The Scanner is used to find resources to be processed by Seam
  * 
@@ -11,22 +13,18 @@
 public interface Scanner
 {
    /**
-    * Scan the "scannable" classloader.
+    * Recursively scan directories
     * 
-    * Method should scan the {@link DeploymentStrategy#getScannableClassLoader()}
-    * and pass all found resources to {@link DeploymentStrategy#handle(String)}
-    * to be processed by any registered deployment handlers
+    * @param directories An array of the roots of the directory trees to scan
     */
-   public void scanClassLoader();
+   public void scanDirectories(File[] directories);
    
    /**
-    * Scan any classloader containing the given resource.
+    * Scan for structures which contain any of the given resources in their root
     * 
-    * Method should scan any classloader containing {@link DeploymentStrategy#getResourceNames()}
-    * and pass all found resources to {@link DeploymentStrategy#handle(String)}
-    * to be processed by any registered deployment handlers 
+    * @param resources The resources to scan for
     */
-   public void scanResources();
+   public void scanResources(String[] resources);
    
    /**
     * Get the deployment strategy this scanner is used by

Modified: trunk/src/main/org/jboss/seam/deployment/StandardDeploymentStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/StandardDeploymentStrategy.java	2008-01-22 13:05:54 UTC (rev 7181)
+++ trunk/src/main/org/jboss/seam/deployment/StandardDeploymentStrategy.java	2008-01-22 13:11:59 UTC (rev 7182)
@@ -36,12 +36,6 @@
    {
       return classLoader;
    }
-   
-   @Override
-   public String[] getResourceNames()
-   {
-      return RESOURCE_NAMES;
-   }
 
    /**
     * Get all scanned and handled annotated components known to this strategy
@@ -67,4 +61,10 @@
       return namespaceDeploymentHandler.getPackages();
    }
    
+   @Override
+   public void scan()
+   {
+      getScanner().scanResources(RESOURCE_NAMES);
+   }
+   
 }

Modified: trunk/src/main/org/jboss/seam/deployment/URLScanner.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/URLScanner.java	2008-01-22 13:05:54 UTC (rev 7181)
+++ trunk/src/main/org/jboss/seam/deployment/URLScanner.java	2008-01-22 13:11:59 UTC (rev 7182)
@@ -32,25 +32,18 @@
       super(deploymentStrategy);
    }
    
-   public void scanClassLoader()
+   public void scanDirectories(File[] directories)
    {
-      Set<String> paths = new HashSet<String>();
-      for ( URL url: getURLsFromClassLoader() )
+      for (File directory : directories)
       {
-         String urlPath = url.getFile();
-         if ( urlPath.endsWith("/") )
-         {
-            urlPath = urlPath.substring( 0, urlPath.length()-1 );
-         }
-         paths.add( urlPath );
+         handleDirectory(directory, null);
       }
-      handle(paths);
    }
    
-   public void scanResources()
+   public void scanResources(String[] resources)
    {
       Set<String> paths = new HashSet<String>();
-      for (String resourceName : getDeploymentStrategy().getResourceNames())
+      for (String resourceName : resources)
       {
          try
          {
@@ -112,18 +105,6 @@
       }
    }
 
-   private URL[] getURLsFromClassLoader()
-   {
-      if (getDeploymentStrategy().getScannableClassLoader() instanceof URLClassLoader)
-      {
-         return ( (URLClassLoader) getDeploymentStrategy().getScannableClassLoader()).getURLs();
-      }
-      else
-      {
-         return new URL[0];
-      }
-   }
-
    private void handleArchiveByFile(File file) throws IOException
    {
       log.debug("archive: " + file);




More information about the seam-commits mailing list