[jboss-cvs] JBossAS SVN: r66625 - in projects/vfs/trunk/src: main/java/org/jboss/virtual/plugins/context/jar and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Oct 31 14:34:06 EDT 2007


Author: alesj
Date: 2007-10-31 14:34:06 -0400 (Wed, 31 Oct 2007)
New Revision: 66625

Added:
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/URLConnectionUnitTestCase.java
Modified:
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/file/FileHandler.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/file/LinkHandler.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/SynthenticDirEntryHandler.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectory.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectoryHandler.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledFileHandler.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java
Log:
Simple clean-up.
Overridding getContent in VFURLConnection.
Still todo on tests.

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/file/FileHandler.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/file/FileHandler.java	2007-10-31 18:22:35 UTC (rev 66624)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/file/FileHandler.java	2007-10-31 18:34:06 UTC (rev 66625)
@@ -145,7 +145,7 @@
       if (files == null)
          throw new IOException("Error listing files: " + parent.getCanonicalPath());
       // We need to validate the files list due to jdk bug 6192331
-      ArrayList<File> tmpFiles = new ArrayList<File>();
+      List<File> tmpFiles = new ArrayList<File>();
       for (File file : files)
       {
          if( file.canRead() == true )
@@ -168,7 +168,7 @@
       {
          try
          {
-            VirtualFileHandler handler = null;
+            VirtualFileHandler handler;
             handler = oldCache.get(file.getName());
             // if underlying file has been modified then create a new handler instead of using the cached one
             if (handler != null && handler.hasBeenModified())

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/file/LinkHandler.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/file/LinkHandler.java	2007-10-31 18:22:35 UTC (rev 66624)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/file/LinkHandler.java	2007-10-31 18:34:06 UTC (rev 66625)
@@ -54,14 +54,15 @@
    private static final long serialVersionUID = 1;
    /** The link information */
    private List<LinkInfo> links;
-   private HashMap<String, VirtualFileHandler> linkTargets =
-      new HashMap<String, VirtualFileHandler>(3);
+   /** The link targets */
+   private HashMap<String, VirtualFileHandler> linkTargets = new HashMap<String, VirtualFileHandler>(3);
 
    class ParentOfLink extends AbstractURLHandler
       implements StructuredVirtualFileHandler
    {
       private static final long serialVersionUID = 1;
-      private HashMap<String, VirtualFileHandler> children = 
+
+      private HashMap<String, VirtualFileHandler> children =
          new HashMap<String, VirtualFileHandler>(1);
 
       public ParentOfLink(VFSContext context, VirtualFileHandler parent, URL url, String name)
@@ -76,10 +77,12 @@
             throw new RuntimeException(e);
          }
       }
+
       void addChild(VirtualFileHandler child, String name)
       {
          children.put(name, child);
       }
+
       public VirtualFileHandler findChild(String path) throws IOException
       {
          return structuredFindChild(path);
@@ -99,8 +102,6 @@
       {
          return false;
       }
-
-
    }
 
    /**
@@ -196,6 +197,7 @@
    {
       return structuredFindChild(path);
    }
+
    public VirtualFileHandler createChildHandler(String name) throws IOException
    {
       VirtualFileHandler handler = linkTargets.get(name);
@@ -223,5 +225,4 @@
       // TODO: if the factory caches contexts the root handler may not point to the link
       return new DelegatingHandler(this.getVFSContext(), parent, name, rootHandler);
    }
-
 }

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java	2007-10-31 18:22:35 UTC (rev 66624)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java	2007-10-31 18:34:06 UTC (rev 66625)
@@ -337,7 +337,7 @@
 
    public VirtualFileHandler findChild(String path) throws IOException
    {
-      return super.structuredFindChild(path);
+      return structuredFindChild(path);
    }
 
    public VirtualFileHandler createChildHandler(String name) throws IOException

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java	2007-10-31 18:22:35 UTC (rev 66624)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java	2007-10-31 18:34:06 UTC (rev 66625)
@@ -168,7 +168,7 @@
 
    public VirtualFileHandler findChild(String path) throws IOException
    {
-      return super.structuredFindChild(path);
+      return structuredFindChild(path);
    }
 
    @Override

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/SynthenticDirEntryHandler.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/SynthenticDirEntryHandler.java	2007-10-31 18:22:35 UTC (rev 66624)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/SynthenticDirEntryHandler.java	2007-10-31 18:34:06 UTC (rev 66625)
@@ -152,7 +152,7 @@
 
    public VirtualFileHandler findChild(String path) throws IOException
    {
-      return super.structuredFindChild(path);
+      return structuredFindChild(path);
    }
 
    /**

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectory.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectory.java	2007-10-31 18:22:35 UTC (rev 66624)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectory.java	2007-10-31 18:34:06 UTC (rev 66625)
@@ -21,6 +21,11 @@
 */
 package org.jboss.virtual.plugins.context.vfs;
 
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+import java.util.regex.Pattern;
+
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
 import org.jboss.virtual.VirtualFileFilter;
@@ -30,11 +35,6 @@
 import org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter;
 import org.jboss.virtual.spi.VirtualFileHandler;
 
-import java.io.IOException;
-import java.net.URL;
-import java.util.regex.Pattern;
-import java.util.List;
-
 /**
  * Extension of VirtualFile that represents a virtual directory that can be composed of arbitrary files and resources
  * spread throughout the file system or embedded in jar files.
@@ -122,7 +122,7 @@
             {
                throw new RuntimeException(e);
             }
-            dir.addChld(next);
+            dir.addChild(next);
          }
          dir = next;
       }
@@ -312,7 +312,7 @@
     */
    public VirtualFile addChild(VirtualFile vf)
    {
-      return directory.addChld(vf.getHandler()).getVirtualFile();
+      return directory.addChild(vf.getHandler()).getVirtualFile();
    }
 
    /**
@@ -327,7 +327,7 @@
       try
       {
          AssembledFileHandler handler = new AssembledFileHandler((AssembledContext) directory.getVFSContext(), directory, newName, vf.getHandler());
-         directory.addChld(handler);
+         directory.addChild(handler);
          return handler.getVirtualFile();
       }
       catch (IOException e)
@@ -442,7 +442,7 @@
       {
          throw new RuntimeException(e);
       }
-      directory.addChld(handler);
+      directory.addChild(handler);
       return handler.getVirtualFile();
    }
 
@@ -458,7 +458,7 @@
       try
       {
          handler = new AssembledDirectoryHandler((AssembledContext) directory.getVFSContext(), directory, name);
-         directory.addChld(handler);
+         directory.addChild(handler);
       }
       catch (IOException e)
       {

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectoryHandler.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectoryHandler.java	2007-10-31 18:22:35 UTC (rev 66624)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectoryHandler.java	2007-10-31 18:34:06 UTC (rev 66625)
@@ -21,23 +21,24 @@
 */
 package org.jboss.virtual.plugins.context.vfs;
 
-import org.jboss.virtual.plugins.context.AbstractVirtualFileHandler;
-import org.jboss.virtual.plugins.context.StructuredVirtualFileHandler;
-import org.jboss.virtual.spi.VirtualFileHandler;
-import org.jboss.virtual.VirtualFile;
-
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.net.MalformedURLException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
 import java.util.ArrayList;
-import java.util.Map;
 import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.plugins.context.AbstractVirtualFileHandler;
+import org.jboss.virtual.plugins.context.StructuredVirtualFileHandler;
+import org.jboss.virtual.spi.VirtualFileHandler;
+
 /**
+ * The assembled directory handler.
  *
  * @author <a href="bill at jboss.com">Bill Burke</a>
  * @version $Revision: 1.1 $
@@ -49,7 +50,6 @@
    private List<VirtualFileHandler> children = new ArrayList<VirtualFileHandler>();
    private Map<String, VirtualFileHandler> childrenMap = new HashMap<String, VirtualFileHandler>();
 
-
    public AssembledDirectoryHandler(AssembledContext context, AssembledDirectoryHandler parent, String name) throws IOException
    {
       super(context, parent, name);
@@ -58,7 +58,7 @@
       vfsUrl = new URL("vfs", context.getName(), -1, path, new AssembledUrlStreamHandler(context));
    }
 
-   public VirtualFileHandler addChld(VirtualFileHandler handler)
+   public VirtualFileHandler addChild(VirtualFileHandler handler)
    {
       if (!handler.getClass().isAnnotationPresent(Assembled.class))
       {
@@ -122,7 +122,6 @@
       return children;
    }
 
-
    public VirtualFileHandler createChildHandler(String name) throws IOException
    {
       VirtualFileHandler handler = childrenMap.get(name);
@@ -135,7 +134,6 @@
       return structuredFindChild(path);
    }
 
-
    @Override
    public VirtualFile getVirtualFile()
    {

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledFileHandler.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledFileHandler.java	2007-10-31 18:22:35 UTC (rev 66624)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledFileHandler.java	2007-10-31 18:34:06 UTC (rev 66625)
@@ -21,18 +21,19 @@
 */
 package org.jboss.virtual.plugins.context.vfs;
 
-import org.jboss.virtual.plugins.context.AbstractVirtualFileHandler;
-import org.jboss.virtual.spi.VirtualFileHandler;
-
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URL;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URI;
+import java.net.URL;
 import java.util.List;
 
+import org.jboss.virtual.plugins.context.AbstractVirtualFileHandler;
+import org.jboss.virtual.spi.VirtualFileHandler;
+
 /**
+ * The assembled file handler.
  *
  * @author <a href="bill at jboss.com">Bill Burke</a>
  * @version $Revision: 1.1 $
@@ -50,7 +51,6 @@
 
    }
 
-
    public List<VirtualFileHandler> getChildren(boolean ignoreErrors) throws IOException
    {
       throw new IOException("File cannot have children: " + this);

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java	2007-10-31 18:22:35 UTC (rev 66624)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java	2007-10-31 18:34:06 UTC (rev 66625)
@@ -21,17 +21,17 @@
 */
 package org.jboss.virtual.plugins.vfs;
 
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VFS;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.net.URLConnection;
-import java.util.Map;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Map;
 
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
 /**
  * Implements basic URLConnection for a VirtualFile
  *
@@ -46,7 +46,6 @@
    protected URL vfsurl;
    protected String relativePath;
 
-
    public VirtualFileURLConnection(URL url, URL vfsurl, String relativePath)
    {
       super(url);
@@ -64,6 +63,11 @@
    {
    }
 
+   public Object getContent() throws IOException
+   {
+      return getVirtualFile();
+   }
+
    public static VirtualFile resolveCachedVirtualFile(URL vfsurl, String relativePath) throws IOException
    {
       VFS vfs = urlCache.get(vfsurl);
@@ -84,7 +88,6 @@
          }
       }
       return vfs.findChild(relativePath);
-
    }
 
    public static VirtualFile resolveVirtualFile(URL vfsurl, String relativePath) throws IOException
@@ -109,7 +112,6 @@
       return file;
    }
 
-
    public InputStream getInputStream() throws IOException
    {
       return getVirtualFile().openStream();

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java	2007-10-31 18:22:35 UTC (rev 66624)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java	2007-10-31 18:34:06 UTC (rev 66625)
@@ -84,7 +84,7 @@
       if (tokens == null)
          throw new IllegalArgumentException("Null tokens");
       if (i < 0 || i >= tokens.length)
-         throw new IllegalArgumentException("i is not in the range of tokens: 0" + (tokens.length-1));
+         throw new IllegalArgumentException("i is not in the range of tokens: 0-" + (tokens.length-1));
       
       if (i == tokens.length-1)
          return tokens[tokens.length-1];

Added: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/URLConnectionUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/URLConnectionUnitTestCase.java	                        (rev 0)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/URLConnectionUnitTestCase.java	2007-10-31 18:34:06 UTC (rev 66625)
@@ -0,0 +1,40 @@
+/*
+* 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.test.virtual.test;
+
+import junit.framework.TestCase;
+
+/**
+ * Basic tests of URL connection
+ *
+ * @author ales.jutin at jboss.org
+ */
+public class URLConnectionUnitTestCase extends TestCase
+{
+   /**
+    * Test url content
+    * @throws Exception for any error
+    */
+   public void testFileURLs() throws Exception
+   {
+   }
+}

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java	2007-10-31 18:22:35 UTC (rev 66624)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java	2007-10-31 18:34:06 UTC (rev 66625)
@@ -57,6 +57,8 @@
       suite.addTest(JARVFSContextUnitTestCase.suite());
       suite.addTest(JARVirtualFileHandlerUnitTestCase.suite());
       suite.addTest(new TestSuite(AssembledContextTest.class));
+      suite.addTest(new TestSuite(MemoryTestCase.class));
+      suite.addTest(new TestSuite(URLConnectionUnitTestCase.class));
 
       return suite;
    }




More information about the jboss-cvs-commits mailing list