Class DefaultFileWatcher
- java.lang.Object
-
- br.pucrio.tecgraf.soma.job.log.watcher.impl.DefaultFileWatcher
-
- All Implemented Interfaces:
IFileWatcher,IWatcher,Closeable,AutoCloseable
public class DefaultFileWatcher extends Object implements IFileWatcher
-
-
Field Summary
Fields Modifier and Type Field Description static WatchEvent.Modifier[]DEFAULT_MODIFIERS
-
Constructor Summary
Constructors Constructor Description DefaultFileWatcher(Integer threadPoolSize)DefaultFileWatcher(WatchService watchService, List<IFileWatchEventListener> listeners, Integer threadPoolSize)Construtor para os testes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFileWatchEventListener(IFileWatchEventListener listener)voidclose()PathgetWatchedDirectoryPath()booleanisWatching()protected voidprocessEvent(WatchEvent<?> watchEvent)voidregister(String dirStrPath, FileFilter fileFilter)voidremoveFileWatchEventListener(IFileWatchEventListener listener)voidstartWatch()voidstopWatch()
-
-
-
Field Detail
-
DEFAULT_MODIFIERS
public static final WatchEvent.Modifier[] DEFAULT_MODIFIERS
-
-
Constructor Detail
-
DefaultFileWatcher
public DefaultFileWatcher(Integer threadPoolSize) throws IOException
- Throws:
IOException
-
DefaultFileWatcher
public DefaultFileWatcher(WatchService watchService, List<IFileWatchEventListener> listeners, Integer threadPoolSize)
Construtor para os testes.- Parameters:
watchService-listeners-
-
-
Method Detail
-
register
public void register(String dirStrPath, FileFilter fileFilter) throws IOException
- Specified by:
registerin interfaceIFileWatcher- Throws:
IOException
-
startWatch
public void startWatch() throws InterruptedException- Specified by:
startWatchin interfaceIFileWatcher- Throws:
InterruptedException
-
stopWatch
public void stopWatch()
- Specified by:
stopWatchin interfaceIFileWatcher
-
getWatchedDirectoryPath
public Path getWatchedDirectoryPath()
-
addFileWatchEventListener
public void addFileWatchEventListener(IFileWatchEventListener listener)
- Specified by:
addFileWatchEventListenerin interfaceIFileWatcher
-
removeFileWatchEventListener
public void removeFileWatchEventListener(IFileWatchEventListener listener)
- Specified by:
removeFileWatchEventListenerin interfaceIFileWatcher
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
isWatching
public boolean isWatching()
- Specified by:
isWatchingin interfaceIFileWatcher
-
processEvent
protected void processEvent(WatchEvent<?> watchEvent)
-
-