public boolean refresh() { plugins = null; // We always refresh our plugins if (propertiesFile == null) return false; boolean changed = updateModified(propertiesFile.lastModified(), "properties file"); if (included != null) { for (File file : included) { if (changed) break; changed |= !file.exists() || updateModified(file.lastModified(), "include file: " + file); } } if (changed) { forceRefresh(); return true; } return false; }
/** * Helper to load a properties file from disk. * * @param file * @return * @throws IOException */ public Properties loadProperties(File file) throws IOException { updateModified(file.lastModified(), "Properties file: " + file); InputStream in = new FileInputStream(file); Properties p = loadProperties(in, file.getAbsolutePath()); in.close(); return p; }
/** * Helper to load a properties file from disk. * * @param file * @return * @throws IOException */ public Properties loadProperties(File file) throws IOException { updateModified(file.lastModified(), "Properties file: " + file); InputStream in = new FileInputStream(file); Properties p = loadProperties(in, file.getAbsolutePath()); in.close(); return p; }
/** * @param file * @param parent * @param done * @param overwrite * @throws FileNotFoundException * @throws IOException */ public void doIncludeFile(File file, boolean overwrite, Properties target) throws Exception { if (included != null && included.contains(file)) { error("Cyclic or multiple include of " + file); } else { addIncluded(file); updateModified(file.lastModified(), file.toString()); InputStream in = new FileInputStream(file); Properties sub; if (file.getName().toLowerCase().endsWith(".mf")) { sub = getManifestAsProperties(in); } else sub = loadProperties(in, file.getAbsolutePath()); in.close(); doIncludes(file.getParentFile(), sub); // make sure we do not override properties for (Map.Entry<?, ?> entry : sub.entrySet()) { if (overwrite || !target.containsKey(entry.getKey())) target.setProperty((String) entry.getKey(), (String) entry.getValue()); } } }
} else { addIncluded(file); updateModified(file.lastModified(), "Include " + value); InputStream in = new FileInputStream(file);