org.sca4j.binding.file.runtime
Class DirectoryWatcher

java.lang.Object
  extended by org.sca4j.host.work.DefaultPausableWork
      extended by org.sca4j.binding.file.runtime.DirectoryWatcher
All Implemented Interfaces:
java.lang.Runnable, org.sca4j.host.work.PausableWork, org.sca4j.spi.services.event.SCA4JEventListener

public class DirectoryWatcher
extends org.sca4j.host.work.DefaultPausableWork
implements org.sca4j.spi.services.event.SCA4JEventListener

Polls the directory to list the files and passes them to FileServiceInvoker for processing. Once file is processed it will be either archived or deleted. TODO: SERVICECONDUIT-26

Author:
dhillonn

Nested Class Summary
 class DirectoryWatcher.ManagementUnitImpl
           
 
Constructor Summary
DirectoryWatcher(java.io.File endpointDir, org.sca4j.spi.wire.Wire wire, FileBindingMonitor monitor, org.sca4j.host.management.ManagementService managementService, java.net.URI serviceUri)
          Constructor with mandatory fields
 
Method Summary
protected  void execute()
          
 void onEvent(org.sca4j.spi.services.event.SCA4JEvent event)
           
 void setAcquireEndpointLock(boolean acquireEndpointLock)
          Sets the flag to specify if endpoint lock must be acquired for cluster-wide deployment.
 void setAcquireFileLock(boolean acquireFileLock)
          Sets the flag to specify if lock must be acquired before reading the file.
 void setArchiveDir(java.io.File archiveDir)
          Set optional archive directory, where file be moved after its been read.
 void setArchiveFileTSPattern(java.lang.String archiveFileTimestampPattern)
          Set timestamp suffix pattern for the archived file
 void setFileNamePattern(java.lang.String fileNameRegex)
          Regular expression to filter the files
 void setPollingFrequency(long pollingFrequency)
          Sets directory polling frequency
 
Methods inherited from class org.sca4j.host.work.DefaultPausableWork
isDaemon, run, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectoryWatcher

public DirectoryWatcher(java.io.File endpointDir,
                        org.sca4j.spi.wire.Wire wire,
                        FileBindingMonitor monitor,
                        org.sca4j.host.management.ManagementService managementService,
                        java.net.URI serviceUri)
Constructor with mandatory fields

Parameters:
endpointDir - directory to the polling on
wire - wire to access the underlying service
monitor - monitor for logging
Method Detail

setArchiveDir

public void setArchiveDir(java.io.File archiveDir)
Set optional archive directory, where file be moved after its been read. In absence of this file will be deleted.

Parameters:
archiveDir - archive directory

setFileNamePattern

public void setFileNamePattern(java.lang.String fileNameRegex)
Regular expression to filter the files

Parameters:
fileNameRegex - file name regular expression

setPollingFrequency

public void setPollingFrequency(long pollingFrequency)
Sets directory polling frequency

Parameters:
pollingFrequency - polling frequency

setAcquireFileLock

public void setAcquireFileLock(boolean acquireFileLock)
Sets the flag to specify if lock must be acquired before reading the file. This is to protect against in-flight files.

Parameters:
acquireFileLock - flag to indicate if lock to be acquired

setAcquireEndpointLock

public void setAcquireEndpointLock(boolean acquireEndpointLock)
Sets the flag to specify if endpoint lock must be acquired for cluster-wide deployment.

Parameters:
acquireEndpointLock - flag to indicate if endpoint lock to be acquired

setArchiveFileTSPattern

public void setArchiveFileTSPattern(java.lang.String archiveFileTimestampPattern)
Set timestamp suffix pattern for the archived file

Parameters:
archiveTimestampPattern - time stamp pattern for archived file

execute

protected void execute()

Specified by:
execute in class org.sca4j.host.work.DefaultPausableWork

onEvent

public void onEvent(org.sca4j.spi.services.event.SCA4JEvent event)
Specified by:
onEvent in interface org.sca4j.spi.services.event.SCA4JEventListener


Copyright © 2008-2011 Service Symphony. All Rights Reserved.