[jboss-cvs] JBossAS SVN: r102289 - in projects/jboss-deployers/trunk: deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/jar and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Mar 11 08:47:33 EST 2010


Author: alesj
Date: 2010-03-11 08:47:33 -0500 (Thu, 11 Mar 2010)
New Revision: 102289

Added:
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/ArchiveMatcher.java
Modified:
   projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderClassPathDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/jar/JARStructure.java
Log:
[JBDEPLOY-252]; extract archive matcher from JARStructure.

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderClassPathDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderClassPathDeployer.java	2010-03-11 13:12:16 UTC (rev 102288)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderClassPathDeployer.java	2010-03-11 13:47:33 UTC (rev 102289)
@@ -31,6 +31,7 @@
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.DeploymentStages;
 import org.jboss.deployers.vfs.spi.deployer.AbstractOptionalVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.deployer.ArchiveMatcher;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.deployers.vfs.spi.structure.helpers.ClassPathVisitor;
 import org.jboss.vfs.VirtualFile;
@@ -40,6 +41,7 @@
  * VFSClassLoaderClassPathDeployer.
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
  * @version $Revision: 1.1 $
  */
 public class VFSClassLoaderClassPathDeployer extends AbstractOptionalVFSRealDeployer<ClassLoadingMetaData>
@@ -49,7 +51,10 @@
 
    /** The vfs excluded */
    public static String VFS_EXCLUDES = "org.jboss.deployers.vfs.plugins.classloader.VFS_EXCLUDES";  
-   
+
+   /** The archive matcher */
+   private ArchiveMatcher archiveMatcher;
+
    /**
     * Create a new VFSClassLoaderClassPathDeployer.
     */
@@ -104,7 +109,7 @@
       {
          for (VirtualFile file : rawClassPath)
          {
-            if (vfsClassPath.contains(file) == false)
+            if ((archiveMatcher == null || archiveMatcher.hasArchiveSuffix(file)) && vfsClassPath.contains(file) == false)
             {
                if (canSeeParent == false || (canSeeParent && parentClassPath.contains(file) == false)) 
                {
@@ -114,7 +119,7 @@
                   }
                   catch (IOException e)
                   {
-                     DeploymentException.rethrowAsDeploymentException("Failed to mount " + file, e);
+                     throw DeploymentException.rethrowAsDeploymentException("Failed to mount " + file, e);
                   }
                   vfsClassPath.add(file);
                }
@@ -145,4 +150,14 @@
       unit.removeAttachment(VFS_CLASS_PATH);
       unit.removeAttachment(VFS_EXCLUDES);
    }
+
+   /**
+    * Set the archive matcher.
+    *
+    * @param archiveMatcher the archive matcher
+    */
+   public void setArchiveMatcher(ArchiveMatcher archiveMatcher)
+   {
+      this.archiveMatcher = archiveMatcher;
+   }
 }

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/jar/JARStructure.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/jar/JARStructure.java	2010-03-11 13:12:16 UTC (rev 102288)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/jar/JARStructure.java	2010-03-11 13:47:33 UTC (rev 102289)
@@ -21,9 +21,9 @@
 */
 package org.jboss.deployers.vfs.plugins.structure.jar;
 
-import java.util.Set;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Set;
 
 import org.jboss.beans.metadata.api.annotations.Install;
 import org.jboss.beans.metadata.api.annotations.Uninstall;
@@ -31,6 +31,7 @@
 import org.jboss.deployers.spi.deployer.matchers.JarExtensionProvider;
 import org.jboss.deployers.spi.structure.ContextInfo;
 import org.jboss.deployers.vfs.plugins.structure.AbstractVFSArchiveStructureDeployer;
+import org.jboss.deployers.vfs.spi.deployer.ArchiveMatcher;
 import org.jboss.deployers.vfs.spi.structure.StructureContext;
 import org.jboss.vfs.VirtualFile;
 
@@ -41,7 +42,7 @@
  * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  * @version $Revision: 1.1 $
  */
-public class JARStructure extends AbstractVFSArchiveStructureDeployer
+public class JARStructure extends AbstractVFSArchiveStructureDeployer implements ArchiveMatcher
 {
    private final Set<String> suffixes = Collections.synchronizedSet(new HashSet<String>());
 
@@ -116,12 +117,28 @@
          suffixes.remove(extension);
    }
 
+   public boolean isArchive(VirtualFile file)
+   {
+      return shouldMount(file);
+   }
+
+   public boolean hasArchiveSuffix(VirtualFile file)
+   {
+      return file != null && hasArchiveSuffix(file.getName());
+   }
+
+   public boolean hasArchiveSuffix(String fileName)
+   {
+      return hasValidSuffix(fileName);
+   }
+
    protected boolean hasValidSuffix(String name)
    {
+      if (name == null)
+         return false;
+
       int idx = name.lastIndexOf('.');
-      if (idx == -1)
-         return false;
-      return suffixes.contains(name.substring(idx).toLowerCase());
+      return (idx != -1) && suffixes.contains(name.substring(idx).toLowerCase());
    }
 
    public boolean doDetermineStructure(StructureContext structureContext) throws DeploymentException

Copied: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/ArchiveMatcher.java (from rev 102273, projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/FileMatcher.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/ArchiveMatcher.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/ArchiveMatcher.java	2010-03-11 13:47:33 UTC (rev 102289)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.deployers.vfs.spi.deployer;
+
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * Matches virtual file to check if it is archive / archive-suffix.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface ArchiveMatcher
+{
+   /**
+    * Check if file param is archive.
+    *
+    * @param file the virtual file
+    * @return true if we have an archive, false otherwise
+    */
+   boolean isArchive(VirtualFile file);
+
+   /**
+    * Does the file have valid archive suffix.
+    *
+    * @param file the virtual file
+    * @return true if the file matches valid archive suffixes
+    */
+   boolean hasArchiveSuffix(VirtualFile file);
+
+   /**
+    * Does the file have valid archive suffix.
+    *
+    * @param fileName the file name
+    * @return true if the file name matches valid archive suffixes
+    */
+   boolean hasArchiveSuffix(String fileName);
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list