Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from alesj/auto-handle

Auto handle
  • Loading branch information...
commit 8ed8ebfba3cfc272da422cbbf463cec5ff3aa931 2 parents ec95717 + b21109a
@dmlloyd dmlloyd authored
Showing with 28 additions and 4 deletions.
  1. +28 −4 src/main/java/org/jboss/vfs/util/automount/Automounter.java
View
32 src/main/java/org/jboss/vfs/util/automount/Automounter.java
@@ -135,6 +135,30 @@ private static MountConfig getMountConfig(MountOption[] mountOptions) {
}
/**
+ * Add handle to owner, to be auto closed.
+ *
+ * @param owner the handle owner
+ * @param handle the handle
+ * @return add result
+ */
+ public static boolean addHandle(VirtualFile owner, Closeable handle) {
+ RegistryEntry entry = getEntry(owner);
+ return entry.handles.add(handle);
+ }
+
+ /**
+ * Remove handle from owner.
+ *
+ * @param owner the handle owner
+ * @param handle the handle
+ * @return remove result
+ */
+ public static boolean removeHandle(VirtualFile owner, Closeable handle) {
+ RegistryEntry entry = getEntry(owner);
+ return entry.handles.remove(handle);
+ }
+
+ /**
* 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
@@ -175,8 +199,8 @@ public static void cleanup(MountOwner owner)
/**
* Determines whether a target {@link VirtualFile} is mounted.
*
- * @param target
- * @return
+ * @param target target to check
+ * @return true if mounted, false otherwise
*/
public static boolean isMounted(VirtualFile target)
{
@@ -186,8 +210,8 @@ public static boolean isMounted(VirtualFile target)
/**
* Get the entry from the tree creating the entry if not present.
*
- * @param virtualFile
- * @return
+ * @param virtualFile entry's owner file
+ * @return registry entry
*/
static RegistryEntry getEntry(VirtualFile virtualFile)
{
Please sign in to comment.
Something went wrong with that request. Please try again.