List of usage examples for org.apache.commons.vfs.impl DefaultFileMonitor setRecursive
public void setRecursive(final boolean newRecursive)
From source file:com.sonatype.nexus.plugin.groovyconsole.DefaultScriptStorage.java
public void initialize() throws InitializationException { scripts = new LinkedHashMap<String, String>(); FileObject listendir;//from w ww . j a v a2 s . c o m try { FileSystemManager fsManager = VFS.getManager(); scriptDir = applicationConfiguration.getWorkingDirectory("scripts"); if (!scriptDir.exists()) { scriptDir.mkdirs(); try { new File(scriptDir, "place your .groovy files here.txt").createNewFile(); } catch (IOException e) { throw new InitializationException(e.getMessage(), e); } } listendir = fsManager.resolveFile(scriptDir.getAbsolutePath()); } catch (FileSystemException e) { throw new InitializationException(e.getMessage(), e); } FileSelector selector = new FileSelector() { public boolean traverseDescendents(FileSelectInfo arg0) throws Exception { return true; } public boolean includeFile(FileSelectInfo arg0) throws Exception { return isScriptFile(arg0.getFile()); } }; try { FileObject[] availableScripts = listendir.findFiles(selector); for (FileObject fileObject : availableScripts) { updateScript(fileObject); } } catch (FileSystemException e) { getLogger().warn("Unable to perform initial directory scan.", e); } DefaultFileMonitor fm = new DefaultFileMonitor(this); fm.setRecursive(true); fm.addFile(listendir); fm.start(); this.fileMonitor = fm; }
From source file:org.innobuilt.fincayra.FincayraApplication.java
public void watch(String fileName) { if (this.getReloadRootScope()) { LOGGER.info("Adding file to root scope watch: {}", fileName); try {// w w w . j a v a 2s . c om FileSystemManager fsManager = VFS.getManager(); FileObject listendir = fsManager.resolveFile(fileName); DefaultFileMonitor fm = new DefaultFileMonitor(new FincayraFileListener()); fm.setRecursive(true); fm.addFile(listendir); fm.start(); } catch (FileSystemException e) { LOGGER.error("Unable to watch directory: {}", fileName); } } }