[ 
https://issues.apache.org/jira/browse/IO-132?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12536483
 ] 

Niall Pemberton commented on IO-132:
------------------------------------

Thought I would give a quick summary of the core of this feature, which is two 
interfaces and four classes:

1) Interfaces
FileListener - listens for file/directory create, change and delete events
FileObserver - checks the file system for changes and notifies registered 
listeners (core method is checkAndNotify())

2) Implementations
FileListenerAdaptor - do nothing convenience FileListener implementation
AbstractFileObserver - basic FileObserver plumbing - checkAndNotify() not 
implemented
FileObserverImpl - core class providing checkAndNotify() implementation 
(extends AbstractFileObserver)
FileMonitor - Runnable which periodically executes checkAndNotify() of 
registered FileObserver

The heart of all of this is the logic in FileObserverImpl which does the main 
task of identifying new, modified and deleted files/directories and notifying 
the listeners.

> File Listener/Monitor
> ---------------------
>
>                 Key: IO-132
>                 URL: https://issues.apache.org/jira/browse/IO-132
>             Project: Commons IO
>          Issue Type: New Feature
>            Reporter: Niall Pemberton
>            Assignee: Niall Pemberton
>             Fix For: 1.4
>
>         Attachments: AbstractFileObserver.java, 
> AbstractFileObserverTestCase.java, CollectionFileListener.java, 
> CollectionFileListenerTestCase.java, FileListener.java, 
> FileListenerAdaptor.java, FileMonitor.java, FileObserver.java, 
> FileObserverImpl.java, FileObserverImplTestCase.java, 
> JDKLoggingFileListener.java
>
>
> Commons JCI has a "fam" (file alteration monitor) module[1] which provides a 
> listener for file and directory create/change/delete events. I have done some 
> work refactoring the JCI implementation and propose adding to to Commons IO. 
> There is already an existing request/propsal to add similar functionality in 
> IO-79 from Jim Harrington (which includes code).
> There are IMO two main differences (IMO improvements) in this implementation 
> over exsiting JCI fam module:
> 1) It uses a matching array technique to compare previous and current 
> directory contents which minimizes object creation
> 2) FileFilters can be specified to monitor only portions of the file system, 
> ignoring files/directories of no interest. This is more efficient and reduces 
> the amount of noise from un-wanted file/directory events
> From a quick look at IO-79, the above also applies to that proposal. 
> Additionally IMO the solution in IO-79 would benefit from been broken out 
> from the two DirectoryPoller and FilePoller artifacts.
> There are also some changes to the API specified in JCI's fam:
> 1) FileObserver (FilesystemAlterationObserver in fam) has additional init() 
> and destroy() methods
> 2) FileMonitor (FilesystemAlterationMonitor in fam) has 
> addObserver/removeObserver methods rather than addListener/removeListener 
> methods. The issue (IMO) with fam is that the monitor is fixed to the 
> FilesystemAlterationObserverImpl implementation, rather than any 
> FilesystemAlterationObserver implementation. Also the ability to specify file 
> filters means that there is a need to be able to add more than one observer 
> for the same root directory.
> [1] http://svn.apache.org/repos/asf/commons/proper/jci/trunk/fam/

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to