Class WeakRefFileListener

java.lang.Object
org.apache.commons.vfs2.util.WeakRefFileListener
All Implemented Interfaces:
FileListener

public class WeakRefFileListener extends Object implements FileListener
Wraps a listener with a WeakReference.
Since:
2.0
  • Field Details

  • Constructor Details

  • Method Details

    • installListener

      public static void installListener(FileObject file, FileListener listener)
      Installs the listener at the given file.
      Parameters:
      file - The FileObject to listen on.
      listener - The FileListener
    • getListener

      protected FileListener getListener() throws Exception
      Gets 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.
    • fileCreated

      public void fileCreated(FileChangeEvent event) throws Exception
      Called when a file is created.
      Specified by:
      fileCreated in interface FileListener
      Parameters:
      event - The FileChangeEvent.
      Throws:
      Exception - if an error occurs.
    • fileDeleted

      public void fileDeleted(FileChangeEvent event) throws Exception
      Called when a file is deleted.
      Specified by:
      fileDeleted in interface FileListener
      Parameters:
      event - The FileChangeEvent.
      Throws:
      Exception - if an error occurs.
    • fileChanged

      public void fileChanged(FileChangeEvent event) throws Exception
      Called when a file is changed.

      This will only happen if you monitor the file using FileMonitor.

      Specified by:
      fileChanged in interface FileListener
      Parameters:
      event - The FileChangeEvent.
      Throws:
      Exception - if an error occurs.