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.Closeable
The 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 void
close()
java.util.Set<java.lang.String>
getBaseNamesWithExtension(java.lang.String extension)
Gets the base names with extension.T
getContents(java.lang.String fileName)
Gets the contents.java.util.Set<java.lang.String>
getFileNames()
Gets the file names.void
join()
Join.void
run()
void
start()
Start.void
stop()
Stop.
-
-
-
Constructor Detail
-
DirectoryWatcher
public DirectoryWatcher(java.io.File directory, FileReloadCallback<T> loader) throws java.lang.InterruptedException
Instantiates 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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
join
public void join() throws java.lang.InterruptedException
Join.- Throws:
java.lang.InterruptedException
- the interrupted exception
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
start
public void start() throws java.lang.InterruptedException
Start.- Throws:
java.lang.InterruptedException
- the interrupted exception
-
stop
public void stop() throws java.lang.InterruptedException
Stop.- 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
-
-