use of org.opennms.core.spring.FileReloadContainer in project opennms by OpenNMS.
the class DirectoryWatcher method getContents.
/**
* Gets the contents.
*
* @param fileName the file name
* @return the contents
* @throws FileNotFoundException the file not found exception
*/
public T getContents(String fileName) throws FileNotFoundException {
File file = new File(m_directory, fileName);
if (file.exists() && !file.isDirectory()) {
FileReloadContainer<T> newContainer = new FileReloadContainer<T>(file, m_loader);
newContainer.setReloadCheckInterval(0);
FileReloadContainer<T> container = m_contents.putIfAbsent(fileName, newContainer);
if (container == null) {
LOG.debug("getting content of {}", file);
container = newContainer;
}
return container.getObject();
}
m_contents.remove(fileName);
throw new FileNotFoundException("there is no file called '" + fileName + "' in directory " + m_directory);
}
Aggregations