[seam-commits] Seam SVN: r9595 - in trunk/src/main/org/jboss/seam: init and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Nov 18 08:02:38 EST 2008


Author: pete.muir at jboss.org
Date: 2008-11-18 08:02:38 -0500 (Tue, 18 Nov 2008)
New Revision: 9595

Added:
   trunk/src/main/org/jboss/seam/deployment/ForwardingAbstractScanner.java
   trunk/src/main/org/jboss/seam/deployment/ForwardingDeploymentStrategy.java
   trunk/src/main/org/jboss/seam/deployment/TimestampCheckForwardingDeploymentStrategy.java
   trunk/src/main/org/jboss/seam/deployment/TimestampScanner.java
Removed:
   trunk/src/main/org/jboss/seam/deployment/HotDeploymentTimestampCheckStrategy.java
   trunk/src/main/org/jboss/seam/deployment/TimestampCheckStrategy.java
   trunk/src/main/org/jboss/seam/deployment/TimestampURLScanner.java
   trunk/src/main/org/jboss/seam/deployment/WarRootTimestampCheckStrategy.java
Modified:
   trunk/src/main/org/jboss/seam/deployment/AbstractScanner.java
   trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java
   trunk/src/main/org/jboss/seam/deployment/Scanner.java
   trunk/src/main/org/jboss/seam/deployment/URLScanner.java
   trunk/src/main/org/jboss/seam/deployment/WarRootDeploymentStrategy.java
   trunk/src/main/org/jboss/seam/init/Initialization.java
Log:
JBSEAM-3699, fix for compatiblity, and improve architecture

Modified: trunk/src/main/org/jboss/seam/deployment/AbstractScanner.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/AbstractScanner.java	2008-11-18 12:28:38 UTC (rev 9594)
+++ trunk/src/main/org/jboss/seam/deployment/AbstractScanner.java	2008-11-18 13:02:38 UTC (rev 9595)
@@ -1,7 +1,6 @@
 package org.jboss.seam.deployment;
 
 import java.io.DataInputStream;
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
@@ -17,6 +16,8 @@
 /**
  * Abstract base class for {@link Scanner} providing common functionality
  * 
+ * This class provides file-system orientated scanning
+ * 
  * @author Pete Muir
  *
  */
@@ -134,6 +135,11 @@
       ClassFile.class.getPackage(); //to force loading of javassist, throwing an exception if it is missing
    }
    
+   protected AbstractScanner()
+   {
+      
+   }
+   
    protected static boolean hasAnnotations(ClassFile classFile, Set<Class<? extends Annotation>> annotationTypes)
    {
       if (annotationTypes.size() > 0)
@@ -190,17 +196,15 @@
       return Long.MAX_VALUE;
    }
    
-   protected boolean handleItem(String name)
+   protected void handleItem(String name)
    {
-      return new Handler(name, deploymentStrategy.getDeploymentHandlers().entrySet(), deploymentStrategy.getClassLoader()).handle();
+      handle(name);
    }
    
-   /**
-    * Default impl of scanDirectories with exclusions for backwards compatibility
-    */
-   public void scanDirectories(File[] directories, File[] excludedDirectories)
+   
+   protected boolean handle(String name)
    {
-      scanDirectories(directories);
+      return new Handler(name, deploymentStrategy.getDeploymentHandlers().entrySet(), deploymentStrategy.getClassLoader()).handle();
    }
 
 }

Modified: trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java	2008-11-18 12:28:38 UTC (rev 9594)
+++ trunk/src/main/org/jboss/seam/deployment/DeploymentStrategy.java	2008-11-18 13:02:38 UTC (rev 9595)
@@ -90,7 +90,7 @@
 
    protected abstract String getDeploymentHandlersKey();
       
