[jboss-cvs] JBossAS SVN: r102127 - projects/metadata/common/trunk/src/main/java/org/jboss/metadata/serviceref.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 9 07:25:25 EST 2010


Author: alessio.soldano at jboss.com
Date: 2010-03-09 07:25:24 -0500 (Tue, 09 Mar 2010)
New Revision: 102127

Modified:
   projects/metadata/common/trunk/src/main/java/org/jboss/metadata/serviceref/VirtualFileAdaptor.java
Log:
[JBWS-2948] Fixing VFSAdaptorUnitTestCase failure (test just moved from metadata-ejb, see JBMETA-266)


Modified: projects/metadata/common/trunk/src/main/java/org/jboss/metadata/serviceref/VirtualFileAdaptor.java
===================================================================
--- projects/metadata/common/trunk/src/main/java/org/jboss/metadata/serviceref/VirtualFileAdaptor.java	2010-03-09 12:00:59 UTC (rev 102126)
+++ projects/metadata/common/trunk/src/main/java/org/jboss/metadata/serviceref/VirtualFileAdaptor.java	2010-03-09 12:25:24 UTC (rev 102127)
@@ -53,17 +53,19 @@
  */
 public class VirtualFileAdaptor implements WritableUnifiedVirtualFile
 {
-   private static final long serialVersionUID = -4509594124653184347L;
+   private static final long serialVersionUID = -4509594124653184348L;
 
    private static final ObjectStreamField[] serialPersistentFields =
    {
       new ObjectStreamField("rootUrl", URL.class),
       new ObjectStreamField("path", String.class),
+      new ObjectStreamField("requiresMount", boolean.class)
    };
 
    /** Minimal info to get full vfs file structure */
    private URL rootUrl;
    private String path;
+   private boolean requiresMount;
    /** The virtual file */
    private transient VirtualFile file;
 
@@ -74,6 +76,11 @@
 
    public VirtualFileAdaptor(URL rootUrl, String path)
    {
+      this(rootUrl, path, false);
+   }
+
+   protected VirtualFileAdaptor(URL rootUrl, String path, boolean requiresMount)
+   {
       if (rootUrl == null)
          throw new IllegalArgumentException("Null root url");
       if (path == null)
@@ -81,6 +88,7 @@
 
       this.rootUrl = rootUrl;
       this.path = path;
+      this.requiresMount = requiresMount;
    }
 
    /**
@@ -109,7 +117,7 @@
          {
             throw new IOException("VirtualFile " + file + " does not exist");
          }
-         else if (root.getPathName().equals(root.getPhysicalFile().getAbsolutePath()) && file.getPathName().equals(file.getPhysicalFile().getAbsolutePath()))
+         else if (requiresMount && !isMounted(root, file))
          {
             throw new IOException("VirtualFile " + file + " is not mounted");
          }
@@ -117,6 +125,11 @@
       return file;
    }
    
+   private static boolean isMounted(VirtualFile root, VirtualFile child) throws IOException
+   {
+      return !(root.getPathName().equals(root.getPhysicalFile().getAbsolutePath()) && child.getPathName().equals(child.getPhysicalFile().getAbsolutePath()));
+   }
+   
    public UnifiedVirtualFile findChild(String child) throws IOException
    {
       final VirtualFile virtualFile = getFile();   
@@ -191,6 +204,11 @@
       ObjectOutputStream.PutField fields = out.putFields();
       fields.put("rootUrl", url);
       fields.put("path", pathName);
+      
+      VirtualFile newRoot = VFS.getChild(url);
+      VirtualFile newChild = newRoot.getChild(pathName);
+      fields.put("requiresMount", isMounted(newRoot, newChild));
+            
       out.writeFields();
    }
 
@@ -199,6 +217,7 @@
       ObjectInputStream.GetField fields = in.readFields();
       rootUrl = (URL) fields.get("rootUrl", null);
       path = (String) fields.get("path", null);
+      requiresMount = fields.get("requiresMount", false);
    }
 
    public List<UnifiedVirtualFile> getChildren() throws IOException




More information about the jboss-cvs-commits mailing list