protected void fireListeners(Path child, WatchEvent.Kind kind) { List<WatcherListener> list = getListeners(); for (WatcherListener listener : list) { listener.onWatchEvent(child, kind); } } }
/** * Converts the given Path to a URL string */ public static String toUrlString(Path path) throws MalformedURLException { return toURL(path).toString(); }
protected void removePath(Path path) { try { String url = toUrlString(path); FileSystemXmlApplicationContext context = contextMap.remove(url); closeContext(url, context); } catch (MalformedURLException e) { LOG.warn("Ignored path " + path + " due to: " + e, e); } }
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(); } } } } }
protected void addPath(Path path) { String url = null; try { url = toUrlString(path); } catch (MalformedURLException e) { LOG.warn("Ignored path " + path + " due to: " + e, e); } if (url != null) { FileSystemXmlApplicationContext context = contextMap.get(url); if (context != null) { try { LOG.info("Refreshing context at path " + path + " context " + context); context.refresh(); } catch (Exception e) { LOG.warn("Failed to refresh context at " + path + " context " + context + ". " + e, e); } } else { context = createContext(path, url); if (context != null) { contextMap.put(url, context); try { LOG.info("Starting context at path " + path + " context " + context); context.start(); } catch (Exception e) { LOG.warn("Failed to start context at " + path + " context " + context + ". " + e, e); } } } } }
protected void removeCompilePath(Path path) { try { String url = toUrlString(path); Path old = urlMap.remove(url); if (old != null) { scheduleRecompile(); } } catch (MalformedURLException e) { LOG.warn("Ignored path " + path + " due to: " + e, e); } }
/** * Returns true if the file can be parsed as XML and it contains one of the given namespace URs */ public static boolean hasNamespace(Path file, String... namespaceURis) { try { return XmlHelper.hasNamespace(getNamespaces(file), namespaceURis); } catch (Exception e) { LOG.warn("Failed to parse XML " + file + ". " + e, e); return false; } }
@Override public void run() { try { processor.process(path); lastModified = System.currentTimeMillis(); } finally { processing.decrementAndGet(); synchronized (processing) { processing.notifyAll(); } } } });
protected FileSystemXmlApplicationContext createContext(Path path, String url) { if (!Paths.hasNamespace(path, SPRING_BEANS_NAMESPACE_URI)) { LOG.info("Ignoring XML file " + path + " which is not a spring XML"); return null; } String[] locations = {url}; if (parentApplicationContext != null) { return new FileSystemXmlApplicationContext(locations, true, parentApplicationContext); } else { return new FileSystemXmlApplicationContext(locations, true); } }
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(); } } } } }
protected void fireListeners(Path child, WatchEvent.Kind kind) { List<WatcherListener> list = getListeners(); for (WatcherListener listener : list) { listener.onWatchEvent(child, kind); } } }
protected void addCompilePath(Path path) { try { String url = toUrlString(path); Path old = urlMap.put(url, path); if (old == null) { scheduleRecompile(); } } catch (MalformedURLException e) { LOG.warn("Ignored path " + path + " due to: " + e, e); } }
/** * Converts the given Path to a URL string */ public static String toUrlString(Path path) throws MalformedURLException { return toURL(path).toString(); }
/** * Returns true if the file can be parsed as XML and it contains one of the given namespace URs */ public static boolean hasNamespace(Path file, String... namespaceURis) { try { return XmlHelper.hasNamespace(getNamespaces(file), namespaceURis); } catch (Exception e) { LOG.warn("Failed to parse XML " + file + ". " + e, e); return false; } }
@Override public void run() { try { processor.process(path); lastModified = System.currentTimeMillis(); } finally { processing.decrementAndGet(); synchronized (processing) { processing.notifyAll(); } } } });