List of usage examples for java.util Properties propertyNames
public Enumeration<?> propertyNames()
From source file:org.ebayopensource.turmeric.tools.codegen.ServiceGeneratorSharedConsumerTest.java
private void createConsumerPropsFile(File basedir, Properties props) throws Exception { File file = new File(basedir, "service_consumer_project.properties"); Properties pro = loadProperties(file); Enumeration<?> names = props.propertyNames(); while (names.hasMoreElements()) { String key = (String) names.nextElement(); String value = props.getProperty(key); pro.setProperty(key, value);//from w ww. j ava2 s . co m } writeProperties(file, pro); }
From source file:org.intermine.web.logic.config.WebConfig.java
/** * Load a set of files into a single merged properties file. These files should all be * located in the WEB-INF directory of the webapp war. * * @param fileNames The file names to load. * @throws FileNotFoundException If a file is listed but does not exist in WEB-INF. * @throws IllegalStateException If two files configure the same key. * @throws IOException if the properties cannot be loaded. *//*www . j a va 2 s . c o m*/ private static Properties loadMergedProperties(final List<String> fileNames, final ServletContext context) throws IOException { final Properties props = new Properties(); for (final String fileName : fileNames) { LOG.info("Loading properties from " + fileName); final Properties theseProps = new Properties(); final InputStream is = context.getResourceAsStream("/WEB-INF/" + fileName); if (is == null) { throw new FileNotFoundException("Could not find mappings file: " + fileName); } try { theseProps.load(is); } catch (final IOException e) { throw new Error("Problem reading from " + fileName, e); } if (!props.isEmpty()) { for (@SuppressWarnings("rawtypes") final Enumeration e = props.propertyNames(); e.hasMoreElements();) { final String key = (String) e.nextElement(); if (theseProps.containsKey(key)) { throw new IllegalStateException("Duplicate label found for " + key + " in " + fileName); } } } if (theseProps.isEmpty()) { LOG.info("No properties loaded from " + fileName); } else { LOG.info("Merging in " + theseProps.size() + " mappings from " + fileName); props.putAll(theseProps); } } return props; }
From source file:mil.dod.th.ose.junit4xmltestrunner.ant.XMLJUnitResultFormatter.java
/** * The whole test suite started./* w ww .j a v a 2s.c om*/ */ public void startTestSuite(final String name) // NOCHECKSTYLE: no documentation, file modified from 3rd party { m_Doc = getDocumentBuilder().newDocument(); m_RootElement = m_Doc.createElement(TESTSUITE); m_RootElement.setAttribute(ATTR_NAME, name); //add the timestamp final String timestamp = DateUtils.format(new Date(), DateUtils.ISO8601_DATETIME_PATTERN); m_RootElement.setAttribute(TIMESTAMP, timestamp); //and the hostname. m_RootElement.setAttribute(HOSTNAME, getHostname()); // Output properties final Element propsElement = m_Doc.createElement(PROPERTIES); m_RootElement.appendChild(propsElement); final Properties props = System.getProperties(); if (props != null) { final Enumeration<?> e = props.propertyNames(); while (e.hasMoreElements()) { final String propName = (String) e.nextElement(); final Element propElement = m_Doc.createElement(PROPERTY); propElement.setAttribute(ATTR_NAME, propName); propElement.setAttribute(ATTR_VALUE, props.getProperty(propName)); propsElement.appendChild(propElement); } } m_OldStdOut = System.out; System.setOut(new PrintStream(m_TeeOutStream)); m_OldStdErr = System.err; System.setErr(new PrintStream(m_TeeErrStream)); }
From source file:org.apache.hadoop.mapred.ClusterWithCapacityScheduler.java
/** * Start the cluster with numTaskTrackers TaskTrackers and numDataNodes * DataNodes and configure the cluster with clusterProperties and the * scheduler with schedulerProperties. Uses default configuration whenever * user provided properties are missing (null/empty) * /*from www .ja va 2 s. com*/ * @param numTaskTrackers * @param clusterProperties * @param schedulerProperties * @throws IOException */ protected void startCluster(int numTaskTrackers, Properties clusterProperties, Properties schedulerProperties) throws IOException { Thread.currentThread().setContextClassLoader(new ClusterWithCapacityScheduler.MyClassLoader()); JobConf clusterConf = new JobConf(); if (clusterProperties != null) { for (Enumeration<?> e = clusterProperties.propertyNames(); e.hasMoreElements();) { String key = (String) e.nextElement(); clusterConf.set(key, (String) clusterProperties.get(key)); } } if (schedulerProperties != null) { setUpSchedulerConfigFile(schedulerProperties); } clusterConf.set("mapred.jobtracker.taskScheduler", CapacityTaskScheduler.class.getName()); mrCluster = new MiniMRCluster(numTaskTrackers, "file:///", 1, null, null, clusterConf); this.jobConf = mrCluster.createJobConf(clusterConf); }
From source file:org.apache.maven.plugin.surefire.report.StatelessXmlReporter.java
/** * Adds system properties to the XML report. * <p/>/*from ww w . j a v a 2 s . c o m*/ * * @param xmlWriter The test suite to report to */ private void showProperties(XMLWriter xmlWriter) { xmlWriter.startElement("properties"); Properties systemProperties = System.getProperties(); if (systemProperties != null) { Enumeration<?> propertyKeys = systemProperties.propertyNames(); while (propertyKeys.hasMoreElements()) { String key = (String) propertyKeys.nextElement(); String value = systemProperties.getProperty(key); if (value == null) { value = "null"; } xmlWriter.startElement("property"); xmlWriter.addAttribute("name", key); xmlWriter.addAttribute("value", extraEscape(value, true)); xmlWriter.endElement(); } } xmlWriter.endElement(); }
From source file:org.intermine.bio.dataconversion.ReactomeConverter.java
private void readConfig() { Properties props = new Properties(); try {//w w w . ja v a2 s .c o m props.load(getClass().getClassLoader().getResourceAsStream(PROP_FILE)); } catch (IOException e) { throw new RuntimeException("Problem loading properties '" + PROP_FILE + "'", e); } Enumeration<?> propNames = props.propertyNames(); while (propNames.hasMoreElements()) { String taxonId = (String) propNames.nextElement(); taxonId = taxonId.substring(0, taxonId.indexOf(".")); Properties taxonProps = PropertiesUtil.stripStart(taxonId, PropertiesUtil.getPropertiesStartingWith(taxonId, props)); String identifier = taxonProps.getProperty("identifier"); if (identifier == null) { throw new IllegalArgumentException("Unable to find geneAttribute property for " + "taxon: " + taxonId + " in file: " + PROP_FILE); } if (!("symbol".equals(identifier) || "primaryIdentifier".equals(identifier) || "secondaryIdentifier".equals(identifier) || "primaryAccession".equals(identifier))) { throw new IllegalArgumentException( "Invalid identifier value for taxon: " + taxonId + " was: " + identifier); } config.put(taxonId, identifier); } }
From source file:org.eclipse.smila.connectivity.queue.worker.internal.task.impl.Send.java
/** * Creates message.//w w w .ja va 2s . co m * * @param config * the config * @param record * the record * @param messageProperties * the jms message properties * @param session * the session * * @return the message * * @throws JMSException * the JMS exception */ private Message createMessage(final SendType config, final Record record, final Properties messageProperties, final Session session) throws JMSException { final BytesMessage message = session.createBytesMessage(); // set dynamic message properties if (messageProperties != null) { final Enumeration<?> propertyNames = messageProperties.propertyNames(); while (propertyNames.hasMoreElements()) { final String name = (String) propertyNames.nextElement(); message.setStringProperty(name, messageProperties.getProperty(name)); } } // get static properties of config file for (final PropertyType property : config.getSetProperty()) { message.setStringProperty(property.getName(), property.getValue()); } final byte[] serialized = XmlSerializationUtils.serialize2byteArray(record); message.writeBytes(serialized); return message; }
From source file:org.talend.cwm.db.connection.MdmWebserviceConnection.java
public void setProviderConnection(Connection dataProvider, DBConnectionParameter parameter) { // Provider connection properties MDMConnection prov = ConnectionFactory.eINSTANCE.createMDMConnection(); prov.setName(SupportDBUrlType.MDM.getDBKey() + EcoreUtil.generateUUID()); // connection prov.setPathname(url);//from ww w . ja v a 2 s . co m Properties propes = parameter.getParameters(); // add properties as tagged value of the provider connection. Enumeration<?> propertyNames = propes.propertyNames(); while (propertyNames.hasMoreElements()) { String key = propertyNames.nextElement().toString(); String property = propes.getProperty(key); if (TaggedValueHelper.PASSWORD.equals(key)) { ConnectionHelper.setPassword(prov, property); } else if (TaggedValueHelper.USER.equals(key)) { prov.setUsername(property); } } // FIXME what is this assignment? dataProvider = prov; // DataProviderHelper.addProviderConnection(prov, dataProvider); }
From source file:org.ops4j.pax.runner.platform.felix.internal.FelixPlatformBuilder.java
/** * @see org.ops4j.pax.runner.platform.PlatformBuilder * #getVMOptions(org.ops4j.pax.runner.platform.PlatformContext) *//*from ww w . ja va 2s . c o m*/ public String[] getVMOptions(final PlatformContext context) { NullArgumentException.validateNotNull(context, "Platform context"); final Collection<String> vmOptions = new ArrayList<String>(); final File workingDirectory = context.getWorkingDirectory(); vmOptions.add("-Dfelix.config.properties=" + context.getFilePathStrategy() .normalizeAsUrl(new File(new File(workingDirectory, CONFIG_DIRECTORY), CONFIG_INI))); // TODO http://team.ops4j.org/browse/PAXSCANNER-23?focusedCommentId=18236&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-18236 final Properties frameworkProperties = context.getProperties(); if (frameworkProperties != null) { final Enumeration<?> enumeration = frameworkProperties.propertyNames(); while (enumeration.hasMoreElements()) { final String key = (String) enumeration.nextElement(); String property = frameworkProperties.getProperty(key); String quotedProperty = property.replace("\"", "\\\""); if (property.length() < quotedProperty.length() || property.indexOf(' ') >= 0) { property = '"' + quotedProperty + '"'; } StringBuilder vmOption = new StringBuilder(2 + key.length() + 1 + property.length()); vmOption.append("-D"); vmOption.append(key); if (property.length() > 0) { vmOption.append('='); vmOption.append(property); } vmOptions.add(vmOption.toString()); } } return vmOptions.toArray(new String[vmOptions.size()]); }
From source file:net.sf.jasperreports.eclipse.builder.jdt.JRJdtCompiler.java
protected Map<String, String> getJdtSettings() { if (settings == null) { settings = new HashMap<String, String>(); settings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); settings.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); settings.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE); // if (ctxt.getOptions().getJavaEncoding() != null) // {//from ww w . j a va 2 s . c o m // settings.put(CompilerOptions.OPTION_Encoding, // ctxt.getOptions().getJavaEncoding()); // } // if (ctxt.getOptions().getClassDebugInfo()) // { // settings.put(CompilerOptions.OPTION_LocalVariableAttribute, // CompilerOptions.GENERATE); // } List<JRPropertiesUtil.PropertySuffix> properties = JRPropertiesUtil.getInstance(jasperReportsContext) .getProperties(JDT_PROPERTIES_PREFIX); for (Iterator<JRPropertiesUtil.PropertySuffix> it = properties.iterator(); it.hasNext();) { JRPropertiesUtil.PropertySuffix property = it.next(); String propVal = property.getValue(); if (propVal != null && propVal.length() > 0) { settings.put(property.getKey(), propVal); } } Properties systemProps = System.getProperties(); for (Enumeration<String> it = (Enumeration<String>) systemProps.propertyNames(); it .hasMoreElements();) { String propName = it.nextElement(); if (propName.startsWith(JDT_PROPERTIES_PREFIX)) { String propVal = systemProps.getProperty(propName); if (propVal != null && propVal.length() > 0) { settings.put(propName, propVal); } } } } return settings; }