List of usage examples for java.util Properties keys
@Override
public Enumeration<Object> keys()
From source file:com.glaf.core.config.CustomProperties.java
public static void reload() { if (!loading.get()) { InputStream inputStream = null; try {// ww w .java2s . c om loading.set(true); String config = SystemProperties.getConfigRootPath() + "/conf/props"; logger.debug(config); File directory = new File(config); if (directory.exists()) { String[] filelist = directory.list(); if (filelist != null) { for (int i = 0, len = filelist.length; i < len; i++) { String filename = config + "/" + filelist[i]; logger.debug(filename); File file = new File(filename); if (file.isFile() && file.getName().endsWith(".properties")) { logger.info("load properties:" + file.getAbsolutePath()); inputStream = new FileInputStream(file); Properties p = PropertiesUtils.loadProperties(inputStream); if (p != null) { Enumeration<?> e = p.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); String value = p.getProperty(key); properties.setProperty(key, value); properties.setProperty(key.toLowerCase(), value); properties.setProperty(key.toUpperCase(), value); } } IOUtils.closeStream(inputStream); } } } } } catch (Exception ex) { throw new RuntimeException(ex); } finally { loading.set(false); IOUtils.closeStream(inputStream); } } }
From source file:org.apache.hadoop.hdfs.server.namenode.Namenode2Agent.java
/** * Key Value ?? ./*from w w w.jav a 2 s . co m*/ * * @param builder {@link StringBuilder} * @param props Key Value ? */ private static void print(StringBuilder builder, Properties props) { int maxLength = getMaxLength(props); Enumeration<Object> keys = props.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = props.getProperty(key); builder.append(" ").append(key).append(getCharacter(maxLength - key.getBytes().length, " ")) .append(" : ").append(value).append("\n"); } }
From source file:com.glaf.core.xml.XmlProperties.java
public static void reload() { if (!loading.get()) { InputStream inputStream = null; try {/*from w w w. j a v a 2 s. c o m*/ loading.set(true); String config = SystemProperties.getConfigRootPath() + "/conf/templates/xml"; File directory = new File(config); if (directory.exists() && directory.isDirectory()) { String[] filelist = directory.list(); if (filelist != null) { for (int i = 0, len = filelist.length; i < len; i++) { String filename = config + "/" + filelist[i]; File file = new File(filename); if (file.isFile() && file.getName().endsWith(".properties")) { inputStream = new FileInputStream(file); Properties p = PropertiesUtils.loadProperties(inputStream); if (p != null) { Enumeration<?> e = p.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); String value = p.getProperty(key); properties.setProperty(key, value); properties.setProperty(key.toLowerCase(), value); properties.setProperty(key.toUpperCase(), value); } } IOUtils.closeStream(inputStream); } } } } } catch (Exception ex) { throw new RuntimeException(ex); } finally { loading.set(false); IOUtils.closeStream(inputStream); } } }
From source file:com.glaf.core.config.MessageProperties.java
public static void reload() { if (!loading.get()) { InputStream inputStream = null; try {//from w w w . j av a 2 s . c o m loading.set(true); String config = SystemProperties.getConfigRootPath() + "/conf/props/messages"; File directory = new File(config); if (directory.exists() && directory.isDirectory()) { File[] filelist = directory.listFiles(); if (filelist != null) { for (int i = 0, len = filelist.length; i < len; i++) { String filename = config + "/" + filelist[i]; File file = new File(filename); if (file.isFile() && file.getName().endsWith(".properties")) { inputStream = new FileInputStream(file); Properties p = PropertiesUtils.loadProperties(inputStream); if (p != null) { Enumeration<?> e = p.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); String value = p.getProperty(key); properties.setProperty(key, value); properties.setProperty(key.toLowerCase(), value); properties.setProperty(key.toUpperCase(), value); } } IOUtils.closeStream(inputStream); } } } } ISystemPropertyService systemPropertyService = ContextFactory.getBean("systemPropertyService"); List<SystemProperty> list = systemPropertyService.getAllSystemProperties(); if (list != null && !list.isEmpty()) { for (SystemProperty p : list) { properties.put(p.getName(), p); } } } catch (Exception ex) { throw new RuntimeException(ex); } finally { loading.set(false); IOUtils.closeStream(inputStream); } } }
From source file:org.wso2.carbon.identity.governance.IdentityGovernanceUtil.java
public static void saveConnectorDefaultProperties(IdentityGovernanceConnector identityGovernanceConnector, String tenantDomain) throws IdentityGovernanceException { Properties connectorProperties = identityGovernanceConnector.getDefaultPropertyValues(tenantDomain); IdpManager identityProviderManager = IdentityMgtServiceDataHolder.getInstance().getIdpManager(); try {/*w w w . j av a 2 s.co m*/ Enumeration enuKeys = connectorProperties.keys(); IdentityProvider residentIdp = identityProviderManager.getResidentIdP(tenantDomain); IdentityProviderProperty[] idpProperties = residentIdp.getIdpProperties(); List<String> idpPropertyKeys = new ArrayList<>(); List<IdentityProviderProperty> propertyList = new ArrayList<>(); for (IdentityProviderProperty idpProperty : idpProperties) { String propertyName = idpProperty.getName(); if ((identityGovernanceConnector.getName() + "." + EventMgtConstants.PropertyConfig.ALREADY_WRITTEN_PROPERTY_KEY).equals(propertyName)) { if (log.isDebugEnabled()) { log.debug("Identity management property saving skipped for tenant : " + tenantDomain); } return; } idpPropertyKeys.add(idpProperty.getName()); propertyList.add(idpProperty); } while (enuKeys.hasMoreElements()) { String key = (String) enuKeys.nextElement(); String value = connectorProperties.getProperty(key); IdentityProviderProperty property = new IdentityProviderProperty(); property.setName(key); property.setValue(value); propertyList.add(property); } IdentityProviderProperty property = new IdentityProviderProperty(); property.setName(identityGovernanceConnector.getName() + "." + EventMgtConstants.PropertyConfig.ALREADY_WRITTEN_PROPERTY_KEY); property.setValue(EventMgtConstants.PropertyConfig.ALREADY_WRITTEN_PROPERTY_VALUE); propertyList.add(property); residentIdp.setIdpProperties(propertyList.toArray(new IdentityProviderProperty[propertyList.size()])); FederatedAuthenticatorConfig[] authenticatorConfigs = residentIdp.getFederatedAuthenticatorConfigs(); List<FederatedAuthenticatorConfig> configsToSave = new ArrayList<>(); for (FederatedAuthenticatorConfig authenticatorConfig : authenticatorConfigs) { if (IdentityApplicationConstants.Authenticator.PassiveSTS.NAME.equals(authenticatorConfig.getName()) || IdentityApplicationConstants.NAME.equals(authenticatorConfig.getName()) || IdentityApplicationConstants.Authenticator.SAML2SSO.NAME .equals(authenticatorConfig.getName())) { configsToSave.add(authenticatorConfig); } } residentIdp.setFederatedAuthenticatorConfigs( configsToSave.toArray(new FederatedAuthenticatorConfig[configsToSave.size()])); identityProviderManager.updateResidentIdP(residentIdp, tenantDomain); if (log.isDebugEnabled()) { log.debug("New resident IDP properties for tenant : " + tenantDomain + " written to database"); } } catch (IdentityProviderManagementException e) { log.error("Error while adding identity management properties to resident Idp.", e); } }
From source file:org.conf4j.service.ConfServiceInstance.java
private static final void initJVM(ConfValueMap conf) { final Properties properties = System.getProperties(); final Enumeration<?> e = properties.keys(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); final String value = properties.getProperty(name); name = normalise(name, JVM_PROPERTY, value); conf.put(name, value, JVM_PROPERTY); }//from w w w .ja va2s . c o m }
From source file:org.conf4j.service.ConfServiceInstance.java
private static final void initOS(ConfValueMap conf) { final Properties properties = Environment.getProperties(); final Enumeration<?> e = properties.keys(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); final String value = properties.getProperty(name); name = normalise(name, OS_PROPERTY, value); conf.put(name, value, OS_PROPERTY); }//from w w w . j a v a 2 s . com }
From source file:raptor.layout.CustomLayout.java
public static CustomLayout loadFromProperties(String pathToFile) { FileInputStream fileIn = null; try {/*from w w w . ja va2 s.c o m*/ fileIn = new FileInputStream(pathToFile); Properties properties = new Properties(); properties.load(fileIn); CustomLayout result = new CustomLayout(); result.setName(properties.getProperty(LAYOUT_NAME)); for (Enumeration<Object> e = properties.keys(); e.hasMoreElements();) { String key = (String) e.nextElement(); if (!StringUtils.equals(key, LAYOUT_NAME)) { String value = properties.getProperty(key); if (value.equals("null")) { value = null; } result.preferenceAdjustments.put(key, properties.getProperty(key)); } } return result; } catch (Throwable t) { Raptor.getInstance().onError("Error loading layout from file: " + pathToFile, t); return null; } finally { try { fileIn.close(); } catch (Throwable t) { } } }
From source file:org.openadaptor.util.PropertiesPoster.java
/** * Simple utility method to convert a set of properties into a string to send as part of email when there is a failure * to register.//from w w w . j ava 2 s . c o m * * @param properties * @return String containing appropriately encoded name/value pairs */ public static String generateString(Properties properties) { StringBuffer sb = new StringBuffer(); if (properties != null) { for (Enumeration keys = properties.keys(); keys.hasMoreElements();) { String key = (String) keys.nextElement(); String value = properties.getProperty(key); if (sb.length() > 0) {// Need separator between <name>=<value> pairs sb.append("\n"); } sb.append(key); sb.append("="); sb.append(value); } } // log.debug("Generated String:"+sb.toString()); return sb.toString(); }
From source file:org.apache.jcs.auxiliary.remote.RemoteUtils.java
/** * Loads properties for the named props file. * <p>// w w w . j a va2 s . c om * @param propFile * @return The properties object for the file * @throws IOException */ public static Properties loadProps(String propFile) throws IOException { InputStream is = RemoteUtils.class.getResourceAsStream(propFile); Properties props = new Properties(); try { props.load(is); if (log.isDebugEnabled()) { log.debug("props.size=" + props.size()); } if (log.isDebugEnabled()) { if (props != null) { Enumeration en = props.keys(); StringBuffer buf = new StringBuffer(); while (en.hasMoreElements()) { String key = (String) en.nextElement(); buf.append("\n" + key + " = " + props.getProperty(key)); } log.debug(buf.toString()); } else { log.debug("props is null"); } } } catch (Exception ex) { log.error("Error loading remote properties, for file name [" + propFile + "]", ex); } finally { if (is != null) { is.close(); } } return props; }