@Test(expected=FileNotFoundException.class) public void testFileDoesntExist() throws FileNotFoundException { m_watcher.getContents("doesnotexist.xml"); }
public T getContents(String fileName) throws FileNotFoundException { checkFileChanges(); File file = new File(m_directory, fileName); if (file.exists()) { FileReloadContainer<T> newContainer = new FileReloadContainer<T>(file, m_loader); newContainer.setReloadCheckInterval(0); FileReloadContainer<T> container = m_contents.putIfAbsent(file.getName(), newContainer); if (container == null) { container = newContainer; } return container.getObject(); } else { m_contents.remove(fileName); throw new FileNotFoundException("there is no file " + fileName + " in directory " + m_directory); } }
DirectoryWatcher { public T getContents(String fileName) throws FileNotFoundException { checkFileChanges(); File file = new File(m_directory, fileName); if (file.exists()) { FileReloadContainer<T> newContainer = new FileReloadContainer<T>(file, m_loader); newContainer.setReloadCheckInterval(0); FileReloadContainer<T> container = m_contents.putIfAbsent(file.getName(), newContainer); if (container == null) { container = newContainer; } return container.getObject(); } else { m_contents.remove(fileName); throw new FileNotFoundException("there is no file " + fileName + " in directory " + m_directory); } } }
DirectoryWatcher { public T getContents(String fileName) throws FileNotFoundException { checkFileChanges(); File file = new File(m_directory, fileName); if (file.exists()) { FileReloadContainer<T> newContainer = new FileReloadContainer<T>(file, m_loader); newContainer.setReloadCheckInterval(0); FileReloadContainer<T> container = m_contents.putIfAbsent(file.getName(), newContainer); if (container == null) { container = newContainer; } return container.getObject(); } else { m_contents.remove(fileName); throw new FileNotFoundException("there is no file " + fileName + " in directory " + m_directory); } } DirectoryWatcher(File directory, FileReloadCallback<T> loader); }
DirectoryWatcher { public T getContents(String fileName) throws FileNotFoundException { checkFileChanges(); File file = new File(m_directory, fileName); if (file.exists()) { FileReloadContainer<T> newContainer = new FileReloadContainer<T>(file, m_loader); newContainer.setReloadCheckInterval(0); FileReloadContainer<T> container = m_contents.putIfAbsent(file.getName(), newContainer); if (container == null) { container = newContainer; } return container.getObject(); } else { m_contents.remove(fileName); throw new FileNotFoundException("there is no file " + fileName + " in directory " + m_directory); } } DirectoryWatcher(File directory, FileReloadCallback<T> loader); Set<String> getFileNames(); Set<String> getBaseNamesWithExtension(String extension); T getContents(String fileName); }
DirectoryWatcher { public T getContents(String fileName) throws FileNotFoundException { checkFileChanges(); File file = new File(m_directory, fileName); if (file.exists()) { FileReloadContainer<T> newContainer = new FileReloadContainer<T>(file, m_loader); newContainer.setReloadCheckInterval(0); FileReloadContainer<T> container = m_contents.putIfAbsent(file.getName(), newContainer); if (container == null) { container = newContainer; } return container.getObject(); } else { m_contents.remove(fileName); throw new FileNotFoundException("there is no file " + fileName + " in directory " + m_directory); } } DirectoryWatcher(File directory, FileReloadCallback<T> loader); Set<String> getFileNames(); Set<String> getBaseNamesWithExtension(String extension); T getContents(String fileName);  }