public class WeakRefFileListener extends Object implements FileListener
| Modifier | Constructor and Description |
|---|---|
protected |
WeakRefFileListener(FileObject file,
FileListener listener)
Constructs a new instance.
|
| Modifier and Type | Method and 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()
Gets the wrapped listener.
|
static void |
installListener(FileObject file,
FileListener listener)
Install the
listener at the given file. |
protected WeakRefFileListener(FileObject file, FileListener listener)
file - the file object.listener - the file listener.public static void installListener(FileObject file, FileListener listener)
listener at the given file.
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 for VirtualFileSystem.
file - The FileObject to listen on.listener - The FileListenerpublic void fileChanged(FileChangeEvent event) throws Exception
This will only happen if you monitor the file using FileMonitor.
fileChanged in interface FileListenerevent - The FileChangeEvent.Exception - if an error occurs.public void fileCreated(FileChangeEvent event) throws Exception
fileCreated in interface FileListenerevent - The FileChangeEvent.Exception - if an error occurs.public void fileDeleted(FileChangeEvent event) throws Exception
fileDeleted in interface FileListenerevent - The FileChangeEvent.Exception - if an error occurs.protected FileListener getListener() throws Exception
Exception - if an error occurs.Copyright © 2002–2025 The Apache Software Foundation. All rights reserved.