/** * Should be ok if this is not called because the thread started by DefaultFileMonitor is a daemon * thread */ public void close() { executor.shutdownNow(); monitor.stop(); }
public void close() { for (DefaultFileMonitor monitor : this.monitors.values()) { monitor.stop(); } }
public void dispose() { fileMonitor.stop(); fileMonitor = null; scripts.clear(); scripts = null; scriptDir = null; }
/** * Should be ok if this is not called because the thread started by DefaultFileMonitor is a daemon * thread */ public void close() { executor.shutdownNow(); monitor.stop(); }
/** * <PRE> * 1. MethodName : stop * 2. ClassName : WasAppLogSource * 3. Comment : * 4. 작성자 : jinoos * 5. 작성일 : 2013. 10. 16. 오후 10:43:03 * </PRE> */ @Override public void stop() { logger.info("Source Stopping.."); fileMonitor.stop(); sourceCounter.stop(); }
/** * set up the monitor so that when the file system data is changed, our singleton will be refreshed */ public void init() { for (String metadataTableName : this.metadataTableNames) { DefaultFileMonitor monitor = new DefaultFileMonitor(this); try { monitor.setDelay(delay); monitor.setRecursive(false); monitor.addFile(this.bridge.getFileObject(metadataTableName)); log.debug("monitoring " + this.bridge.getFileObject(metadataTableName)); monitor.start(); this.monitors.put(metadataTableName, monitor); } catch (Exception ex) { monitor.stop(); throw new RuntimeException("Failed to create TypeMetadataProvider with " + this.bridge.getUri() + this.bridge.getDir() + "/" + this.bridge.getFileName(), ex); } } }
public void testFileModified() throws Exception { writeToFile(testFile); final FileObject fileObj = fsManager.resolveFile(testFile.toURI().toURL().toString()); final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); // TestFileListener manipulates changeStatus monitor.setDelay(100); monitor.addFile(fileObj); monitor.start(); try { // Need a long delay to insure the new timestamp doesn't truncate to be the same as // the current timestammp. Java only guarantees the timestamp will be to 1 second. Thread.sleep(1000); final long value = System.currentTimeMillis(); final boolean rc = testFile.setLastModified(value); assertTrue("setLastModified succeeded", rc); Thread.sleep(300); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event", changeStatus == 1); } finally { monitor.stop(); } }
public void testFileModified() throws Exception { writeToFile(testFile); final FileObject fileObj = fsManager.resolveFile(testFile.toURI().toURL().toString()); final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); // TestFileListener manipulates changeStatus monitor.setDelay(100); monitor.addFile(fileObj); monitor.start(); try { // Need a long delay to insure the new timestamp doesn't truncate to be the same as // the current timestammp. Java only guarantees the timestamp will be to 1 second. Thread.sleep(1000); final long value = System.currentTimeMillis(); final boolean rc = testFile.setLastModified(value); assertTrue("setLastModified succeeded", rc); Thread.sleep(300); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event", changeStatus == 1); } finally { monitor.stop(); } }
public void testFileCreated() throws Exception { final FileObject fileObj = fsManager.resolveFile(testFile.toURI().toURL().toString()); final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); // TestFileListener manipulates changeStatus monitor.setDelay(100); monitor.addFile(fileObj); monitor.start(); try { writeToFile(testFile); Thread.sleep(300); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event", changeStatus == 3); } finally { monitor.stop(); } }
public void testFileModified() throws Exception { writeToFile(testFile); final FileObject fileObj = fsManager.resolveFile(testFile.toURI().toURL().toString()); final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); // TestFileListener manipulates changeStatus monitor.setDelay(100); monitor.addFile(fileObj); monitor.start(); try { // Need a long delay to insure the new timestamp doesn't truncate to be the same as // the current timestammp. Java only guarantees the timestamp will be to 1 second. Thread.sleep(1000); final long value = System.currentTimeMillis(); final boolean rc = testFile.setLastModified(value); assertTrue("setLastModified succeeded",rc); Thread.sleep(300); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event", changeStatus == 1); } finally { monitor.stop(); } }
public void testFileDeleted() throws Exception { writeToFile(testFile); final FileObject fileObj = fsManager.resolveFile(testFile.toURI().toString()); final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); // TestFileListener manipulates changeStatus monitor.setDelay(100); monitor.addFile(fileObj); monitor.start(); try { testFile.delete(); Thread.sleep(300); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event", changeStatus == 2); } finally { monitor.stop(); } }
public void testChildFileRecreated() throws Exception { writeToFile(testFile); final FileObject fileObj = fsManager.resolveFile(testDir.toURI().toURL().toString()); final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); monitor.setDelay(2000); monitor.addFile(fileObj); monitor.start(); try { changeStatus = 0; Thread.sleep(300); testFile.delete(); Thread.sleep(3000); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event " + changeStatus, changeStatus == 2); changeStatus = 0; Thread.sleep(300); writeToFile(testFile); Thread.sleep(3000); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event " + changeStatus, changeStatus == 3); } finally { monitor.stop(); } }
public void testFileCreated() throws Exception { final FileObject fileObj = fsManager.resolveFile(testFile.toURI().toURL().toString()); final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); // TestFileListener manipulates changeStatus monitor.setDelay(100); monitor.addFile(fileObj); monitor.start(); try { writeToFile(testFile); Thread.sleep(300); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event", changeStatus == 3); } finally { monitor.stop(); } }
public void testFileDeleted() throws Exception { writeToFile(testFile); final FileObject fileObj = fsManager.resolveFile(testFile.toURI().toString()); final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); // TestFileListener manipulates changeStatus monitor.setDelay(100); monitor.addFile(fileObj); monitor.start(); try { testFile.delete(); Thread.sleep(300); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event", changeStatus == 2); } finally { monitor.stop(); } }
public void testFileCreated() throws Exception { final FileObject fileObj = fsManager.resolveFile(testFile.toURI().toURL().toString()); final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); // TestFileListener manipulates changeStatus monitor.setDelay(100); monitor.addFile(fileObj); monitor.start(); try { writeToFile(testFile); Thread.sleep(300); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event", changeStatus == 3); } finally { monitor.stop(); } }
public void testFileDeleted() throws Exception { writeToFile(testFile); final FileObject fileObj = fsManager.resolveFile(testFile.toURI().toString()); final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); // TestFileListener manipulates changeStatus monitor.setDelay(100); monitor.addFile(fileObj); monitor.start(); try { testFile.delete(); Thread.sleep(300); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event", changeStatus == 2); } finally { monitor.stop(); } }
public void testChildFileRecreated() throws Exception { writeToFile(testFile); final FileObject fileObj = fsManager.resolveFile(testDir.toURI().toURL().toString()); final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); monitor.setDelay(2000); monitor.addFile(fileObj); monitor.start(); try { changeStatus = 0; Thread.sleep(300); testFile.delete(); Thread.sleep(3000); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event " + changeStatus, changeStatus == 2); changeStatus = 0; Thread.sleep(300); writeToFile(testFile); Thread.sleep(3000); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event " + changeStatus, changeStatus == 3); } finally { monitor.stop(); } }
public void testChildFileRecreated() throws Exception { writeToFile(testFile); final FileObject fileObj = fsManager.resolveFile(testDir.toURI().toURL().toString()); final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); monitor.setDelay(2000); monitor.addFile(fileObj); monitor.start(); try { changeStatus = 0; Thread.sleep(300); testFile.delete(); Thread.sleep(3000); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event " + changeStatus, changeStatus == 2); changeStatus = 0; Thread.sleep(300); writeToFile(testFile); Thread.sleep(3000); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event " + changeStatus, changeStatus == 3); } finally { monitor.stop(); } }
public void testFileRecreated() throws Exception { final FileObject fileObj = fsManager.resolveFile(testFile.toURI().toURL().toString()); final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); // TestFileListener manipulates changeStatus monitor.setDelay(100); monitor.addFile(fileObj); monitor.start(); try { writeToFile(testFile); Thread.sleep(300); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event " + changeStatus, changeStatus == 3); changeStatus = 0; testFile.delete(); Thread.sleep(300); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event " + changeStatus, changeStatus == 2); changeStatus = 0; Thread.sleep(500); monitor.addFile(fileObj); writeToFile(testFile); Thread.sleep(300); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event " + changeStatus, changeStatus == 3); } finally { monitor.stop(); } }
public void testFileRecreated() throws Exception { final FileObject fileObj = fsManager.resolveFile(testFile.toURI().toURL().toString()); final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); // TestFileListener manipulates changeStatus monitor.setDelay(100); monitor.addFile(fileObj); monitor.start(); try { writeToFile(testFile); Thread.sleep(300); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event " + changeStatus, changeStatus == 3); changeStatus = 0; testFile.delete(); Thread.sleep(300); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event " + changeStatus, changeStatus == 2); changeStatus = 0; Thread.sleep(500); monitor.addFile(fileObj); writeToFile(testFile); Thread.sleep(300); assertTrue("No event occurred", changeStatus != 0); assertTrue("Incorrect event " + changeStatus, changeStatus == 3); } finally { monitor.stop(); } }