List of usage examples for java.util Properties keySet
@Override
public Set<Object> keySet()
From source file:com.util.InstallUtil.java
private void processFile(File template, File destFile, Properties properties) { template.getParentFile().mkdirs();//ww w.ja va2 s. c o m String content = FileUtil.readFile(template); for (Object k : properties.keySet()) { String key = (String) k; String value = properties.getProperty(key); value = replacePathSlash(value); content = content.replace("%%" + key + "%%", value); } try { FileUtil.writeFile(destFile, content); } catch (IOException e) { log.error(e.getMessage(), e); UI ui = UIFactory.getUI(); ui.confirmContinue("Failed to generate mail-service.xml."); return; } log.info("Success to generate " + template.getName()); }
From source file:org.apache.ode.utils.HierarchicalProperties.java
private void validatePropertyNames(Properties props, File file) { List invalids = new ArrayList(); for (Iterator<Object> it = props.keySet().iterator(); it.hasNext();) { String name = (String) it.next(); if (name.startsWith("system.") || name.startsWith("env.")) invalids.add(name);/*from w w w.j a v a 2s .c o m*/ } if (!invalids.isEmpty()) { throw new IllegalArgumentException( "Property files cannot define properties starting with 'system.' nor 'env.' File=" + file + ". Invalid names=" + StringUtils.join(invalids, ",")); } }
From source file:nor.core.Nor.java
private void init(final List<URL> jarUrls) throws IOException { LOGGER.entering("init"); /*/*from ww w . j a v a2 s .c o m*/ * Create a proxy server. */ this.server = new ProxyServer(this.handler, this.router); final String pluginPath = System.getProperty("nor.plugin"); if (pluginPath != null) { final File dir = new File(pluginPath); if (dir.isDirectory()) { for (final File f : dir.listFiles()) { try { jarUrls.add(f.toURI().toURL()); } catch (final MalformedURLException e) { LOGGER.catched(Level.WARNING, "init", e); } } } } /* * Load installed plugins */ for (final URL url : jarUrls) { final URLClassLoader loader = new URLClassLoader(new URL[] { url }); for (final Plugin p : ServiceLoader.load(Plugin.class, loader)) { final String name = p.getClass().getName(); if (this.enable(p)) { final File common = new File(this.rootConfDir, String.format(ConfigFileTemplate, name)); final File local = new File(this.localConfDir, String.format(ConfigFileTemplate, name)); p.init(common, local); this.server.attach(p); this.plugins.add(p); LOGGER.info("init", "Loading a plugin {0}", p.getClass().getName()); } } } /* * Load a routing table. */ final File route = new File(this.localConfDir, "route.conf"); if (!route.exists()) { final InputStream in = this.getClass().getResourceAsStream("route.conf"); final BufferedReader r = new BufferedReader(new InputStreamReader(in)); final PrintWriter w = new PrintWriter(new FileWriter(route)); String buf; while ((buf = r.readLine()) != null) { w.println(buf); } w.close(); r.close(); } final Properties routings = new Properties(); final Reader rin = new FileReader(route); routings.load(rin); rin.close(); for (final Object key : routings.keySet()) { final String skey = (String) key; this.router.put(skey, routings.getProperty(skey)); } LOGGER.exiting("init"); }
From source file:org.apache.directory.fortress.core.impl.PropertyDAO.java
/** * Update properties on the provided entity using the provided property provider * * @param entity A FortressEntity that supports properties (Role, AdminRole, Group, Permission, PermObj) * @param properties//from w w w .ja va 2 s . com * @param propProvider DAO for entity type that implements property provider interface * @return Entity with current property value * @throws UpdateException * @throws FinderException */ FortEntity updateProperties(FortEntity entity, Properties properties, PropertyProvider propProvider) throws UpdateException, FinderException { //ftProps all have same name, so will need to delete proprs first, then readd ones that are approprirate //get current properties Properties currentProps = this.getProperties(entity, propProvider); Properties toDeleteProps = new Properties(); //look for proeprties (ftProp=key:value) that are being updated and add to delete list for (Object key : properties.keySet()) { String value = currentProps.getProperty((String) key); toDeleteProps.put((String) key, value); } //delete exising properties this.deleteProperties(entity, toDeleteProps, propProvider); //add the udpates back this.addProperties(entity, properties, propProvider); return propProvider.getEntity(entity); }
From source file:org.apache.falcon.util.ApplicationProperties.java
private void doLoadProperties(InputStream resourceAsStream) throws IOException, FalconException { Properties origProps = new Properties(); origProps.load(resourceAsStream);/* w w w .j a va2 s.c o m*/ if (domain == null) { domain = origProps.getProperty("*.domain"); if (domain == null) { throw new FalconException("Domain is not set!"); } else { domain = ExpressionHelper.substitute(domain); } } LOG.info("Initializing {} properties with domain {}", this.getClass().getName(), domain); Set<String> keys = getKeys(origProps.keySet()); for (String key : keys) { String value = origProps.getProperty(domain + "." + key, origProps.getProperty("*." + key)); if (value != null) { value = ExpressionHelper.substitute(value); LOG.debug("{}={}", key, value); put(key, value); } } }
From source file:com.okidokiteam.gouken.kernel.CoreVault.java
private Map<String, Object> getFrameworkConfig() throws IOException { InputStream ins = getClass().getResourceAsStream(META_INF_GOUKEN_KERNEL_PROPERTIES); Properties descriptor = new Properties(); if (ins != null) { descriptor.load(ins);/*ww w.ja va2 s. c om*/ } final Map<String, Object> p = new HashMap<String, Object>(); File worker = new File(m_settings.getWorkingFolder(), "framework"); p.put("org.osgi.framework.storage", worker.getAbsolutePath()); // p.put( "felix.log.level", "1" ); configureBridgingServiceDelegation(p); for (Object key : descriptor.keySet()) { p.put((String) key, descriptor.getProperty((String) key)); } return p; }
From source file:com.kyne.webby.rtk.web.WebServer.java
public Map<String, Object> getConfJSON() { final Map<String, Object> data = new HashMap<String, Object>(); FileInputStream in = null;/*from ww w . j a v a2s. c o m*/ try { final Properties properties = new Properties(); in = new FileInputStream("server.properties"); properties.load(in); for (final Object key : properties.keySet()) { data.put((String) key, properties.getProperty((String) key)); } } catch (final FileNotFoundException e) { LogHelper.error("Unable to find bukkit configuration file", e); } catch (final IOException e) { LogHelper.error("Unable to read bukkit configuration file", e); } finally { try { if (in != null) { in.close(); } } catch (final IOException ex) { /**/ } } return data; }
From source file:com.kyne.webby.rtk.web.WebServer.java
public String getDefaultWorldName() { FileInputStream in = null;// w ww .ja v a 2s . c o m try { final Properties properties = new Properties(); in = new FileInputStream("server.properties"); properties.load(in); for (final Object key : properties.keySet()) { if ("level-name".equals(key)) { return properties.getProperty((String) key); } } } catch (final FileNotFoundException e) { LogHelper.error("Unable to find bukkit configuration file", e); } catch (final IOException e) { LogHelper.error("Unable to read bukkit configuration file", e); } finally { try { if (in != null) { in.close(); } } catch (final IOException ex) { /**/ } } return null; }
From source file:com.util.InstallUtil.java
/** * @throws IOException//w ww .j a v a2s . com */ public void parseAllTemplates() throws IOException { InstallValues.addAdditionalInstallValues(); URL url = InstallUtil.class.getClassLoader().getResource("generateFiles.properties"); Properties properties = new Properties(); InputStream in = url.openStream(); properties.load(in); Properties installValues = getProperties(); for (Object ob : properties.keySet()) { String path = (String) ob; File f1 = new File(ServerUtil.getPath() + "/" + path); File f2 = new File(ServerUtil.getPath() + "/" + properties.getProperty(path)); try { processFile(f1, f2, installValues); } catch (Exception e) { log.error("Failed to parse " + f1.getPath() + " to " + f2.getPath()); log.error(e); continue; } } }
From source file:com.impetus.client.hbase.schemamanager.HBaseSchemaManager.java
/** * Sets the external properties.// ww w .ja v a2 s. com * * @param name * the name * @param hColumnDescriptor * the h column descriptor */ private void setExternalProperties(String name, HColumnDescriptor hColumnDescriptor) { Properties properties = externalProperties != null ? externalProperties.get(name) : null; if (properties != null && !properties.isEmpty()) { for (Object obj : properties.keySet()) { hColumnDescriptor.setValue(Bytes.toBytes(obj.toString()), Bytes.toBytes(properties.get(obj).toString())); } } }