org.apache.commons.vfs.util
Class WeakRefFileListener

java.lang.Object
  extended by org.apache.commons.vfs.util.WeakRefFileListener
All Implemented Interfaces:
FileListener

public class WeakRefFileListener
extends java.lang.Object
implements FileListener

Wrap a listener with a WeakReference.

Version:
$Revision: 262 $ $Date: 2006-12-20T09:14:53.055649Z $
Author:
Adam Heath

Constructor Summary
protected WeakRefFileListener(FileObject file, FileListener listener)
           
 
Method Summary
 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 the listener at the given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeakRefFileListener

protected WeakRefFileListener(FileObject file,
                              FileListener listener)
Method Detail

installListener

public static void installListener(FileObject file,
                                   FileListener listener)
This will install the listener at the given file.

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 interface FileListener
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 interface FileListener
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 interface FileListener
Parameters:
event - The FileChangeEvent.
Throws:
java.lang.Exception - if an error occurs.


Copyright © 2002-2011 Apache Software Foundation. All Rights Reserved.