org.springframework.integration.file.monitors
Class AbstractEventDrivenFileMonitor

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.file.monitors.AbstractEventDrivenFileMonitor
All Implemented Interfaces:
BeanFactoryAware, BeanNameAware, InitializingBean, NamedComponent, EventDrivenDirectoryMonitor
Direct Known Subclasses:
DirectedEventDrivenFileMonitor

public abstract class AbstractEventDrivenFileMonitor
extends IntegrationObjectSupport
implements EventDrivenDirectoryMonitor

This component will support event-based (not poller based) notifications of files from a file system. Immediate implementations will center around supporting other adapters's delivery of files once they've been synced from a remote system. Potential future expansions for consumer consumption might be a push / event-based file adapter based on either native code or Java 7's NIO.2 WaterService or other third party implementations.

In the meantime, this provides us with a base class for building event driven file adapters quickly. The two cases I see are:


Field Summary
 
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
logger
 
Constructor Summary
AbstractEventDrivenFileMonitor()
           
 
Method Summary
protected  void installDirectoryIfRequired(java.io.File directoryToMonitor)
          Handles ensuring that the directory we're monitroring exists or can be created
 void monitor(java.io.File directory, FileAdditionListener fileAdditionListener)
          installs directory, and then kicks of an event pump
protected  void onInit()
          Subclasses may implement this for initialization logic.
protected  void prescan()
          Obviously, we're trying to keep away from scanning, but this may be necessary at startup to catch up the backlog
protected  void publishNewFileReceived(java.io.File file)
           
protected  void publishNewFileReceived(java.lang.String path)
           
 void setAutoCreateDirectory(boolean autoCreateDirectory)
           
 void setExecutor(java.util.concurrent.Executor executor)
           
 void setFilter(EntryListFilter<java.io.File> filter)
           
 void setMaxQueueSize(int maxQueueSize)
           
 void setScanDirectoryOnLoad(boolean scanDirectoryOnLoad)
           
protected  void start()
          Custom initialization hook - override at your discretion
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getComponentType, getConversionService, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractEventDrivenFileMonitor

public AbstractEventDrivenFileMonitor()
Method Detail

setScanDirectoryOnLoad

public void setScanDirectoryOnLoad(boolean scanDirectoryOnLoad)

monitor

public void monitor(java.io.File directory,
                    FileAdditionListener fileAdditionListener)
             throws java.lang.Exception
installs directory, and then kicks of an event pump

Specified by:
monitor in interface EventDrivenDirectoryMonitor
Parameters:
directory - the directory to start watching from. Unspecified if this implies recursion or not.
fileAdditionListener - the callback
Throws:
java.lang.Exception

setMaxQueueSize

public void setMaxQueueSize(int maxQueueSize)

setFilter

public void setFilter(EntryListFilter<java.io.File> filter)

setExecutor

public void setExecutor(java.util.concurrent.Executor executor)

setAutoCreateDirectory

public void setAutoCreateDirectory(boolean autoCreateDirectory)

publishNewFileReceived

protected void publishNewFileReceived(java.lang.String path)

publishNewFileReceived

protected void publishNewFileReceived(java.io.File file)

prescan

protected void prescan()
Obviously, we're trying to keep away from scanning, but this may be necessary at startup to catch up the backlog


installDirectoryIfRequired

protected void installDirectoryIfRequired(java.io.File directoryToMonitor)
                                   throws java.lang.Exception
Handles ensuring that the directory we're monitroring exists or can be created

Parameters:
directoryToMonitor - the directory to monitor
Throws:
java.lang.Exception

start

protected void start()
              throws java.lang.Exception
Custom initialization hook - override at your discretion

Throws:
java.lang.Exception

onInit

protected void onInit()
               throws java.lang.Exception
Description copied from class: IntegrationObjectSupport
Subclasses may implement this for initialization logic.

Overrides:
onInit in class IntegrationObjectSupport
Throws:
java.lang.Exception