[jboss-cvs] JBossAS SVN: r91927 - in projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual: spi and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Aug 3 16:31:38 EDT 2009


Author: jason.greene at jboss.com
Date: 2009-08-03 16:31:38 -0400 (Mon, 03 Aug 2009)
New Revision: 91927

Modified:
   projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/VFS.java
   projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/VirtualFile.java
   projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/spi/RealFileSystem.java
Log:
Pull VFS field out of VirtualFile since it is now a singleton


Modified: projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/VFS.java
===================================================================
--- projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/VFS.java	2009-08-03 19:52:41 UTC (rev 91926)
+++ projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/VFS.java	2009-08-03 20:31:38 UTC (rev 91927)
@@ -70,8 +70,9 @@
    private final ConcurrentMap<VirtualFile, Map<String, Mount>> mounts = new ConcurrentHashMap<VirtualFile, Map<String, Mount>>();
    private final VirtualFile rootVirtualFile;
    private final Mount rootMount;
-   private static VFS instance = new VFS();
 
+   static VFS instance = new VFS();
+
    // todo - LRU VirtualFiles?
    // todo - LRU String intern?
 

Modified: projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/VirtualFile.java
===================================================================
--- projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/VirtualFile.java	2009-08-03 19:52:41 UTC (rev 91926)
+++ projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/VirtualFile.java	2009-08-03 20:31:38 UTC (rev 91927)
@@ -53,7 +53,6 @@
    private static final long serialVersionUID = 1L;
    private final String name;
    private final String lcname;
-   private final VFS vfs;
    private final VirtualFile parent;
    private final int hashCode;
 
@@ -61,7 +60,6 @@
    {
       this.name = name;
       lcname = name.toLowerCase();
-      this.vfs = vfs;
       this.parent = parent;
       int result = parent == null ? vfs.hashCode() : parent.hashCode();
       result = 31 * result + name.hashCode();
@@ -141,7 +139,7 @@
     */
    public long getLastModified() throws IOException
    {
-      final VFS.Mount mount = vfs.getMount(this);
+      final VFS.Mount mount = VFS.instance.getMount(this);
       return mount.getFileSystem().getLastModified(mount.getMountPoint(), this);
    }
 
@@ -153,7 +151,7 @@
     */
    public long getSize() throws IOException
    {
-      final VFS.Mount mount = vfs.getMount(this);
+      final VFS.Mount mount = VFS.instance.getMount(this);
       return mount.getFileSystem().getSize(mount.getMountPoint(), this);
    }
 
@@ -164,7 +162,7 @@
     */
    public boolean exists() throws IOException
    {
-      final VFS.Mount mount = vfs.getMount(this);
+      final VFS.Mount mount = VFS.instance.getMount(this);
       return mount.getFileSystem().exists(mount.getMountPoint(), this);
    }
 
@@ -190,7 +188,7 @@
     */
    public boolean isDirectory() throws IOException
    {
-      final VFS.Mount mount = vfs.getMount(this);
+      final VFS.Mount mount = VFS.instance.getMount(this);
       return mount.getFileSystem().isDirectory(mount.getMountPoint(), this);
    }
 
@@ -202,7 +200,7 @@
     */
    public InputStream openStream() throws IOException
    {
-      final VFS.Mount mount = vfs.getMount(this);
+      final VFS.Mount mount = VFS.instance.getMount(this);
       return mount.getFileSystem().openInputStream(mount.getMountPoint(), this);
    }
 
@@ -214,7 +212,7 @@
     */
    public boolean delete() throws IOException
    {
-      final VFS.Mount mount = vfs.getMount(this);
+      final VFS.Mount mount = VFS.instance.getMount(this);
       return mount.getFileSystem().delete(mount.getMountPoint(), this);
    }
 
@@ -229,7 +227,7 @@
     */
    public File getPhysicalFile() throws IOException
    {
-      final VFS.Mount mount = vfs.getMount(this);
+      final VFS.Mount mount = VFS.instance.getMount(this);
       return mount.getFileSystem().getFile(mount.getMountPoint(), this);
    }
 
@@ -240,7 +238,7 @@
     */
    public VFS getVFS()
    {
-      return vfs;
+      return VFS.instance;
    }
 
    /**
@@ -296,6 +294,7 @@
       if (! isDirectory())
          return Collections.emptyList();
 
+      VFS vfs = VFS.instance;
       final VFS.Mount mount = vfs.getMount(this);
       final Set<String> submounts = vfs.getSubmounts(this);
       final List<String> names = mount.getFileSystem().getDirectoryEntries(mount.getMountPoint(), this);
@@ -411,6 +410,8 @@
       if (path == null)
          throw new IllegalArgumentException("Null path");
 
+      VFS vfs = VFS.instance;
+
       final List<String> pathParts = PathTokenizer.getTokens(path);
       VirtualFile current = this;
       for (String part : pathParts)
@@ -467,7 +468,7 @@
     */
    public String toString()
    {
-      return "Virtual file \"" + getPathName() + "\" for " + vfs;
+      return "Virtual file \"" + getPathName() + "\" for " + VFS.instance;
    }
 
    /**
@@ -488,8 +489,6 @@
          return false;
       if (! name.equals(that.name))
          return false;
-      if (vfs != that.vfs)
-         return false;
       final VirtualFile parent = this.parent;
       if (parent == null)
          return that.parent == null;

Modified: projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/spi/RealFileSystem.java
===================================================================
--- projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/spi/RealFileSystem.java	2009-08-03 19:52:41 UTC (rev 91926)
+++ projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/spi/RealFileSystem.java	2009-08-03 20:31:38 UTC (rev 91927)
@@ -70,7 +70,7 @@
    /** {@inheritDoc} */
    public File getFile(VirtualFile mountPoint, VirtualFile target) throws IOException
    {
-      if (mountPoint == target) {
+      if (mountPoint.equals(target)) {
          return realRoot;
       } else {
          return new File(getFile(mountPoint, target.getParent()), target.getName());




More information about the jboss-cvs-commits mailing list