-   private void initScanner()
+   protected void initScanner()
    {
       List<String> scanners = new SeamDeploymentProperties(getClassLoader()).getPropertyValues(SCANNERS_KEY);
       for ( String className : scanners )

Added: trunk/src/main/org/jboss/seam/deployment/ForwardingAbstractScanner.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/ForwardingAbstractScanner.java	                        (rev 0)
+++ trunk/src/main/org/jboss/seam/deployment/ForwardingAbstractScanner.java	2008-11-18 13:02:38 UTC (rev 9595)
@@ -0,0 +1,57 @@
+package org.jboss.seam.deployment;
+
+import java.io.File;
+
+
+public abstract class ForwardingAbstractScanner extends AbstractScanner
+{
+
+   @Override
+   public DeploymentStrategy getDeploymentStrategy()
+   {
+      return delegate().getDeploymentStrategy();
+   }
+
+   @Override
+   public long getTimestamp()
+   {
+      return delegate().getTimestamp();
+   }
+
+   public void scanDirectories(File[] directories)
+   {
+      delegate().scanDirectories(directories);
+   }
+
+   public void scanResources(String[] resources)
+   {
+      delegate().scanResources(resources);
+   }
+   
+   @Override
+   public boolean equals(Object obj)
+   {
+      return delegate().equals(obj);
+   }
+   
+   @Override
+   protected boolean handle(String name)
+   {
+      return delegate().handle(name);
+   }
+   
+   @Override
+   public int hashCode()
+   {
+      return delegate().hashCode();
+   }
+   
+   @Override
+   public String toString()
+   {
+      return delegate().toString();
+   }
+   
+   protected abstract AbstractScanner delegate();
+   
+}


Property changes on: trunk/src/main/org/jboss/seam/deployment/ForwardingAbstractScanner.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/src/main/org/jboss/seam/deployment/ForwardingDeploymentStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/ForwardingDeploymentStrategy.java	                        (rev 0)
+++ trunk/src/main/org/jboss/seam/deployment/ForwardingDeploymentStrategy.java	2008-11-18 13:02:38 UTC (rev 9595)
@@ -0,0 +1,90 @@
+package org.jboss.seam.deployment;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A decorator for DeploymentStrategy
+ * 
+ * @author Dan Allen
+ * @author Pete Muir
+ */
+public abstract class ForwardingDeploymentStrategy extends DeploymentStrategy
+{
+
+   @Override
+   public ClassLoader getClassLoader()
+   {
+      return delegate().getClassLoader();
+   }
+
+   @Override
+   protected String getDeploymentHandlersKey()
+   {
+      return delegate().getDeploymentHandlersKey();
+   }
+   
+   @Override
+   public void scan()
+   {
+      delegate().scan();
+   }
+   
+   @Override
+   public boolean equals(Object obj)
+   {
+      return delegate().equals(obj);
+   }
+   
+   @Override
+   public Map<String, DeploymentHandler> getDeploymentHandlers()
+   {
+      return delegate().getDeploymentHandlers();
+   }
+   
+   @Override
+   public List<File> getFiles()
+   {
+      return delegate().getFiles();
+   }
+   
+   @Override
+   protected Scanner getScanner()
+   {
+      return delegate().getScanner();
+   }
+   
+   @Override
+   public long getTimestamp()
+   {
+      return delegate().getTimestamp();
+   }
+   
+   @Override
+   public int hashCode()
+   {
+      return delegate().hashCode();
+   }
+   
+   @Override
+   protected void postScan()
+   {
+      delegate().postScan();
+   }
+   
+   @Override
+   public void setFiles(List<File> files)
+   {
+      delegate().setFiles(files);
+   }
+   
+   @Override
+   public String toString()
+   {
+      return delegate().toString();
+   }
+   
+   protected abstract DeploymentStrategy delegate();
+
+}
\ No newline at end of file


Property changes on: trunk/src/main/org/jboss/seam/deployment/ForwardingDeploymentStrategy.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: trunk/src/main/org/jboss/seam/deployment/HotDeploymentTimestampCheckStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/HotDeploymentTimestampCheckStrategy.java	2008-11-18 12:28:38 UTC (rev 9594)
+++ trunk/src/main/org/jboss/seam/deployment/HotDeploymentTimestampCheckStrategy.java	2008-11-18 13:02:38 UTC (rev 9595)
@@ -1,33 +0,0 @@
-package org.jboss.seam.deployment;
-
-import java.io.File;
-
-/**
- * An accelerated version of the HotDeploymentStrategy that uses the SimpleURLScanner
- * to determine the timestamp of the latest file.
- * 
- * @author Dan Allen
- */
-public class HotDeploymentTimestampCheckStrategy extends TimestampCheckStrategy
-{
-   private HotDeploymentStrategy delegateStrategy;
-   
-   public HotDeploymentTimestampCheckStrategy(HotDeploymentStrategy hotDeploymentStrategy)
-   {
-      delegateStrategy = hotDeploymentStrategy;
-      getDeploymentHandlers().putAll(delegateStrategy.getDeploymentHandlers());
-   }
-   
-   @Override
-   public DeploymentStrategy getDelegateStrategy()
-   {
-      return delegateStrategy;
-   }
-   
-   @Override
-   public void scan()
-   {
-      getScanner().scanDirectories(delegateStrategy.getFiles().toArray(new File[0]));
-   }
-   
-}

Modified: trunk/src/main/org/jboss/seam/deployment/Scanner.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/Scanner.java	2008-11-18 12:28:38 UTC (rev 9594)
+++ trunk/src/main/org/jboss/seam/deployment/Scanner.java	2008-11-18 13:02:38 UTC (rev 9595)
@@ -12,12 +12,6 @@
  */
 public interface Scanner
 {
-   /**
-    * Recursively scan directories
-    * 
-    * @param directories An array of the roots of the directory trees to scan
-    */
-   public void scanDirectories(File[] directories);
    
    /**
     * Recursively scan directories, skipping directories in the exclusion list.
@@ -25,7 +19,7 @@
     * @param directories An array of the roots of the directory trees to scan
     * @param excludedDirectories Directories to skip over during the recursive scan
     */
-   public void scanDirectories(File[] directories, File[] excludedDirectories);
+   public void scanDirectories(File[] directories);
    
    /**
     * Scan for structures which contain any of the given resources in their root

Copied: trunk/src/main/org/jboss/seam/deployment/TimestampCheckForwardingDeploymentStrategy.java (from rev 9589, trunk/src/main/org/jboss/seam/deployment/TimestampCheckStrategy.java)
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/TimestampCheckForwardingDeploymentStrategy.java	                        (rev 0)
+++ trunk/src/main/org/jboss/seam/deployment/TimestampCheckForwardingDeploymentStrategy.java	2008-11-18 13:02:38 UTC (rev 9595)
@@ -0,0 +1,45 @@
+package org.jboss.seam.deployment;
+
+/**
+ * An accelerated version of the underlying strategy that uses the SimpleURLScanner
+ * to determine the timestamp of the latest file.
+ * 
+ * @author Dan Allen
+ */
+public abstract class TimestampCheckForwardingDeploymentStrategy extends ForwardingDeploymentStrategy
+{
+   private Scanner scanner;
+
+   public boolean changedSince(long mark)
+   {
+      scan();
+      return getTimestamp() > mark;
+   }
+
+   @Override
+   protected void initScanner()
+   {
+      if (getScanner() instanceof AbstractScanner)
+      {
+         final AbstractScanner delegate = (AbstractScanner) getScanner();
+         this.scanner = new TimestampScanner()
+         {
+
+            @Override
+            protected AbstractScanner delegate()
+            {
+               return delegate;
+            }
+            
+         };
+      }
+      
+   }
+   
+   @Override
+   protected void postScan()
+   {
+      // No-op
+   }
+
+}
\ No newline at end of file

Deleted: trunk/src/main/org/jboss/seam/deployment/TimestampCheckStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/TimestampCheckStrategy.java	2008-11-18 12:28:38 UTC (rev 9594)
+++ trunk/src/main/org/jboss/seam/deployment/TimestampCheckStrategy.java	2008-11-18 13:02:38 UTC (rev 9595)
@@ -1,48 +0,0 @@
-package org.jboss.seam.deployment;
-
-/**
- * An accelerated version of the underlying strategy that uses the SimpleURLScanner
- * to determine the timestamp of the latest file.
- * 
- * @author Dan Allen
- */
-public abstract class TimestampCheckStrategy extends DeploymentStrategy
-{
-   private Scanner scanner;
-
-   @Override
-   public ClassLoader getClassLoader()
-   {
-      return getDelegateStrategy().getClassLoader();
-   }
-
-   @Override
-   protected String getDeploymentHandlersKey()
-   {
-      return getDelegateStrategy().getDeploymentHandlersKey();
-   }
-   
-   public abstract DeploymentStrategy getDelegateStrategy();
-
-   public boolean changedSince(long mark)
-   {
-      scan();
-      return getTimestamp() > mark;
-   }
-
-   @Override
-   public Scanner getScanner()
-   {
-      if (scanner == null)
-      {
-         initScanner();
-      }
-      return scanner;
-   }
-
-   protected void initScanner()
-   {
-      scanner = new TimestampURLScanner(this);
-   }
-
-}
\ No newline at end of file

Copied: trunk/src/main/org/jboss/seam/deployment/TimestampScanner.java (from rev 9589, trunk/src/main/org/jboss/seam/deployment/TimestampURLScanner.java)
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/TimestampScanner.java	                        (rev 0)
+++ trunk/src/main/org/jboss/seam/deployment/TimestampScanner.java	2008-11-18 13:02:38 UTC (rev 9595)
@@ -0,0 +1,36 @@
+package org.jboss.seam.deployment;
+
+/**
+ * A no-op version of the URLScanner that merely returns whether the deployment
+ * handler would in fact handle this file. It does not process the file
+ * in any way. This allows us to use this scanner for timestamp checking.
+ * 
+ * @author Dan Allen
+ */
+public abstract class TimestampScanner extends ForwardingAbstractScanner
+{
+
+   @Override
+   protected boolean handle(String name)
+   {
+      for (DeploymentHandler handler : getDeploymentStrategy().getDeploymentHandlers().values())
+      {
+         if (handler instanceof ClassDeploymentHandler)
+         {
+            if (name.endsWith(".class"))
+            {
+               return true;
+            }
+         }
+         else
+         {
+            if (name.endsWith(handler.getMetadata().getFileNameSuffix()))
+            {
+               return true;
+            }
+         }
+      }
+      return false;
+   }
+  
+}

Deleted: trunk/src/main/org/jboss/seam/deployment/TimestampURLScanner.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/TimestampURLScanner.java	2008-11-18 12:28:38 UTC (rev 9594)
+++ trunk/src/main/org/jboss/seam/deployment/TimestampURLScanner.java	2008-11-18 13:02:38 UTC (rev 9595)
@@ -1,40 +0,0 @@
-package org.jboss.seam.deployment;
-
-/**
- * A no-op version of the URLScanner that merely returns whether the deployment
- * handler would in fact handle this file. It does not process the file
- * in any way. This allows us to use this scanner for timestamp checking.
- * 
- * @author Dan Allen
- */
-public class TimestampURLScanner extends URLScanner
-{
-   public TimestampURLScanner(DeploymentStrategy deploymentStrategy)
-   {
-      super(deploymentStrategy);
-   }
-
-   @Override
-   protected boolean handleItem(String name)
-   {
-      for (DeploymentHandler handler : getDeploymentStrategy().getDeploymentHandlers().values())
-      {
-         if (handler instanceof ClassDeploymentHandler)
-         {
-            if (name.endsWith(".class"))
-            {
-               return true;
-            }
-         }
-         else
-         {
-            if (name.endsWith(handler.getMetadata().getFileNameSuffix()))
-            {
-               return true;
-            }
-         }
-      }
-      return false;
-   }
-  
-}

Modified: trunk/src/main/org/jboss/seam/deployment/URLScanner.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/URLScanner.java	2008-11-18 12:28:38 UTC (rev 9594)
+++ trunk/src/main/org/jboss/seam/deployment/URLScanner.java	2008-11-18 13:02:38 UTC (rev 9595)
@@ -40,8 +40,7 @@
       scanDirectories(directories, new File[0]);
    }
    
-   @Override
-   public void scanDirectories(File[] directories, File[] excludedDirectories)
+   public void scanDirectories(File[] directories, File... excludedDirectories)
    {
       for (File directory : directories)
       {
@@ -126,7 +125,7 @@
          {
             ZipEntry entry = entries.nextElement();
             String name = entry.getName();
-            handleItem(name);
+            handle(name);
          }
       }
       catch (ZipException e)
@@ -161,7 +160,7 @@
          }
          else
          {
-            if (handleItem(newPath))
+            if (handle(newPath))
             {
                // only try to update the timestamp on this scanner if the file was actually handled
                touchTimestamp(child);

Modified: trunk/src/main/org/jboss/seam/deployment/WarRootDeploymentStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/WarRootDeploymentStrategy.java	2008-11-18 12:28:38 UTC (rev 9594)
+++ trunk/src/main/org/jboss/seam/deployment/WarRootDeploymentStrategy.java	2008-11-18 13:02:38 UTC (rev 9595)
@@ -69,7 +69,7 @@
    @Override
    public void scan()
    {
-      getScanner().scanDirectories(warRoot, excludedDirectories);
+      getScanner().scanDirectories(warRoot/*, excludedDirectories*/);
       postScan();
    }
    

Deleted: trunk/src/main/org/jboss/seam/deployment/WarRootTimestampCheckStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/WarRootTimestampCheckStrategy.java	2008-11-18 12:28:38 UTC (rev 9594)
+++ trunk/src/main/org/jboss/seam/deployment/WarRootTimestampCheckStrategy.java	2008-11-18 13:02:38 UTC (rev 9595)
@@ -1,34 +0,0 @@
-package org.jboss.seam.deployment;
-
-import java.io.File;
-
-
-/**
- * An accelerated version of the WarRootDeploymentStrategy that uses the SimpleURLScanner
- * to determine the timestamp of the latest file.
- * 
- * @author Dan Allen
- */
-public class WarRootTimestampCheckStrategy extends TimestampCheckStrategy
-{
-   private WarRootDeploymentStrategy delegateStrategy;
-   
-   public WarRootTimestampCheckStrategy(WarRootDeploymentStrategy warRootDeploymentStrategy)
-   {
-      delegateStrategy = warRootDeploymentStrategy;
-      getDeploymentHandlers().putAll(delegateStrategy.getDeploymentHandlers());
-   }
-
-   @Override
-   public DeploymentStrategy getDelegateStrategy()
-   {
-      return delegateStrategy;
-   }
-
-   @Override
-   public void scan()
-   {
-      getScanner().scanDirectories(delegateStrategy.getFiles().toArray(new File[0]), delegateStrategy.getExcludedDirectories());
-   }
-
-}

Modified: trunk/src/main/org/jboss/seam/init/Initialization.java
===================================================================
--- trunk/src/main/org/jboss/seam/init/Initialization.java	2008-11-18 12:28:38 UTC (rev 9594)
+++ trunk/src/main/org/jboss/seam/init/Initialization.java	2008-11-18 13:02:38 UTC (rev 9595)
@@ -49,13 +49,13 @@
 import org.jboss.seam.core.Expressions;
 import org.jboss.seam.core.Init;
 import org.jboss.seam.deployment.ClassDescriptor;
+import org.jboss.seam.deployment.DeploymentStrategy;
 import org.jboss.seam.deployment.FileDescriptor;
 import org.jboss.seam.deployment.HotDeploymentStrategy;
-import org.jboss.seam.deployment.HotDeploymentTimestampCheckStrategy;
 import org.jboss.seam.deployment.SeamDeploymentProperties;
 import org.jboss.seam.deployment.StandardDeploymentStrategy;
+import org.jboss.seam.deployment.TimestampCheckForwardingDeploymentStrategy;
 import org.jboss.seam.deployment.WarRootDeploymentStrategy;
-import org.jboss.seam.deployment.WarRootTimestampCheckStrategy;
 import org.jboss.seam.exception.Exceptions;
 import org.jboss.seam.log.LogProvider;
 import org.jboss.seam.log.Logging;
@@ -756,8 +756,19 @@
          {
             hotDeploymentStrategy = createHotDeployment(Thread.currentThread().getContextClassLoader(), isHotDeployEnabled(init));
             
-            if (hotDeploymentStrategy.available() && new HotDeploymentTimestampCheckStrategy(hotDeploymentStrategy).changedSince(init.getTimestamp()))
+            boolean changed = new TimestampCheckForwardingDeploymentStrategy()
             {
+               
+               @Override
+               protected DeploymentStrategy delegate()
+               {
+                  return hotDeploymentStrategy;
+               }
+               
+            }.changedSince(init.getTimestamp());
+            
+            if (hotDeploymentStrategy.available() && changed)
+            {
                ServletLifecycle.beginReinitialization(request);
                Contexts.getEventContext().set(HotDeploymentStrategy.NAME, hotDeploymentStrategy);
                hotDeploymentStrategy.scan();
@@ -792,10 +803,19 @@
                ServletLifecycle.endReinitialization();
             }
                
-            WarRootDeploymentStrategy warRootDeploymentStrategy = new WarRootDeploymentStrategy(
-                  Thread.currentThread().getContextClassLoader(), warRoot, new File[] { warClassesDirectory, warLibDirectory, hotDeployDirectory });
-            if (new WarRootTimestampCheckStrategy(warRootDeploymentStrategy).changedSince(init.getWarTimestamp()))
+            final WarRootDeploymentStrategy warRootDeploymentStrategy = new WarRootDeploymentStrategy(Thread.currentThread().getContextClassLoader(), warRoot, new File[] { warClassesDirectory, warLibDirectory, hotDeployDirectory });
+            changed = new TimestampCheckForwardingDeploymentStrategy()
             {
+               
+               @Override
+               protected DeploymentStrategy delegate()
+               {
+                  return warRootDeploymentStrategy;
+               }
+               
+            }.changedSince(init.getWarTimestamp());
+            if (changed)
+            {
                warRootDeploymentStrategy.scan();
                if (warRootDeploymentStrategy.getTimestamp() > init.getWarTimestamp())
                {




More information about the seam-commits mailing list