Class FilesListenerManager

java.lang.Object
org.odpi.openmetadata.frameworks.integration.filelistener.FilesListenerManager

public class FilesListenerManager extends Object
FilesListenerManager uses the Apache Commons IO capabilities to support the ability for an Integration Connector to monitor changes in the file system. The implementation is a thin wrapper around the Apache Commons IO to allow the implementation to be swapped for other types of file system monitors.
  • Constructor Details

    • FilesListenerManager

      public FilesListenerManager(AuditLog auditLog, String connectorName)
      Constructor.
      Parameters:
      auditLog - logging destination
      connectorName - name of the connector
  • Method Details

    • registerFileListener

      public void registerFileListener(FileListenerInterface listener, File fileToMonitor) throws InvalidParameterException
      Register a listener object that will be called each time a specific file is created, changed or deleted.
      Parameters:
      listener - listener object
      fileToMonitor - name of the file to monitor
      Throws:
      InvalidParameterException - one of the parameters is null or invalid.
    • unregisterFileListener

      public void unregisterFileListener(FileListenerInterface listener, File fileToMonitor) throws InvalidParameterException
      Unregister a listener object that will be called each time a specific file is created, changed or deleted.
      Parameters:
      listener - listener object
      fileToMonitor - name of the file to unregister
      Throws:
      InvalidParameterException - one of the parameters is null or invalid.
    • registerDirectoryListener

      public void registerDirectoryListener(FileDirectoryListenerInterface listener, File directoryToMonitor, FileFilter fileFilter) throws InvalidParameterException
      Register a listener object that will be called each time a file is created, changed or deleted in a specific root directory. The file filter lets you request that only certain types of files are returned.
      Parameters:
      listener - listener object
      directoryToMonitor - details of the file directory to monitor
      fileFilter - a file filter implementation that restricts the files/directories that will be returned to the listener
      Throws:
      InvalidParameterException - one of the parameters is null or invalid.
    • unregisterDirectoryListener

      public void unregisterDirectoryListener(FileDirectoryListenerInterface listener, File directoryToMonitor) throws InvalidParameterException
      Unregister a listener object for the directory.
      Parameters:
      listener - listener object
      directoryToMonitor - details of the file directory unregister
      Throws:
      InvalidParameterException - one of the parameters is null or invalid.
    • registerDirectoryTreeListener

      public void registerDirectoryTreeListener(FileDirectoryListenerInterface listener, File directoryToMonitor, FileFilter fileFilter) throws InvalidParameterException
      Register a listener object that will be called each time a file is created, changed or deleted in a specific root directory and any of its subdirectories. The file filter lets you request that only certain types of files and/or directories are returned.
      Parameters:
      listener - listener object
      directoryToMonitor - details of the root file directory to monitor from
      fileFilter - a file filter implementation that restricts the files/directories that will be returned to the listener
      Throws:
      InvalidParameterException - one of the parameters is null or invalid.
    • unregisterDirectoryTreeListener

      public void unregisterDirectoryTreeListener(FileDirectoryListenerInterface listener, File directoryToMonitor) throws InvalidParameterException
      Unregister a listener object for the directory.
      Parameters:
      listener - listener object
      directoryToMonitor - details of the root file directory to unregister
      Throws:
      InvalidParameterException - one of the parameters is null or invalid.
    • disconnect

      public void disconnect() throws ConnectorCheckedException
      Shutdown file monitoring
      Throws:
      ConnectorCheckedException - something failed in the super class
    • validateParameter

      public void validateParameter(Object object, String nameParameter, String methodName) throws InvalidParameterException
      Throw an exception if the supplied parameter is null
      Parameters:
      object - object to validate
      nameParameter - name of the parameter that passed the object.
      methodName - name of the method making the call.
      Throws:
      InvalidParameterException - the object is null