List of usage examples for java.util Properties keys
@Override
public Enumeration<Object> keys()
From source file:com.seajas.search.utilities.spring.i18n.AccessibleReloadableResourceBundleMessageSource.java
/** * Retrieve all messages for a given locale. * /*from w w w . ja v a 2 s.c om*/ * @param locale * @return Map<String, String> */ public Map<String, String> getAllMessages(final Locale locale) { Map<String, String> messages = new HashMap<String, String>(); // Should be internally synchronized, so we shouldn't run into any deadlock issues PropertiesHolder propertiesHolder = getMergedProperties(locale); Properties properties = propertiesHolder.getProperties(); for (Enumeration<Object> enumeration = properties.keys(); enumeration.hasMoreElements();) { String key = (String) enumeration.nextElement(); messages.put(key, propertiesHolder.getProperty(key)); } return messages; }
From source file:com.glaf.core.execution.ExecutionManager.java
public void execute() { if (!running.get()) { String defaultSystemName = Environment.getCurrentSystemName(); try {// ww w . jav a 2 s . c o m running.set(true); ExecutionProperties.reload(); Properties props = ExecutionProperties.getProperties(); if (props != null && props.keys().hasMoreElements()) { Enumeration<?> e = props.keys(); while (e.hasMoreElements()) { String className = (String) e.nextElement(); String content = props.getProperty(className); Object object = ClassUtils.instantiateObject(className); if (object instanceof ExecutionHandler) { ExecutionHandler handler = (ExecutionHandler) object; Map<String, Properties> dataSourceProperties = DBConfiguration .getDataSourceProperties(); Iterator<String> iter = dataSourceProperties.keySet().iterator(); while (iter.hasNext()) { String systemName = (String) iter.next(); Environment.setCurrentSystemName(systemName); try { handler.execute(content); } catch (Exception ex) { ex.printStackTrace(); logger.error(ex); } } } } } } catch (Exception ex) { ex.printStackTrace(); throw new RuntimeException(ex); } finally { Environment.setCurrentSystemName(defaultSystemName); running.set(false); } } }
From source file:com.glaf.core.execution.SolitaryExecutionManager.java
/** * ?/* ww w . j a v a2 s. c o m*/ * * @param configFile * ? * confexec.properties?/conf/exec.properties */ public void execute(String configFile) { if (!running.get()) { try { running.set(true); if (!configFile.startsWith("/")) { configFile = "/" + configFile; } String filename = SystemProperties.getConfigRootPath() + configFile; Properties props = PropertiesUtils.loadFilePathResource(filename); if (props != null && props.keys().hasMoreElements()) { Enumeration<?> e = props.keys(); while (e.hasMoreElements()) { String className = (String) e.nextElement(); String content = props.getProperty(className); Object object = ClassUtils.instantiateObject(className); if (object instanceof ExecutionHandler) { ExecutionHandler handler = (ExecutionHandler) object; try { handler.execute(content); } catch (Exception ex) { ex.printStackTrace(); logger.error(ex); } } } } } catch (Exception ex) { ex.printStackTrace(); throw new RuntimeException(ex); } finally { running.set(false); } } }
From source file:org.smartfrog.avalanche.client.sf.exec.ant.AntUtils.java
private void setUserProperties(Properties properties) { Enumeration e = properties.keys(); while (e.hasMoreElements()) { String userProperty = (String) e.nextElement(); String value = (String) properties.get(userProperty); project.setUserProperty(userProperty, value); }/* ww w .j a v a2 s . co m*/ }
From source file:io.wcm.config.core.override.impl.SystemPropertyOverrideProvider.java
@Activate void activate(final ComponentContext ctx) { Dictionary config = ctx.getProperties(); final boolean enabled = PropertiesUtil.toBoolean(config.get(PROPERTY_ENABLED), DEFAULT_ENABLED); Map<String, String> map = new HashMap<>(); if (enabled) { Properties properties = System.getProperties(); Enumeration<Object> keys = properties.keys(); while (keys.hasMoreElements()) { Object keyObject = keys.nextElement(); if (keyObject instanceof String) { String key = (String) keyObject; if (StringUtils.startsWith(key, SYSTEM_PROPERTY_PREFIX)) { map.put(StringUtils.substringAfter(key, SYSTEM_PROPERTY_PREFIX), System.getProperty(key)); }/*from w ww. java 2 s . c o m*/ } } } this.overrideMap = ImmutableMap.copyOf(map); }
From source file:com.tera.common.configuration.properties.CPropertyLoader.java
/** * @param properties// ww w . jav a2s .co m */ private void fillPropertiesMap(Properties properties) { Enumeration<Object> keys = properties.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); loadedProperties.put(key, properties.getProperty(key)); } }
From source file:org.formic.ant.Property.java
/** * Executes this task./*w w w . ja v a 2 s .c om*/ */ public void execute() throws BuildException { InputStream in = Installer.class.getResourceAsStream(resource); if (in == null) { throw new BuildException("Resource not found: " + resource); } try { Project project = getProject(); Properties properties = new Properties(); properties.load(in); Enumeration keys = properties.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); project.setProperty(key, properties.getProperty(key)); } } catch (IOException ioe) { throw new BuildException(ioe); } finally { IOUtils.closeQuietly(in); } }
From source file:org.sakaiproject.metaobj.utils.ioc.ApplicationContextFactory.java
public String[] getConfigLocations(Properties props) throws IOException { SortedMap configFiles = new TreeMap(); for (Enumeration e = props.keys(); e.hasMoreElements();) { Integer key = new Integer((String) e.nextElement()); String curFile = props.getProperty(key.toString()); curFile = (!curFile.startsWith("/")) ? "/" + curFile : curFile; configFiles.put(key, curFile);/*from w w w . j a v a 2s. co m*/ logger.info("registering '" + curFile + "' in position " + key + " as spring bean definition file"); } return convertToArray(configFiles.values()); }
From source file:org.apache.archiva.configuration.MavenProxyPropertyLoader.java
@SuppressWarnings("unchecked") private Properties getSubset(Properties props, String prefix) { Enumeration keys = props.keys(); Properties result = new Properties(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = props.getProperty(key); if (key.startsWith(prefix)) { String newKey = key.substring(prefix.length()); result.setProperty(newKey, value); }/*from w w w .j a v a2s . co m*/ } return result; }
From source file:es.itecban.deployment.security.client.ws.RoleManager.java
public void setPropertiesResource(Resource propertiesResource) throws Exception { this.propertiesResource = propertiesResource; Properties p = new Properties(); p.load(propertiesResource.getInputStream()); Enumeration keys = p.keys(); if (keys != null) { while (keys.hasMoreElements()) { String rname = (String) keys.nextElement(); String roles = p.getProperty(rname); String[] ritems = roles.split(","); if (ritems == null) { ritems = new String[] { DEFAULT_USER }; }/* w w w . j a v a 2s . c o m*/ if (ritems.length > 1) { String[] temp = new String[ritems.length - 1]; for (int i = 0; i < temp.length; i++) { temp[i] = ritems[i + 1].trim(); } } //Add the user to the users list if (!this.users.containsKey(rname)) this.users.put(rname, ritems[0]); //Add roles to the users this.roleMap.put(rname, ritems); } } }