Package org.apache.commons.vfs2.util
Class WeakRefFileListener
java.lang.Object
org.apache.commons.vfs2.util.WeakRefFileListener
- All Implemented Interfaces:
- FileListener
Wraps a listener with a WeakReference.
- Since:
- 2.0
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedWeakRefFileListener(FileObject file, FileListener listener) Constructs a new instance.
- 
Method SummaryModifier and TypeMethodDescriptionvoidfileChanged(FileChangeEvent event) Called when a file is changed.voidfileCreated(FileChangeEvent event) Called when a file is created.voidfileDeleted(FileChangeEvent event) Called when a file is deleted.protected FileListenerGets the wrapped listener.static voidinstallListener(FileObject file, FileListener listener) Install thelistenerat the givenfile.
- 
Constructor Details- 
WeakRefFileListenerConstructs a new instance.- Parameters:
- file- the file object.
- listener- the file listener.
 
 
- 
- 
Method Details- 
installListenerInstall thelistenerat the givenfile.This installs a wrapper with a weak reference, so the listener can be collected. The reference to the listener is removed when the first event can't be delivered. Warning: you cannot remove the listener with fs.removeListener(file, listener)as you do'nt have the wrapper instance at hand.Method is used by DelegateFileObject, as used forVirtualFileSystem.- Parameters:
- file- The FileObject to listen on.
- listener- The FileListener
 
- 
fileChangedCalled when a file is changed.This will only happen if you monitor the file using FileMonitor.- Specified by:
- fileChangedin interface- FileListener
- Parameters:
- event- The FileChangeEvent.
- Throws:
- Exception- if an error occurs.
 
- 
fileCreatedCalled when a file is created.- Specified by:
- fileCreatedin interface- FileListener
- Parameters:
- event- The FileChangeEvent.
- Throws:
- Exception- if an error occurs.
 
- 
fileDeletedCalled when a file is deleted.- Specified by:
- fileDeletedin interface- FileListener
- Parameters:
- event- The FileChangeEvent.
- Throws:
- Exception- if an error occurs.
 
- 
getListenerGets the wrapped listener. If it is gone, the WeakRefFileListener wrapper will remove itself from the list of listeners.- Returns:
- The FileListener.
- Throws:
- Exception- if an error occurs.
 
 
-