Package org.apache.commons.vfs2.util
Class WeakRefFileListener
- java.lang.Object
-
- org.apache.commons.vfs2.util.WeakRefFileListener
-
- All Implemented Interfaces:
FileListener
public class WeakRefFileListener extends java.lang.Object implements FileListener
Wrap a listener with a WeakReference.- Since:
- 2.0
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
WeakRefFileListener(FileObject file, FileListener listener)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
fileChanged(FileChangeEvent event)
Called when a file is changed.void
fileCreated(FileChangeEvent event)
Called when a file is created.void
fileDeleted(FileChangeEvent event)
Called when a file is deleted.protected FileListener
getListener()
returns the wrapped listener.static void
installListener(FileObject file, FileListener listener)
This will install thelistener
at the givenfile
.
-
-
-
Constructor Detail
-
WeakRefFileListener
protected WeakRefFileListener(FileObject file, FileListener listener)
-
-
Method Detail
-
installListener
public static void installListener(FileObject file, FileListener listener)
This will install thelistener
at the givenfile
.- Parameters:
file
- The FileObject to listen on.listener
- The FileListener
-
getListener
protected FileListener getListener() throws java.lang.Exception
returns the wrapped listener. If it is gone, the WeakRefFileListener wrapper will remove itself from the list of listeners.- Returns:
- The FileListener.
- Throws:
java.lang.Exception
- if an error occurs.
-
fileCreated
public void fileCreated(FileChangeEvent event) throws java.lang.Exception
Called when a file is created.- Specified by:
fileCreated
in interfaceFileListener
- Parameters:
event
- The FileChangeEvent.- Throws:
java.lang.Exception
- if an error occurs.
-
fileDeleted
public void fileDeleted(FileChangeEvent event) throws java.lang.Exception
Called when a file is deleted.- Specified by:
fileDeleted
in interfaceFileListener
- Parameters:
event
- The FileChangeEvent.- Throws:
java.lang.Exception
- if an error occurs.
-
fileChanged
public void fileChanged(FileChangeEvent event) throws java.lang.Exception
Called when a file is changed.This will only happen if you monitor the file using
FileMonitor
.- Specified by:
fileChanged
in interfaceFileListener
- Parameters:
event
- The FileChangeEvent.- Throws:
java.lang.Exception
- if an error occurs.
-
-