[jboss-cvs] JBossAS SVN: r66213 - in projects/vfs/trunk/src/main/java/org/jboss/virtual: protocol/vfsmemory and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 17 06:27:43 EDT 2007
Author: alesj
Date: 2007-10-17 06:27:42 -0400 (Wed, 17 Oct 2007)
New Revision: 66213
Modified:
projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContext.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextFactory.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextHandler.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/protocol/vfsmemory/Handler.java
Log:
Simple clean-up.
Fixing non-Serializable on MemoryContext.
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContext.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContext.java 2007-10-17 09:14:22 UTC (rev 66212)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContext.java 2007-10-17 10:27:42 UTC (rev 66213)
@@ -22,27 +22,27 @@
package org.jboss.virtual.plugins.context.memory;
-import java.io.File;
import java.io.IOException;
+import java.io.Serializable;
import java.net.MalformedURLException;
-import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
-import org.jboss.virtual.VFSUtils;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.plugins.context.AbstractVFSContext;
import org.jboss.virtual.plugins.vfs.helpers.PathTokenizer;
import org.jboss.virtual.spi.VirtualFileHandler;
/**
- *
+ * Virtual memory context.
+ *
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
-public class MemoryContext extends AbstractVFSContext
+public class MemoryContext extends AbstractVFSContext implements Serializable
{
private static final long serialVersionUID = 1L;
+
/** The root file */
private final MemoryContextHandler root;
@@ -56,7 +56,6 @@
rootFile = root.getVirtualFile();
}
-
public VirtualFileHandler getRoot() throws IOException
{
return root;
@@ -71,9 +70,6 @@
{
try
{
- URI uri = VFSUtils.toURI(url);
-
-
String[] tokens = PathTokenizer.getTokens(url.getPath());
if (tokens == null || tokens.length == 0)
{
@@ -107,7 +103,7 @@
}
URL localUrl = new URL(path.toString());
- if (current.contents != null)
+ if (current.getContents() != null)
{
throw new IllegalStateException("Cannot add a child to " + current + " it already has contents");
}
@@ -121,10 +117,5 @@
{
throw new RuntimeException(e);
}
- catch (URISyntaxException e)
- {
- throw new RuntimeException(e);
- }
- }
-
+ }
}
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextFactory.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextFactory.java 2007-10-17 09:14:22 UTC (rev 66212)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextFactory.java 2007-10-17 10:27:42 UTC (rev 66213)
@@ -27,6 +27,7 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.Map;
import org.jboss.virtual.spi.VFSContext;
import org.jboss.virtual.spi.VFSContextFactory;
@@ -44,11 +45,10 @@
private static final String[] PROTOCOLS = {"vfsmemory"};
private static MemoryContextFactory instance = new MemoryContextFactory();
- private ConcurrentHashMap<String, MemoryContext> registry = new ConcurrentHashMap<String, MemoryContext>();
+ private Map<String, MemoryContext> registry = new ConcurrentHashMap<String, MemoryContext>();
private MemoryContextFactory()
{
-
}
/**
@@ -124,7 +124,7 @@
/**
* Creates a 'directory' within the context determined by the url host part
- * @param URL url The url of the directory we want tot create
+ * @param url The url of the directory we want tot create
* @return The created directory
* @throws IllegalArgumentException if there is no root matching the host part of the url
*/
@@ -142,8 +142,8 @@
/**
* Creates a 'file' within the context determined by the url host part
- * @param URL url The url of the directory we want tot create
- * @param byte[] contents The contents of the file
+ * @param url The url of the directory we want tot create
+ * @param contents The contents of the file
* @return The created file
* @throws IllegalArgumentException if there is no root matching the host part of the url
*/
@@ -161,7 +161,7 @@
/**
* Deletes a root MemoryContext
- * @param The url of the root context we want to delete
+ * @param url of the root context we want to delete
* @return true if we deleted a root MemoryContext, false otherwise
* @throws IllegalArgumentException If the url parameter contains a path
*/
@@ -178,7 +178,7 @@
/**
* Deletes a 'file' or a 'directory'
- * @param The url of the 'file' or 'directory' we want to delete
+ * @param url of the 'file' or 'directory' we want to delete
* @return true if we deleted a 'file' or 'directory', false otherwise
*/
public boolean delete(URL url)
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextHandler.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextHandler.java 2007-10-17 09:14:22 UTC (rev 66212)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextHandler.java 2007-10-17 10:27:42 UTC (rev 66213)
@@ -39,7 +39,8 @@
/**
- *
+ * Virtual memory context handler.
+ *
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
@@ -48,10 +49,9 @@
/** serialVersionUID */
private static final long serialVersionUID = 1L;
- private transient List<VirtualFileHandler> entryChildren = Collections.EMPTY_LIST;
- private transient Map<String, MemoryContextHandler> entryMap = Collections.EMPTY_MAP;
- byte[] contents;
-
+ private transient List<VirtualFileHandler> entryChildren = Collections.emptyList();
+ private transient Map<String, MemoryContextHandler> entryMap = Collections.emptyMap();
+ private byte[] contents;
public MemoryContextHandler(VFSContext context, VirtualFileHandler parent, URL url, String name)
{
@@ -121,6 +121,11 @@
return true;
}
+ byte[] getContents()
+ {
+ return contents;
+ }
+
public void setContents(byte[] contents)
{
if (entryChildren.size() > 0)
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/protocol/vfsmemory/Handler.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/protocol/vfsmemory/Handler.java 2007-10-17 09:14:22 UTC (rev 66212)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/protocol/vfsmemory/Handler.java 2007-10-17 10:27:42 UTC (rev 66213)
@@ -51,6 +51,7 @@
return new VirtualFileURLConnection(u, vf);
}
+
public static void main(String[] args) throws Exception
{
System.setProperty("java.protocol.handler.pkgs", "org.jboss.virtual.protocol");
@@ -82,6 +83,5 @@
System.out.print((char)is2.read());
}
is.close();
-
}
}
More information about the jboss-cvs-commits
mailing list