[jboss-cvs] JBossAS SVN: r99119 - in projects/vfs/branches/dml-zip-rework/src: test/java/org/jboss/test/vfs/util/automount and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 7 10:47:30 EST 2010
Author: johnbailey
Date: 2010-01-07 10:47:29 -0500 (Thu, 07 Jan 2010)
New Revision: 99119
Modified:
projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/util/automount/Automounter.java
projects/vfs/branches/dml-zip-rework/src/test/java/org/jboss/test/vfs/util/automount/AutomounterTestCase.java
Log:
Created convenience methods on Automounter to avoid requiring clients to create MountOwner objects.
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-07 14:46:09 UTC (rev 99118)
+++ projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/util/automount/Automounter.java 2010-01-07 15:47:29 UTC (rev 99119)
@@ -75,6 +75,30 @@
{
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.
+ *
+ * @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 mount(Object owner, VirtualFile target) throws IOException
+ {
+ 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.
+ *
+ * @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 mount(VirtualFile owner, VirtualFile target) throws IOException
+ {
+ mount(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.
@@ -93,6 +117,26 @@
}
/**
+ * Cleanup all references from the owner. Cleanup any mounted entries that become un-referenced in the process.
+ *
+ * @param owner {@link Object} to cleanup references for
+ */
+ public static void cleanup(Object owner)
+ {
+ cleanup(new SimpleMountOwner(owner));
+ }
+
+ /**
+ * Cleanup all references from the owner. Cleanup any mounted entries that become un-referenced in the process.
+ *
+ * @param owner {@link Object} to cleanup references for
+ */
+ public static void cleanup(VirtualFile owner)
+ {
+ cleanup(new VirtualFileOwner(owner));
+ }
+
+ /**
* Cleanup all references from the {@link MountOwner}. Cleanup any mounted entries that become un-referenced in the process.
*
* @param owner {@link MountOwner} to cleanup references for
Modified: projects/vfs/branches/dml-zip-rework/src/test/java/org/jboss/test/vfs/util/automount/AutomounterTestCase.java
===================================================================
--- projects/vfs/branches/dml-zip-rework/src/test/java/org/jboss/test/vfs/util/automount/AutomounterTestCase.java 2010-01-07 14:46:09 UTC (rev 99118)
+++ projects/vfs/branches/dml-zip-rework/src/test/java/org/jboss/test/vfs/util/automount/AutomounterTestCase.java 2010-01-07 15:47:29 UTC (rev 99119)
@@ -115,8 +115,7 @@
assertTrue(Automounter.isMounted(jarVirtualFile));
VirtualFile otherEarVirtualFile = getVirtualFile("/vfs/test/spring-ear.ear");
- VirtualFileOwner otherOwner = new VirtualFileOwner(otherEarVirtualFile);
- Automounter.mount(otherOwner, jarVirtualFile);
+ Automounter.mount(otherEarVirtualFile, jarVirtualFile);
Automounter.cleanup(owner);
@@ -124,7 +123,7 @@
assertFalse(Automounter.isMounted(warVirtualFile));
assertTrue("Should not have unmounted the reference from two locations", Automounter.isMounted(jarVirtualFile));
- Automounter.cleanup(otherOwner);
+ Automounter.cleanup(otherEarVirtualFile);
assertFalse(Automounter.isMounted(jarVirtualFile));
}
@@ -167,15 +166,13 @@
public void testCleanupReferecesSimpleOwnerSameObj() throws Exception
{
Object ownerObject = new Object();
- MountOwner owner = new SimpleMountOwner(ownerObject);
VirtualFile jarVirtualFile = getVirtualFile("/vfs/test/jar1.jar");
- Automounter.mount(owner, jarVirtualFile);
+ Automounter.mount(ownerObject, jarVirtualFile);
- MountOwner otherOwner = new SimpleMountOwner(ownerObject);
- Automounter.mount(otherOwner, jarVirtualFile);
+ Automounter.mount(ownerObject, jarVirtualFile);
- Automounter.cleanup(owner);
+ Automounter.cleanup(ownerObject);
assertFalse("Should have been unmounted since the owner object is the same", Automounter.isMounted(jarVirtualFile));
}
More information about the jboss-cvs-commits
mailing list