[jboss-cvs] JBossAS SVN: r83352 - in projects/jboss-deployers/trunk: deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jan 23 10:06:38 EST 2009


Author: alesj
Date: 2009-01-23 10:06:38 -0500 (Fri, 23 Jan 2009)
New Revision: 83352

Modified:
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/VFSDeploymentContext.java
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/VFSDeploymentUnit.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/InMemoryClassesDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/UrlIntegrationDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSDeploymentContext.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSDeploymentUnit.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/validate/support/MyVirtualFile.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/parsing/test/DeployersAltDDTestCase.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/file/test/FileMatcherTestCase.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structurebuilder/test/VFSStructureBuilderUnitTestCase.java
   projects/jboss-deployers/trunk/pom.xml
Log:
[JBDEPLOY-151, JBDEPLOY-152, JBDEPLOY-153];
Impl cleanup on VFSDDeploymentContext,
add/remove metadata locations,
make metadata locations/classpath unmodifiable.


Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/InMemoryClassesDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/InMemoryClassesDeployer.java	2009-01-23 15:01:07 UTC (rev 83351)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/InMemoryClassesDeployer.java	2009-01-23 15:06:38 UTC (rev 83352)
@@ -22,7 +22,6 @@
 package org.jboss.deployers.vfs.plugins.classloader;
 
 import java.net.URL;
-import java.util.List;
 
 import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
 import org.jboss.deployers.spi.DeploymentException;
@@ -100,12 +99,7 @@
          VirtualFile classes = unit.removeAttachment(DYNAMIC_CLASS_KEY, VirtualFile.class);
          if (classes != null)
          {
-            List<VirtualFile> classPath = unit.getClassPath();
-            if (classPath != null)
-            {
-               classPath.remove(classes);
-               unit.setClassPath(classPath);
-            }
+            unit.removeClassPath(classes);
          }
       }
       finally

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/UrlIntegrationDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/UrlIntegrationDeployer.java	2009-01-23 15:01:07 UTC (rev 83351)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/UrlIntegrationDeployer.java	2009-01-23 15:06:38 UTC (rev 83352)
@@ -123,7 +123,7 @@
          {
             for (URL integrationURL : integrationURLs)
             {
-               VirtualFile integration = VFS.getCachedFile(integrationURL);
+               VirtualFile integration = VFS.getRoot(integrationURL);
                unit.addClassPath(integration);
                added.add(integration);
             }
@@ -150,7 +150,7 @@
          {
             try
             {
-               VirtualFile integration = VFS.getCachedFile(integrationURL);
+               VirtualFile integration = VFS.getRoot(integrationURL);
                classPath.remove(integration);
             }
             catch (Throwable t)

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSDeploymentContext.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSDeploymentContext.java	2009-01-23 15:01:07 UTC (rev 83351)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSDeploymentContext.java	2009-01-23 15:06:38 UTC (rev 83352)
@@ -25,9 +25,9 @@
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-import java.util.Arrays;
 
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.structure.spi.helpers.AbstractDeploymentContext;
@@ -152,12 +152,26 @@
       }
    }
 
+   /**
+    * Get mutable metadata locations.
+    *
+    * @return the mutable metadata locations
+    */
+   protected List<VirtualFile> getMutableMetaDataLocations()
+   {
+      return metaDataLocations;
+   }
+
    public List<VirtualFile> getMetaDataLocations()
    {
-      if (metaDataLocations == null)
+      if (metaDataLocations == null || metaDataLocations.isEmpty())
+      {
          return Collections.emptyList();
-
-      return metaDataLocations;
+      }
+      else
+      {
+         return Collections.unmodifiableList(metaDataLocations);
+      }
    }
 
    public void setMetaDataLocations(List<VirtualFile> locations)
@@ -272,16 +286,81 @@
       }
    }
 
+   public void prependMetaDataFile(VirtualFile... files)
+   {
+      if (files == null)
+         throw new IllegalArgumentException("Null files");
+
+      List<VirtualFile> metadataLocations = getMutableMetaDataLocations();
+      if (metadataLocations == null)
+         metadataLocations = new ArrayList<VirtualFile>();
+
+      for (int i = files.length-1; i >= 0; --i)
+      {
+         VirtualFile file = files[i];
+         if (file == null)
+            throw new IllegalArgumentException("Null virtual file in " + Arrays.toString(files));
+         metadataLocations.add(0, file);
+      }
+      setMetaDataLocations(metadataLocations);
+   }
+
+   public void appendMetaDataFile(VirtualFile... files)
+   {
+      if (files == null)
+         throw new IllegalArgumentException("Null files");
+
+      List<VirtualFile> metaDataLocations = getMutableMetaDataLocations();
+      if (metaDataLocations == null)
+         metaDataLocations = new ArrayList<VirtualFile>();
+
+      for (VirtualFile file : files)
+      {
+         if (file == null)
+            throw new IllegalArgumentException("Null virtual file in " + Arrays.toString(files));
+         metaDataLocations.add(file);
+      }
+      setMetaDataLocations(metaDataLocations);
+   }
+
+   public void removeMetaDataFile(VirtualFile... files)
+   {
+      if (files == null || files.length == 0)
+         return;
+
+      for (VirtualFile file : files)
+      {
+         metaDataLocations.remove(file);
+      }
+   }
+
    public VirtualFile getFile(String name)
    {
       return getResourceLoader().getFile(name);
    }
 
