/** * Starts watching the file system for changes to trigger a bake. * * @param config JBakeConfiguration settings */ public void start(JBakeConfiguration config) { try { FileSystemManager fsMan = VFS.getManager(); FileObject listenPath = fsMan.resolveFile(config.getContentFolder().toURI()); FileObject templateListenPath = fsMan.resolveFile(config.getTemplateFolder().toURI()); FileObject assetPath = fsMan.resolveFile(config.getAssetFolder().toURI()); logger.info("Watching for (content, template, asset) changes in [{}]", config.getSourceFolder().getPath()); DefaultFileMonitor monitor = new DefaultFileMonitor(new CustomFSChangeListener(config)); monitor.setRecursive(true); monitor.addFile(listenPath); monitor.addFile(templateListenPath); monitor.addFile(assetPath); monitor.start(); } catch (FileSystemException e) { logger.error("Problems watching filesystem changes", e); } } }
public AccumuloReloadingVFSClassLoader(String uris, FileSystemManager vfs, ReloadingClassLoader parent, long monitorDelay, boolean preDelegate) throws FileSystemException { this.uris = uris; this.parent = parent; this.preDelegate = preDelegate; ArrayList<FileObject> pathsToMonitor = new ArrayList<>(); files = AccumuloVFSClassLoader.resolve(vfs, uris, pathsToMonitor); if (preDelegate) cl = new VFSClassLoader(files, vfs, parent.getClassLoader()); else cl = new PostDelegatingVFSClassLoader(files, vfs, parent.getClassLoader()); monitor = new DefaultFileMonitor(this); monitor.setDelay(monitorDelay); monitor.setRecursive(false); for (FileObject file : pathsToMonitor) { monitor.addFile(file); log.debug("monitoring {}", file); } monitor.start(); }
FileSystemManager fsManager = VFS.getManager(); FileObject listendir = fsManager.resolveFile("/home/username/monitored/"); DefaultFileMonitor fm = new DefaultFileMonitor(new CustomFileListener()); fm.setRecursive(true); fm.addFile(listendir); fm.start();
private void startMonitor() { Logger logger = LogManager.getLogger(MyClass.class); try { FileSystemManager fileSystemManager = VFS.getManager(); FileObject dirToWatchFO = null; String path = "dir/you/want/to/watch"; File pathFile = new File(path); path = pathFile.getAbsolutePath(); dirToWatchFO = fileSystemManager.resolveFile(path); DefaultFileMonitor fileMonitor = new DefaultFileMonitor(new MyFancyFileListener()); fileMonitor.setRecursive(false); fileMonitor.addFile(dirToWatchFO); fileMonitor.start(); } catch (FileSystemException e) { logger.error("SOMETHING WENT WRONG!!", e); } }
fm.setRecursive(true); fm.addFile(listendir); fm.start();
public class PropertyManager implements FileListener{ @Override public void fileChanged(FileChangeEvent fileChangeEvent) { //Reload here into memory } } private register(STring fileName){ String pathToPropertyFile = new ClassPathResource(fileName).getFile().getPath(); FileSystemManager fsManager = VFS.getManager(); FileObject listenFile = fsManager.resolveFile(pathToPropertyFile); DefaultFileMonitor fm = new DefaultFileMonitor(this); fm.setRecursive(true); fm.addFile(listenFile); fm.setDelay(15000); fm.start(); } }
fileMonitor.setRecursive(false);
/** * 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); } } }
/** * Starts watching the file system for changes to trigger a bake. * * @param config JBakeConfiguration settings */ public void start(JBakeConfiguration config) { try { FileSystemManager fsMan = VFS.getManager(); FileObject listenPath = fsMan.resolveFile(config.getContentFolder().toURI()); FileObject templateListenPath = fsMan.resolveFile(config.getTemplateFolder().toURI()); FileObject assetPath = fsMan.resolveFile(config.getAssetFolder().toURI()); logger.info("Watching for (content, template, asset) changes in [{}]", config.getSourceFolder().getPath()); DefaultFileMonitor monitor = new DefaultFileMonitor(new CustomFSChangeListener(config)); monitor.setRecursive(true); monitor.addFile(listenPath); monitor.addFile(templateListenPath); monitor.addFile(assetPath); monitor.start(); } catch (FileSystemException e) { logger.error("Problems watching filesystem changes", e); } } }
fm.setRecursive( true ); fm.addFile( listendir ); fm.start();
public AccumuloReloadingVFSClassLoader(String uris, FileSystemManager vfs, ReloadingClassLoader parent, long monitorDelay, boolean preDelegate) throws FileSystemException { this.uris = uris; this.parent = parent; this.preDelegate = preDelegate; ArrayList<FileObject> pathsToMonitor = new ArrayList<>(); files = AccumuloVFSClassLoader.resolve(vfs, uris, pathsToMonitor); if (preDelegate) cl = new VFSClassLoader(files, vfs, parent.getClassLoader()); else cl = new PostDelegatingVFSClassLoader(files, vfs, parent.getClassLoader()); monitor = new DefaultFileMonitor(this); monitor.setDelay(monitorDelay); monitor.setRecursive(false); for (FileObject file : pathsToMonitor) { monitor.addFile(file); log.debug("monitoring " + file); } monitor.start(); }
fm.setRecursive(true); fm.setDelay(DIRECTORY_WATCH_DELAY_TIME); fm.addFile(directoryFile);