[jboss-cvs] JBossAS SVN: r76130 - in projects/vfs/trunk/src/main/java/org/jboss/virtual: plugins/context/vfs and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jul 23 09:13:34 EDT 2008
Author: alesj
Date: 2008-07-23 09:13:33 -0400 (Wed, 23 Jul 2008)
New Revision: 76130
Modified:
projects/vfs/trunk/src/main/java/org/jboss/virtual/AssembledDirectory.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledContext.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectoryHandler.java
Log:
[JBVFS-48]; initial fix for Assembled.
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/AssembledDirectory.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/AssembledDirectory.java 2008-07-23 12:16:01 UTC (rev 76129)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/AssembledDirectory.java 2008-07-23 13:13:33 UTC (rev 76130)
@@ -23,10 +23,12 @@
import java.io.IOException;
import java.net.URL;
+import java.net.URISyntaxException;
import java.util.List;
import java.util.regex.Pattern;
import org.jboss.virtual.plugins.context.jar.JarUtils;
+import org.jboss.virtual.plugins.context.vfs.AssembledContext;
import org.jboss.virtual.plugins.context.vfs.AssembledDirectoryHandler;
import org.jboss.virtual.plugins.context.vfs.AssembledFileHandler;
import org.jboss.virtual.plugins.context.vfs.ByteArrayHandler;
@@ -52,6 +54,49 @@
}
/**
+ * Create assembled directory.
+ *
+ * @param name context's name
+ * @param rootName root name
+ * @return new assembled directory instance
+ * @throws IOException for any IO error
+ * @throws URISyntaxException for any URI error
+ */
+ public static AssembledDirectory createAssembledDirectory(String name, String rootName) throws IOException, URISyntaxException
+ {
+ AssembledContext context = new AssembledContext(name, rootName);
+ return context.getRoot().getVirtualFile();
+ }
+
+ /**
+ * Add files recursively from root, using the filter.
+ *
+ * @param root the root
+ * @param recurseFilter the recurse filter
+ * @throws IOException for any error
+ */
+ public void addPath(VirtualFile root, VirtualFileFilter recurseFilter) throws IOException
+ {
+ final VisitorAttributes va = new VisitorAttributes();
+ va.setLeavesOnly(true);
+ va.setRecurseFilter(recurseFilter);
+
+ VirtualFileVisitor visitor = new VirtualFileVisitor()
+ {
+ public VisitorAttributes getAttributes()
+ {
+ return va;
+ }
+
+ public void visit(VirtualFile virtualFile)
+ {
+ mkdirs(virtualFile.getPathName()).addChild(virtualFile);
+ }
+ };
+ root.visit(visitor);
+ }
+
+ /**
* Find the underlying .class file representing this class and create it within this directory, along with
* its packages.
*
@@ -64,6 +109,7 @@
{
if (clazz == null)
throw new IllegalArgumentException("Null clazz");
+
addClass(clazz.getName(), clazz.getClassLoader());
}
@@ -74,7 +120,7 @@
* So, if you added com.acme.Customer class, then a directory structure com/acme would be created
* and an entry in the acme directory would be the .class file.
*
- * @param className
+ * @param className the class name
*/
public void addClass(String className)
{
@@ -88,7 +134,7 @@
* So, if you added com.acme.Customer class, then a directory structure com/acme would be created
* and an entry in the acme directory would be the .class file.
*
- * @param className
+ * @param className the class name
* @param loader ClassLoader to look for class resource
*/
public void addClass(String className, ClassLoader loader)
@@ -137,7 +183,7 @@
}
dir = next;
}
- return (AssembledDirectory) dir.getVirtualFile();
+ return dir.getVirtualFile();
}
/**
@@ -181,6 +227,7 @@
{
if (baseResource == null)
throw new IllegalArgumentException("Null base resource");
+
addResources(baseResource, includes, excludes, Thread.currentThread().getContextClassLoader());
}
@@ -225,7 +272,6 @@
VirtualFileFilter filter = new VirtualFileFilter()
{
-
public boolean accepts(VirtualFile file)
{
boolean matched = false;
@@ -250,7 +296,6 @@
}
return true;
}
-
};
FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filter, va);
@@ -302,7 +347,7 @@
String[] paths = path.split("/");
String[] expressions = expression.split("/");
- int x = 0, p = 0;
+ int x = 0, p;
Pattern pattern = getPattern(expressions[0]);
for (p = 0; p < paths.length && x < expressions.length; p++)
@@ -419,6 +464,7 @@
throw new IllegalArgumentException("Null resource");
if (loader == null)
throw new IllegalArgumentException("Null loader");
+
URL url = loader.getResource(resource);
if (url == null)
throw new RuntimeException("Could not find resource: " + resource);
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledContext.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledContext.java 2008-07-23 12:16:01 UTC (rev 76129)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledContext.java 2008-07-23 13:13:33 UTC (rev 76130)
@@ -21,25 +21,25 @@
*/
package org.jboss.virtual.plugins.context.vfs;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
import org.jboss.virtual.plugins.context.AbstractVFSContext;
-import org.jboss.virtual.spi.VirtualFileHandler;
-import java.net.URISyntaxException;
-import java.net.URI;
-import java.io.IOException;
-
/**
* AssembledContext.
*
* @author Scott.Stark at jboss.org
* @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
* @version $Revision: 1.1 $
*/
public class AssembledContext extends AbstractVFSContext
{
private String name;
/** The root file */
- private final VirtualFileHandler root;
+ private final AssembledDirectoryHandler root;
public AssembledContext(String name, String rootName) throws IOException, URISyntaxException
{
@@ -48,7 +48,7 @@
root = new AssembledDirectoryHandler(this, null, rootName);
}
- public VirtualFileHandler getRoot() throws IOException
+ public AssembledDirectoryHandler getRoot() throws IOException
{
return root;
}
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 2008-07-23 12:16:01 UTC (rev 76129)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectoryHandler.java 2008-07-23 13:13:33 UTC (rev 76130)
@@ -33,7 +33,6 @@
import java.util.List;
import java.util.Map;
-import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.AssembledDirectory;
import org.jboss.virtual.plugins.context.AbstractVirtualFileHandler;
import org.jboss.virtual.plugins.context.StructuredVirtualFileHandler;
@@ -165,7 +164,7 @@
}
@Override
- public VirtualFile getVirtualFile()
+ public AssembledDirectory getVirtualFile()
{
checkClosed();
increment();
More information about the jboss-cvs-commits
mailing list