Class DirectoryWatcher<T>
- java.lang.Object
-
- org.opennms.netmgt.provision.persist.DirectoryWatcher<T>
-
- Type Parameters:
T- the object representation of the file
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Runnable
public class DirectoryWatcher<T> extends java.lang.Object implements java.lang.Runnable, java.io.CloseableThe Class DirectoryWatcher.- Author:
- Alejandro Galue
-
-
Constructor Summary
Constructors Constructor Description DirectoryWatcher(java.io.File directory, FileReloadCallback<T> loader)Instantiates a new directory watcher.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()java.util.Set<java.lang.String>getBaseNamesWithExtension(java.lang.String extension)Gets the base names with extension.TgetContents(java.lang.String fileName)Gets the contents.java.util.Set<java.lang.String>getFileNames()Gets the file names.voidjoin()Join.voidrun()voidstart()Start.voidstop()Stop.
-
-
-
Constructor Detail
-
DirectoryWatcher
public DirectoryWatcher(java.io.File directory, FileReloadCallback<T> loader) throws java.lang.InterruptedExceptionInstantiates a new directory watcher.- Parameters:
directory- the directoryloader- the loader- Throws:
java.lang.InterruptedException- the interrupted exception
-
-
Method Detail
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
join
public void join() throws java.lang.InterruptedExceptionJoin.- Throws:
java.lang.InterruptedException- the interrupted exception
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
start
public void start() throws java.lang.InterruptedExceptionStart.- Throws:
java.lang.InterruptedException- the interrupted exception
-
stop
public void stop() throws java.lang.InterruptedExceptionStop.- Throws:
java.lang.InterruptedException- the interrupted exception
-
getFileNames
public java.util.Set<java.lang.String> getFileNames()
Gets the file names.- Returns:
- the file names
-
getBaseNamesWithExtension
public java.util.Set<java.lang.String> getBaseNamesWithExtension(java.lang.String extension)
Gets the base names with extension.- Parameters:
extension- the extension- Returns:
- the base names with extension
-
getContents
public T getContents(java.lang.String fileName) throws java.io.FileNotFoundException
Gets the contents.- Parameters:
fileName- the file name- Returns:
- the contents
- Throws:
java.io.FileNotFoundException- the file not found exception
-
-