-   public List<VirtualFile> getClassPath()
+   /**
+    * Get mutable classpath.
+    *
+    * @return the mutable classpath
+    */
+   protected List<VirtualFile> getMutableClassPath()
    {
       return classPath;
    }
 
+   public List<VirtualFile> getClassPath()
+   {
+      if (classPath == null || classPath.isEmpty())
+      {
+         return Collections.emptyList();
+      }
+      else
+      {
+         return Collections.unmodifiableList(classPath);
+      }
+   }
+
    public void setClassPath(List<VirtualFile> paths)
    {
       this.classPath = paths;
@@ -294,7 +373,7 @@
       if (files == null)
          throw new IllegalArgumentException("Null files");
 
-      List<VirtualFile> classPath = getClassPath();
+      List<VirtualFile> classPath = getMutableClassPath();
       if (classPath == null)
          classPath = new ArrayList<VirtualFile>();
 
@@ -312,7 +391,7 @@
       if (files == null)
          throw new IllegalArgumentException("Null files");
 
-      List<VirtualFile> classPath = getClassPath();
+      List<VirtualFile> classPath = getMutableClassPath();
       if (classPath == null)
          classPath = new ArrayList<VirtualFile>();
 
@@ -331,7 +410,7 @@
       if (files == null)
          throw new IllegalArgumentException("Null files");
 
-      List<VirtualFile> classPath = getClassPath();
+      List<VirtualFile> classPath = getMutableClassPath();
       if (classPath == null)
          classPath = new ArrayList<VirtualFile>();
 
@@ -350,7 +429,7 @@
       if (files == null)
          throw new IllegalArgumentException("Null files");
 
-      List<VirtualFile> classPath = getClassPath();
+      List<VirtualFile> classPath = getMutableClassPath();
       if (classPath == null)
          classPath = new ArrayList<VirtualFile>();
 
@@ -363,6 +442,17 @@
       setClassPath(classPath);
    }
 
+   public void removeClassPath(VirtualFile... files)
+   {
+      if (files == null || files.length == 0)
+         return;
+
+      for (VirtualFile file : files)
+      {
+         classPath.remove(file);
+      }
+   }
+
    @Override
    public VFSDeploymentContext getTopLevel()
    {
@@ -384,6 +474,19 @@
       return new AbstractVFSDeploymentUnit(this);
    }
 
+   @Override
+   public void cleanup()
+   {
+      try
+      {
+         root.cleanup();
+      }
+      finally
+      {
+         super.cleanup();
+      }
+   }
+   
    @SuppressWarnings("unchecked")
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
    {

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSDeploymentUnit.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSDeploymentUnit.java	2009-01-23 15:01:07 UTC (rev 83351)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSDeploymentUnit.java	2009-01-23 15:06:38 UTC (rev 83352)
@@ -33,6 +33,7 @@
  * AbstractVFSDeploymentUnit.
  * 
  * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
  * @version $Revision: 1.1 $
  */
 public class AbstractVFSDeploymentUnit extends AbstractDeploymentUnit implements VFSDeploymentUnit
@@ -68,6 +69,21 @@
       return getDeploymentContext().getMetaDataFiles(name, suffix);
    }
 
+   public void prependMetaDataFile(VirtualFile... files)
+   {
+      getDeploymentContext().prependMetaDataFile(files);
+   }
+
+   public void appendMetaDataFile(VirtualFile... files)
+   {
+      getDeploymentContext().appendMetaDataFile(files);
+   }
+
+   public void removeMetaDataFile(VirtualFile... files)
+   {
+      getDeploymentContext().removeMetaDataFile(files);
+   }
+
    @Override
    public VFSDeploymentResourceLoader getResourceLoader()
    {
@@ -124,6 +140,11 @@
       getDeploymentContext().appendClassPath(files);
    }
 
+   public void removeClassPath(VirtualFile... files)
+   {
+      getDeploymentContext().removeClassPath(files);
+   }
+
    @Override
    public VFSDeploymentUnit getParent()
    {

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/validate/support/MyVirtualFile.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/validate/support/MyVirtualFile.java	2009-01-23 15:01:07 UTC (rev 83351)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/validate/support/MyVirtualFile.java	2009-01-23 15:06:38 UTC (rev 83352)
@@ -186,6 +186,10 @@
          {
             return null;
          }
+
+         public void cleanup()
+         {
+         }
       };
    }
 }

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/parsing/test/DeployersAltDDTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/parsing/test/DeployersAltDDTestCase.java	2009-01-23 15:01:07 UTC (rev 83351)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/parsing/test/DeployersAltDDTestCase.java	2009-01-23 15:06:38 UTC (rev 83352)
@@ -205,6 +205,10 @@
          {
             return null;
          }
