public Maven2MetadataProvider(String path, String dirMatcher, String fileMatcher) throws IOException { metadatas = new ConcurrentHashMap<String, Map<String, String>>(); root = Paths.get(path); watcher = new FileWatcher(); watcher.setRoot(root); if (dirMatcher != null && !dirMatcher.isEmpty()) { watcher.setDirMatchPattern(dirMatcher); } if (fileMatcher != null && !fileMatcher.isEmpty()) { watcher.setFileMatchPattern(fileMatcher); } watcher.setProcessor(new Processor() { @Override public void process(Path path) { scan(path); } @Override public void onRemove(Path path) { unscan(path); } }); watcher.init(); }
public void destroy() { watcher.destroy(); }
private void scan(final Path file) throws IOException { if (isMatchesFile(file)) { fireListeners(file, ENTRY_MODIFY); process(file); processedMap.put(file, Boolean.TRUE); } }
/** * Sets the file matching pattern using the * <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String)">java 7 pattern matching syntax</a> * such as <code>glob:*.xml</code> */ public void setFileMatchPattern(String pattern) { setFileMatcher(Matchers.parse(pattern, getFileSystem())); }
/** * Sets the directory matching pattern using the * <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String)">java 7 pattern matching syntax</a> * such as <code>glob:/foo/*</code> */ public void setDirMatchPattern(String pattern) { setDirMatcher(Matchers.parse(pattern, getFileSystem())); }
public void init() throws IOException { super.init(); LOG.info("Watching directory " + getRoot() + " for Spring XML files to load"); }
private void unscan(final Path file) throws IOException { if (isMatchesFile(file)) { Processor processor = getProcessor(); if (processor != null) { processor.onRemove(file); } lastModified = System.currentTimeMillis(); } else { // lets find all the files that now no longer exist List<Path> files = new ArrayList<Path>(processedMap.keySet()); for (Path path : files) { if (!Files.exists(path)) { LOGGER.debug("File has been deleted: " + path); processedMap.remove(path); if (isMatchesFile(path)) { Processor processor = getProcessor(); if (processor != null) { processor.onRemove(path); } fireListeners(path, ENTRY_DELETE); lastModified = System.currentTimeMillis(); } } } } }
public void setRootDirectory(File directory) { setRoot(directory.toPath()); }
public void init() throws IOException { if (root == null) { Iterable<Path> rootDirectories = getFileSystem().getRootDirectories(); for (Path rootDirectory : rootDirectories) { if (rootDirectory != null) { fail(LOGGER, "Root path does not exist: " + root); } else if (!Files.isDirectory(root)) { fail(LOGGER, "Root path is not a directory: " + root); watcher = watch ? getFileSystem().newWatchService() : null;
public void init() throws IOException { super.init(); LOG.info("Watching directory " + getRoot() + " for XML Schema files to dynamically compile"); }
private void unscan(final Path file) throws IOException { if (isMatchesFile(file)) { Processor processor = getProcessor(); if (processor != null) { processor.onRemove(file); } lastModified = System.currentTimeMillis(); } else { // lets find all the files that now no longer exist List<Path> files = new ArrayList<Path>(processedMap.keySet()); for (Path path : files) { if (!Files.exists(path)) { LOGGER.debug("File has been deleted: " + path); processedMap.remove(path); if (isMatchesFile(path)) { Processor processor = getProcessor(); if (processor != null) { processor.onRemove(path); } fireListeners(path, ENTRY_DELETE); lastModified = System.currentTimeMillis(); } } } } }
public void setRootDirectory(File directory) { setRoot(directory.toPath()); }
/** * Sets the file matching pattern using the * <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String)">java 7 pattern matching syntax</a> * such as <code>glob:*.xml</code> */ public void setFileMatchPattern(String pattern) { setFileMatcher(Matchers.parse(pattern, getFileSystem())); }
/** * Sets the directory matching pattern using the * <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String)">java 7 pattern matching syntax</a> * such as <code>glob:/foo/*</code> */ public void setDirMatchPattern(String pattern) { setDirMatcher(Matchers.parse(pattern, getFileSystem())); }
public void init() throws IOException { if (root == null) { Iterable<Path> rootDirectories = getFileSystem().getRootDirectories(); for (Path rootDirectory : rootDirectories) { if (rootDirectory != null) { fail(LOGGER, "Root path does not exist: " + root); } else if (!Files.isDirectory(root)) { fail(LOGGER, "Root path is not a directory: " + root); watcher = watch ? getFileSystem().newWatchService() : null;
public void init() throws IOException { if (camelContext == null) { throw new IllegalArgumentException("CamelContext must be configured on " + this); } mapper = new DozerBeanMapper(); setFileMatchPattern("glob:META-INF/services/dozer/*.xml"); setProcessor(new Processor() { public void process(Path path) { addOrUpdateMapping(path); } public void onRemove(Path path) { removeMapping(path); } }); super.init(); LOG.info("Watching directory " + getRoot() + " for Dozer XML Mapping file changes"); }
@Override public void destroy() { if (mapper != null) { mapper.destroy(); } super.destroy(); }
private void scan(final Path file) throws IOException { if (isMatchesFile(file)) { fireListeners(file, ENTRY_MODIFY); process(file); processedMap.put(file, Boolean.TRUE); } }
public void setRootPath(String rootPath) { Path path = new File(rootPath).getAbsoluteFile().toPath(); setRoot(path); }
public void destroy() { if (closing.compareAndSet(false, true)) { Set<Map.Entry<String, FileSystemXmlApplicationContext>> entries = contextMap.entrySet(); for (Map.Entry<String, FileSystemXmlApplicationContext> entry : entries) { String url = entry.getKey(); FileSystemXmlApplicationContext context = entry.getValue(); closeContext(url, context); } } super.destroy(); }