List of usage examples for java.util Properties keys
@Override
public Enumeration<Object> keys()
From source file:ORG.oclc.os.SRW.DSpaceLucene.SRWLuceneDatabase.java
private void getIndexSynonyms(Properties properties) { indexSynonyms.put("cql.serverChoice", ""); if (log.isDebugEnabled()) log.debug("new indexSynonym: cql.serverChoice=\"\""); if (properties == null) { if (log.isDebugEnabled()) log.debug("no properties file provided!"); return;// w w w . j a va2 s.c o m } Enumeration keys = properties.keys(); String index, key, value; if (keys == null) { if (log.isDebugEnabled()) log.debug("no properties specified in properties file"); return; } while (keys.hasMoreElements()) { key = (String) keys.nextElement(); if (key.startsWith("indexSynonym.")) { value = properties.getProperty(key); index = key.substring(13); if (log.isDebugEnabled()) log.debug("new indexSynonym: " + index + "=\"" + value + "\""); indexSynonyms.put(index, value); } } }
From source file:org.ow2.chameleon.core.ChameleonConfiguration.java
/** * Loads the chameleon properties file./* w ww . ja v a 2 s . c o m*/ * * @throws java.io.IOException if any. */ public void loadChameleonProperties() throws IOException { FileInputStream stream = null; try { File file = new File(baseDirectory.getAbsoluteFile(), Constants.CHAMELEON_PROPERTIES_FILE); Properties ps = new Properties(); // Load system properties first. ps.putAll(System.getProperties()); // If the properties file exist, loads it. if (file.isFile()) { stream = new FileInputStream(file); ps.load(stream); } // Apply substitution Enumeration keys = ps.keys(); while (keys.hasMoreElements()) { String k = (String) keys.nextElement(); String v = (String) ps.get(k); v = StringUtils.substVars(v, k, null, ps); if (k.endsWith("extra") && containsKey(k)) { // Append put(k, get(k) + "," + v); } else { // Replace put(k, v); } } } finally { IOUtils.closeQuietly(stream); } }
From source file:org.wso2.carbon.mediation.initializer.configurations.ConfigurationManager.java
/** * Initialize a newly created configuration. This will initialize the Synapse Env as well. * * @param configurationLocation file path which this configuration is based on * @param oldSynapseConfiguration previous synapse configuration * @param newSynapseConfiguration newly created synapse configuration * @param repository task repository/*from w w w .j av a2 s .c o m*/ * @param taskScheduler @throws ConfigurationInitilizerException if an error occurs * @throws org.apache.axis2.AxisFault if an error occurs * @throws ConfigurationInitilizerException if an error occurs */ private void initializeConfiguration(String configurationLocation, SynapseConfiguration oldSynapseConfiguration, SynapseConfiguration newSynapseConfiguration, TaskDescriptionRepository repository, TaskScheduler taskScheduler) throws ConfigurationInitilizerException, AxisFault { AxisConfiguration axisConfiguration = configurationContext.getAxisConfiguration(); // Set the Axis2 ConfigurationContext to the SynapseConfiguration newSynapseConfiguration.setAxisConfiguration(axisConfiguration); Entry hostEntry = oldSynapseConfiguration.getEntryDefinition(SynapseConstants.SERVER_HOST); Entry ipEntry = oldSynapseConfiguration.getEntryDefinition(SynapseConstants.SERVER_IP); // setup the properties Properties properties = SynapsePropertiesLoader.loadSynapseProperties(); if (properties != null) { Enumeration keys = properties.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); newSynapseConfiguration.setProperty(key, properties.getProperty(key)); } } // Add the old parameters to the new configuration newSynapseConfiguration.setPathToConfigFile(configurationLocation); newSynapseConfiguration.addEntry(SynapseConstants.SERVER_HOST, hostEntry); newSynapseConfiguration.addEntry(SynapseConstants.SERVER_IP, ipEntry); // Check for the main sequence and add a default main sequence if not present if (newSynapseConfiguration.getMainSequence() == null) { SynapseConfigUtils.setDefaultMainSequence(newSynapseConfiguration); } // Check for the fault sequence and add a deafult fault sequence if not present if (newSynapseConfiguration.getFaultSequence() == null) { SynapseConfigUtils.setDefaultFaultSequence(newSynapseConfiguration); } ServerContextInformation contextInformation = getServerContextInformation(); // set the synapse configuration to the axis2 configuration newSynapseConfiguration.setAxisConfiguration(axisConfiguration); Parameter synapseCtxParam = new Parameter(SynapseConstants.SYNAPSE_CONFIG, null); synapseCtxParam.setValue(newSynapseConfiguration); MessageContextCreatorForAxis2.setSynConfig(newSynapseConfiguration); //set up synapse env Parameter synapseEnvParam = new Parameter(SynapseConstants.SYNAPSE_ENV, null); Axis2SynapseEnvironment synEnv = new Axis2SynapseEnvironment(configurationContext, newSynapseConfiguration, contextInformation); synapseEnvParam.setValue(synEnv); MessageContextCreatorForAxis2.setSynEnv(synEnv); if (contextInformation != null) { // set the new information to the server context contextInformation.setSynapseEnvironment(synEnv); contextInformation.setSynapseConfiguration(newSynapseConfiguration); } else { throw new IllegalStateException("ServerContextInformation not found"); } try { axisConfiguration.addParameter(synapseCtxParam); axisConfiguration.addParameter(synapseEnvParam); } catch (AxisFault e) { String msg = "Could not set parameters '" + SynapseConstants.SYNAPSE_CONFIG + "' and/or '" + SynapseConstants.SYNAPSE_ENV + "'to the Axis2 configuration : " + e.getMessage(); throw new ConfigurationInitilizerException(msg, e); } // redeploy proxy services if (log.isTraceEnabled()) { log.trace("Re-deploying Proxy services..."); } for (ProxyService proxyService : newSynapseConfiguration.getProxyServices()) { if (proxyService != null) { proxyService.buildAxisService(newSynapseConfiguration, axisConfiguration); if (log.isDebugEnabled()) { log.debug("Deployed Proxy service : " + proxyService.getName()); } if (!proxyService.isStartOnLoad()) { proxyService.stop(newSynapseConfiguration); } } } if (log.isTraceEnabled()) { log.trace("Re-deploying Event Sources..."); } for (SynapseEventSource eventSource : newSynapseConfiguration.getEventSources()) { if (eventSource != null) { eventSource.buildService(axisConfiguration); if (log.isDebugEnabled()) { log.debug("Deployed Event Source : " + eventSource.getName()); } } } synEnv.getTaskManager().init(repository, taskScheduler, newSynapseConfiguration.getTaskManager()); // init the synapse configuration newSynapseConfiguration.init(synEnv); synEnv.setInitialized(true); }
From source file:org.xmlactions.action.config.ExecContext.java
/** * @deprecated - replaced with constructor ExecContext(List<Object> actionMaps, List<Object> localMaps, List<Object> themes) * @param actionMaps//from w ww .j a va 2s .c o m * @param localMaps */ public ExecContext(List<Object> actionMaps, List<Object> localMaps) { if (actionMaps != null) { for (Object object : actionMaps) { if (object instanceof Map) { Map<String, String> map = (Map<String, String>) object; this.actionMaps.get(DEFAULT_ACTION_MAP).putAll(map); } else if (object instanceof Properties) { Properties props = (Properties) object; Enumeration enumeration = props.keys(); while (enumeration.hasMoreElements()) { String key = (String) enumeration.nextElement(); this.actionMaps.get(DEFAULT_ACTION_MAP).put(key, props.getProperty(key)); } } } } if (localMaps != null) { for (Object object : localMaps) { if (object instanceof Map) { Map<String, String> map = (Map<String, String>) object; this.putAll(map); } else if (object instanceof Properties) { Properties props = (Properties) object; Enumeration enumeration = props.keys(); while (enumeration.hasMoreElements()) { String key = (String) enumeration.nextElement(); this.put(key, props.getProperty(key)); } } } } }
From source file:immf.StatusManager.java
public void load() throws IOException { Properties prop = new Properties(); FileInputStream fis = null;/* w ww. ja v a2s . c o m*/ try { fis = new FileInputStream(this.f); prop.load(fis); this.lastMailId = prop.getProperty("lastmailid"); this.pushCredentials = prop.getProperty("push_credentials"); String nc = prop.getProperty("needconnect"); if (this.needConnect == null) { this.needConnect = nc; } if (this.needConnect != null && !this.needConnect.equals("1")) { this.needConnect = nc; } Enumeration<Object> enu = prop.keys(); List<Cookie> list = new ArrayList<Cookie>(); while (enu.hasMoreElements()) { String key = (String) enu.nextElement(); if (key.startsWith("cookie_")) { String cookieName = key.substring(7); String val = prop.getProperty(key); String[] params = val.split(";"); BasicClientCookie c = new BasicClientCookie(cookieName, params[0]); for (int i = 1; i < params.length; i++) { String[] nameval = params[i].split("="); if (nameval[0].equalsIgnoreCase("path")) { c.setPath(nameval[1]); } else if (nameval[0].equalsIgnoreCase("domain")) { c.setDomain(nameval[1]); } } c.setSecure(true); log.debug("Load Cookie [" + c.getName() + "]=[" + c.getValue() + "]"); list.add(c); } } this.cookies = list; } finally { Util.safeclose(fis); } }
From source file:com.twitter.pig.backend.hadoop.executionengine.tez.TezExecutionEngine.java
/** * Method to apply pig properties to JobConf * (replaces properties with resulting jobConf values) * @param conf JobConf with appropriate hadoop resource files * @param properties Pig properties that will override hadoop properties; properties might be modified *///w w w. j ava2 s .c o m @SuppressWarnings("deprecation") private void recomputeProperties(JobConf jobConf, Properties properties) { // We need to load the properties from the hadoop configuration // We want to override these with any existing properties we have. if (jobConf != null && properties != null) { // set user properties on the jobConf to ensure that defaults // and deprecation is applied correctly Enumeration<Object> propertiesIter = properties.keys(); while (propertiesIter.hasMoreElements()) { String key = (String) propertiesIter.nextElement(); String val = properties.getProperty(key); // We do not put user.name, See PIG-1419 if (!key.equals("user.name")) jobConf.set(key, val); } //clear user defined properties and re-populate properties.clear(); Iterator<Map.Entry<String, String>> iter = jobConf.iterator(); while (iter.hasNext()) { Map.Entry<String, String> entry = iter.next(); properties.put(entry.getKey(), entry.getValue()); } } }
From source file:org.xmlactions.action.config.ExecContext.java
public ExecContext(List<Object> actionMaps, List<Object> localMaps, List<Object> themes) { if (actionMaps != null) { for (Object object : actionMaps) { if (object instanceof Map) { Map<String, String> map = (Map<String, String>) object; this.actionMaps.get(DEFAULT_ACTION_MAP).putAll(map); } else if (object instanceof Properties) { Properties props = (Properties) object; Enumeration enumeration = props.keys(); while (enumeration.hasMoreElements()) { String key = (String) enumeration.nextElement(); this.actionMaps.get(DEFAULT_ACTION_MAP).put(key, props.getProperty(key)); }/*ww w . j a v a 2 s . c om*/ } } } if (localMaps != null) { for (Object object : localMaps) { if (object instanceof Map) { Map<String, String> map = (Map<String, String>) object; this.putAll(map); } else if (object instanceof Properties) { Properties props = (Properties) object; Enumeration enumeration = props.keys(); while (enumeration.hasMoreElements()) { String key = (String) enumeration.nextElement(); this.put(key, props.getProperty(key)); } } else if (object instanceof XMLConfiguration) { addXmlConfiguration((XMLConfiguration) object); } } } if (themes != null) { for (Object object : themes) { if (object instanceof Theme) { addThemes((Theme) object); } else if (object instanceof Properties) { Properties props = (Properties) object; addThemes(props); } } } }
From source file:com.redhat.rcm.maven.plugin.buildmetadata.BuildReportRenderer.java
private void renderNonStandardProperties(final Properties buildMetaDataProperties) { final Properties nonStandardProperties = Constant.calcNonStandardProperties(buildMetaDataProperties, properties);//from w w w . jav a2 s . c om if (!nonStandardProperties.isEmpty()) { sink.sectionTitle2(); sink.text(messages.getString(Constant.SECTION_BUILD_MISC)); sink.sectionTitle2_(); renderTableStart(); for (final Enumeration<Object> en = nonStandardProperties.keys(); en.hasMoreElements();) { final String key = String.valueOf(en.nextElement()); if (Constant.isIntendedForMiscSection(key)) { renderCell(nonStandardProperties, key); } } renderTableEnd(); } }
From source file:fr.fastconnect.factory.tibco.bw.maven.packaging.MergePropertiesMojo.java
public MergedFiles mergeFiles(Properties propertiesGlobalVariables, Properties propertiesServices, File deploymentGlobalVariables, File deploymentServices, String messageGlobalVariables, String messageServices) throws MojoExecutionException, IOException { MergedFiles result = MergedFiles.NONE; // Merge with files if they exist if (deploymentGlobalVariables != null && deploymentGlobalVariables.exists() && !deploymentGlobalVariables .getCanonicalPath().equals(this.deploymentGlobalVariables.getCanonicalPath())) { // FIXME: check the checksum of files instead of canonical path ? getLog().info(messageGlobalVariables + " : " + deploymentGlobalVariables.getAbsolutePath()); Properties propertiesGlobalVariablesReference; try {//from www.ja va 2s.c o m propertiesGlobalVariablesReference = loadPropertiesFile(deploymentGlobalVariables); } catch (Exception e) { throw new MojoExecutionException(PROPERTIES_LOAD_FAILURE, e); } Enumeration<Object> e = propertiesGlobalVariablesReference.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); String value = propertiesGlobalVariablesReference.getProperty(key); propertiesGlobalVariables.setProperty(key, value); // add or override value } result = MergedFiles.GV; } Pattern pNotEmptyBinding = Pattern.compile(regexNotEmptyBinding); if (deploymentServices != null && deploymentServices.exists() && !deploymentServices.getCanonicalPath().equals(this.deploymentServices.getCanonicalPath())) { // FIXME: check the checksum of files instead of canonical path ? getLog().info(messageServices + " : " + deploymentServices.getAbsolutePath()); Properties propertiesServicesReference; try { propertiesServicesReference = loadPropertiesFile(deploymentServices); } catch (Exception e) { throw new MojoExecutionException(PROPERTIES_LOAD_FAILURE, e); } String par, binding; Enumeration<Object> e = propertiesServicesReference.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); Matcher mNotEmptyBinding = pNotEmptyBinding.matcher(key); if (mNotEmptyBinding.matches() && !isAWildCard(key)) { par = mNotEmptyBinding.group(1); binding = mNotEmptyBinding.group(2); ImmutablePair<String, String> pair = new ImmutablePair<String, String>(par, binding); if (!pairParInstance.contains(pair)) { propertiesServices = duplicateEmptyBinding(propertiesServices, par, binding); pairParInstance.add(pair); } } String value = propertiesServicesReference.getProperty(key); propertiesServices.setProperty(key, value); // add or override value } propertiesServices = expandWildCards(propertiesServices); if (result == MergedFiles.GV) { result = MergedFiles.BOTH; } else { result = MergedFiles.SERVICES; } } return result; }
From source file:org.pepstock.jem.node.StartUpSystem.java
/** * load the factories of the jem configuration checking if they are * configured//w w w . j a v a 2 s. co m * * @param conf the jem node config * @param substituter a VariableSubstituter containing all the System * properties * @throws ConfigurationException if some error occurs */ private static void loadFactories() throws ConfigurationException { // load factories, checking if they are configured. If not, exception // occurs List<Factory> factories = JEM_ENV_CONFIG.getFactories(); if (factories == null) { LogAppl.getInstance().emit(NodeMessage.JEMC009E, ConfigKeys.FACTORIES_ELEMENT); throw new ConfigurationException( NodeMessage.JEMC009E.toMessage().getFormattedMessage(ConfigKeys.FACTORIES_ELEMENT)); } if (factories.isEmpty()) { LogAppl.getInstance().emit(NodeMessage.JEMC009E, ConfigKeys.FACTORY_ALIAS); throw new ConfigurationException( NodeMessage.JEMC009E.toMessage().getFormattedMessage(ConfigKeys.FACTORY_ALIAS)); } // for all factories checking which have the right className. If not, // execption occurs, otherwise it's loaded for (Factory factory : factories) { if (factory.getClassName() != null) { String className = factory.getClassName(); try { ObjectAndClassPathContainer oacp = ClassLoaderUtil.loadAbstractPlugin(factory, PROPERTIES); Object objectFactory = oacp.getObject(); // check if it's a JemFactory. if not, exception occurs. if // yes, it's loaded on a map // with all factory. Remember the the key of map is getType // result, put to lowercase to ignore case // during the search by key if (objectFactory instanceof JemFactory) { JemFactory jf = (JemFactory) objectFactory; // gets properties defined. If not empty, substitutes // the value of property with variables Properties propsOfFactory = factory.getProperties(); if (propsOfFactory != null) { if (!propsOfFactory.isEmpty()) { // scans all properties for (Enumeration<Object> e = propsOfFactory.keys(); e.hasMoreElements();) { // gets key and value String key = e.nextElement().toString(); String value = propsOfFactory.getProperty(key); // substitutes variables if present // and sets new value for the key propsOfFactory.setProperty(key, substituteVariable(value)); } } } else { // creates however an emtpy collection to avoid null // pointer propsOfFactory = new Properties(); } jf.setClassPath(oacp.getClassPath()); // initializes the factory with properties defined // and puts in the list if everything went good jf.init(propsOfFactory); Main.FACTORIES_LIST.put(jf.getType().toLowerCase(), jf); LogAppl.getInstance().emit(NodeMessage.JEMC032I, className, jf.getType()); } else { LogAppl.getInstance().emit(NodeMessage.JEMC040E, className); } } catch (Exception e) { LogAppl.getInstance().emit(NodeMessage.JEMC031E, e, className); } // in this case the class name is null so ignore, emitting a // warning } else { LogAppl.getInstance().emit(NodeMessage.JEMC038W, ConfigKeys.FACTORY_ALIAS, factory.toString()); } } }