[jboss-cvs] JBossAS SVN: r99359 - in projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs: util/automount and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 13 16:10:34 EST 2010
Author: johnbailey
Date: 2010-01-13 16:10:34 -0500 (Wed, 13 Jan 2010)
New Revision: 99359
Modified:
projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/VFS.java
projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/util/automount/Automounter.java
Log:
Update Automounter to again support mounting expanded and update the URLStreamFactory call in VFS to place org.jboss.vfs.protocol last
Modified: projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/VFS.java
===================================================================
--- projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/VFS.java 2010-01-13 20:58:14 UTC (rev 99358)
+++ projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/VFS.java 2010-01-13 21:10:34 UTC (rev 99359)
@@ -49,6 +49,7 @@
import org.jboss.vfs.spi.RealFileSystem;
import org.jboss.vfs.spi.JavaZipFileSystem;
import org.jboss.logging.Logger;
+import org.jboss.net.protocol.URLStreamHandlerFactory;
/**
* Virtual File System
@@ -89,14 +90,19 @@
* Initialize VFS protocol handlers package property.
*/
private static void init() {
- // A small hack that allows us to replace file for now
- URL.setURLStreamHandlerFactory(null);
+ // If this doesn't work, hopefully the existing URLStreamHandlerFactory supports updates to the 'java.protocol.handler.pkgs' property.
+ try {
+ URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory());
+ } catch (Throwable ignored) {}
+
String pkgs = System.getProperty("java.protocol.handler.pkgs");
if (pkgs == null || pkgs.trim().length() == 0) {
- pkgs = "org.jboss.vfs.protocol";
+ pkgs = "org.jboss.net.protocol|org.jboss.vfs.protocol";
System.setProperty("java.protocol.handler.pkgs", pkgs);
} else if (pkgs.contains("org.jboss.vfs.protocol") == false) {
- pkgs = "org.jboss.vfs.protocol|" + pkgs;
+ if(pkgs.contains("org.jboss.net.protocol") == false)
+ pkgs += "|org.jboss.net.protocol";
+ pkgs += "|org.jboss.vfs.protocol";
System.setProperty("java.protocol.handler.pkgs", pkgs);
}
}
Modified: projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/util/automount/Automounter.java
===================================================================
--- projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/util/automount/Automounter.java 2010-01-13 20:58:14 UTC (rev 99358)
+++ projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/util/automount/Automounter.java 2010-01-13 21:10:34 UTC (rev 99359)
@@ -58,6 +58,9 @@
/* VirutalFile used as a base mount for 'hidden' original copies of mounted files */
private static final VirtualFile originalsRoot = VFS.getChild("/.vfs/backups");
+ /* Mount types */
+ private static enum MountType {ZIP, EXPANDED};
+
/**
* Private constructor
*/
@@ -75,7 +78,7 @@
{
mount(new VirtualFileOwner(target), target);
}
-
+
/**
* Mount provided {@link VirtualFile} (if not mounted) and add an owner entry. Also creates a back-reference to from the owner to the target.
*
@@ -87,7 +90,7 @@
{
mount(new SimpleMountOwner(owner), target);
}
-
+
/**
* Mount provided {@link VirtualFile} (if not mounted) and add an owner entry. Also creates a back-reference to from the owner to the target.
*
@@ -101,16 +104,74 @@
}
/**
+ * Mount provided {@link VirtualFile} as an expanded file system (if not mounted) and add an owner entry. Also creates a back-reference to from the owner to the target.
+ *
+ * @param owner MountOwner that owns the reference to the mount
+ * @param target VirtualFile to mount
+ * @throws IOException when the target can not be mounted
+ */
+ public static void mount(MountOwner owner, VirtualFile target) throws IOException {
+ mount(owner, target, MountType.ZIP);
+ }
+
+ /**
+ * Mount provided {@link VirtualFile} (if not mounted) and set the owner to be the provided target. (Self owned mount)
+ *
+ * @param target VirtualFile to mount
+ * @throws IOException when the target can not be mounted.
+ */
+ public static void mountExpanded(VirtualFile target) throws IOException
+ {
+ mountExpanded(new VirtualFileOwner(target), target);
+ }
+
+ /**
+ * Mount provided {@link VirtualFile} as an expanded file system (if not mounted) and add an owner entry. Also creates a back-reference to from the owner to the target.
+ *
+ * @param owner Object that owns the reference to the mount
+ * @param target VirtualFile to mount
+ * @throws IOException when the target can not be mounted.
+ */
+ public static void mountExpanded(Object owner, VirtualFile target) throws IOException
+ {
+ mountExpanded(new SimpleMountOwner(owner), target);
+ }
+
+ /**
+ * Mount provided {@link VirtualFile} as an expanded file system (if not mounted) and add an owner entry. Also creates a back-reference to from the owner to the target.
+ *
+ * @param owner VirtualFile that owns the reference to the mount
+ * @param target VirtualFile to mount
+ * @throws IOException when the target can not be mounted.
+ */
+ public static void mountExpanded(VirtualFile owner, VirtualFile target) throws IOException
+ {
+ mountExpanded(new VirtualFileOwner(owner), target);
+ }
+
+ /**
* Mount provided {@link VirtualFile} (if not mounted) and add an owner entry. Also creates a back-reference to from the owner to the target.
*
* @param owner MountOwner that owns the reference to the mount
* @param target VirtualFile to mount
* @throws IOException when the target can not be mounted
*/
- public static void mount(MountOwner owner, VirtualFile target) throws IOException
+ public static void mountExpanded(MountOwner owner, VirtualFile target) throws IOException {
+ mount(owner, target, MountType.EXPANDED);
+ }
+
+ /**
+ * Mount provided {@link VirtualFile} (if not mounted) and add an owner entry. Also creates a back-reference to from the owner to the target.
+ *
+ * @param owner MountOwner that owns the reference to the mount
+ * @param target VirtualFile to mount
+ * @param mountType {@link MountType} type of mount to create
+ * @throws IOException when the target can not be mounted
+ */
+ private static void mount(MountOwner owner, VirtualFile target, MountType mountType) throws IOException
{
RegistryEntry targetEntry = getEntry(target);
- targetEntry.mount(target);
+ targetEntry.mount(target, mountType);
targetEntry.inboundReferences.add(owner);
ownerReferences.putIfAbsent(owner, new HashSet<RegistryEntry>());
ownerReferences.get(owner).add(targetEntry);
@@ -238,7 +299,7 @@
private VirtualFile backupFile;
- private void mount(VirtualFile target) throws IOException
+ private void mount(VirtualFile target, MountType mountType) throws IOException
{
if (mounted.compareAndSet(false, true))
{
@@ -247,7 +308,10 @@
final TempFileProvider provider = getTempFileProvider(target.getName());
// Make sure we can get to the original
backup(target);
- handles.add(VFS.mountZip(target, target, provider));
+ if(MountType.ZIP.equals(mountType))
+ handles.add(VFS.mountZip(target, target, provider));
+ else
+ handles.add(VFS.mountZipExpanded(target, target, provider));
}
}
}
More information about the jboss-cvs-commits
mailing list