@Test(expected=FileNotFoundException.class) public void testFileDeleted() throws IOException { assertEquals("file2Contents", m_watcher.getContents("file2.xml")); File file2 = new File(m_bldr.getCurrentDir(), "file2.xml"); file2.delete(); m_watcher.getContents("file2.xml"); fail("This should not get here!"); }
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);  }