+
+         public void cleanup()
+         {
+         }
       });
       return altDD;
    }

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/file/test/FileMatcherTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/file/test/FileMatcherTestCase.java	2009-01-23 15:01:07 UTC (rev 83351)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/file/test/FileMatcherTestCase.java	2009-01-23 15:06:38 UTC (rev 83352)
@@ -235,6 +235,10 @@
             {
                return null;
             }
+
+            public void cleanup()
+            {
+            }
          };
       }
 

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structurebuilder/test/VFSStructureBuilderUnitTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structurebuilder/test/VFSStructureBuilderUnitTestCase.java	2009-01-23 15:01:07 UTC (rev 83351)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structurebuilder/test/VFSStructureBuilderUnitTestCase.java	2009-01-23 15:06:38 UTC (rev 83352)
@@ -127,7 +127,7 @@
       List<VirtualFile> classPath = context.getClassPath();
       
       if (classPathEntries == null)
-         assertNull(classPath);
+         assertEmpty(classPath);
       else
       {
          int cpeSize = classPathEntries.size();

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/VFSDeploymentContext.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/VFSDeploymentContext.java	2009-01-23 15:01:07 UTC (rev 83351)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/VFSDeploymentContext.java	2009-01-23 15:06:38 UTC (rev 83352)
@@ -30,6 +30,7 @@
  * VFSDeploymentContext.
  * 
  * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
  * @version $Revision: 1.1 $
  */
 public interface VFSDeploymentContext extends DeploymentContext
@@ -82,6 +83,26 @@
    List<VirtualFile> getMetaDataFiles(String name, String suffix);
 
    /**
+    * Prepend metadata file locations.
+    * 
+    * @param files the files
+    */
+   void prependMetaDataFile(VirtualFile... files);
+
+   /**
+    * Append metadata file locations.
+    *
+    * @param files the files
+    */
+   void appendMetaDataFile(VirtualFile... files);
+
+   /**
+    * Remove metadata file locations.
+    * @param files the files
+    */
+   void removeMetaDataFile(VirtualFile... files);
+
+   /**
     * Gets a file from this deployment
     * 
     * @param name the name to exactly match
@@ -133,6 +154,13 @@
    void appendClassPath(List<VirtualFile> files);
 
    /**
+    * Remove classpath files.
+    *
+    * @param files the files
+    */
+   void removeClassPath(VirtualFile... files);
+
+   /**
     * Get the top level deployment context
     * 
     * @return the top level deployment context

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/VFSDeploymentUnit.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/VFSDeploymentUnit.java	2009-01-23 15:01:07 UTC (rev 83351)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/VFSDeploymentUnit.java	2009-01-23 15:06:38 UTC (rev 83352)
@@ -30,6 +30,7 @@
  * VFSDeploymentUnit.
  * 
  * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
  * @version $Revision: 1.1 $
  */
 public interface VFSDeploymentUnit extends DeploymentUnit
@@ -55,6 +56,26 @@
    List<VirtualFile> getMetaDataFiles(String name, String suffix);
    
    /**
+    * Prepend metadata file locations.
+    *
+    * @param files the files
+    */
+   void prependMetaDataFile(VirtualFile... files);
+
+   /**
+    * Append metadata file locations.
+    *
+    * @param files the files
+    */
+   void appendMetaDataFile(VirtualFile... files);
+
+   /**
+    * Remove metadata file locations.
+    * @param files the files
+    */
+   void removeMetaDataFile(VirtualFile... files);
+
+   /**
     * Get a resource loader
     * 
     * @return the resource loader
@@ -87,7 +108,9 @@
     * Set the classpath
     * 
     * @param classPath the classpath
+    * @deprecated user view should not have setters
     */
+   @Deprecated
    void setClassPath(List<VirtualFile> classPath);
    
    /**
@@ -131,8 +154,15 @@
     * @param files a virtual file
     */
    void addClassPath(List<VirtualFile> files);
-   
+
    /**
+    * Remove classpath files.
+    *
+    * @param files the files
+    */
+   void removeClassPath(VirtualFile... files);
+
+   /**
     * Get the top leve deployment unit
     * 
     * @return the top level deployment unit

Modified: projects/jboss-deployers/trunk/pom.xml
===================================================================
--- projects/jboss-deployers/trunk/pom.xml	2009-01-23 15:01:07 UTC (rev 83351)
+++ projects/jboss-deployers/trunk/pom.xml	2009-01-23 15:06:38 UTC (rev 83352)
@@ -31,7 +31,7 @@
     <version.jboss.logging.log4j>2.0.5.GA</version.jboss.logging.log4j>
     <version.jbossxb>2.0.0.GA</version.jbossxb>
     <version.jboss.aop>2.0.0.SP1</version.jboss.aop>
-    <version.jboss.vfs>2.0.0.GA</version.jboss.vfs>
+    <version.jboss.vfs>2.2.0-SNAPSHOT</version.jboss.vfs>
     <version.org.jboss.test>1.1.1.GA</version.org.jboss.test>
     <version.junit>4.4</version.junit>
     <version.javassist>3.9.0.GA</version.javassist>




More information about the jboss-cvs-commits mailing list