Example usage for java.util Properties propertyNames

List of usage examples for java.util Properties propertyNames

Introduction

In this page you can find the example usage for java.util Properties propertyNames.

Prototype

public Enumeration<?> propertyNames() 

Source Link

Document

Returns an enumeration of all the keys in this property list, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list.

Usage

From source file:com.liferay.portal.dao.jdbc.DataSourceFactoryImpl.java

protected DataSource initDataSourcePrimrose(Properties properties) throws Exception {

    String poolName = PwdGenerator.getPassword(PwdGenerator.KEY2, 8);

    properties.setProperty("poolName", poolName);

    Enumeration<String> enu = (Enumeration<String>) properties.propertyNames();

    while (enu.hasMoreElements()) {
        String key = enu.nextElement();

        String value = properties.getProperty(key);

        // Map org.apache.commons.dbcp.BasicDataSource to Primrose

        if (key.equalsIgnoreCase("driverClassName")) {
            key = "driverClass";
        } else if (key.equalsIgnoreCase("url")) {
            key = "driverURL";
        } else if (key.equalsIgnoreCase("username")) {
            key = "user";
        }/*ww  w. j ava2 s  .  co  m*/

        properties.setProperty(key, value);
    }

    GenericDataSourceFactory genericDataSourceFactory = new GenericDataSourceFactory();

    return genericDataSourceFactory.loadPool(poolName, properties);
}

From source file:org.apache.jcs.engine.control.CompositeCacheConfigurator.java

/**
 * Parse region elements./*from ww  w  .j  a  v a2 s.  com*/
 *
 * @param props
 */
protected void parseRegions(Properties props) {
    List regionNames = new ArrayList();

    Enumeration en = props.propertyNames();
    while (en.hasMoreElements()) {
        String key = (String) en.nextElement();
        if (key.startsWith(REGION_PREFIX) && (key.indexOf("attributes") == -1)) {
            String regionName = key.substring(REGION_PREFIX.length());

            regionNames.add(regionName);

            String value = OptionConverter.findAndSubst(key, props);
            ICache cache;
            synchronized (regionName) {
                cache = parseRegion(props, regionName, value);
            }
            compositeCacheManager.caches.put(regionName, cache);
        }
    }

    if (log.isInfoEnabled()) {
        log.info("Parsed regions " + regionNames);
    }

}

From source file:com.amalto.core.jobox.component.JobAware.java

private String analyzeJobParams(File entity, JobInfo jobInfo) {
    String propFilePath = null;/*ww  w .j a v  a 2  s. c o m*/
    try {
        List<File> checkList = new ArrayList<File>();
        JoboxUtil.findFirstFile(jobInfo, entity, jobInfo.getContextStr() + ".properties", checkList);//$NON-NLS-1$
        if (checkList.size() > 0) {
            propFilePath = checkList.get(0).getAbsolutePath();
            Properties paramProperties = new Properties();
            FileInputStream fileReader = new FileInputStream(checkList.get(0));
            try {
                paramProperties.load(fileReader);
            } finally {
                fileReader.close();
            }
            for (Enumeration e = paramProperties.propertyNames(); e.hasMoreElements();) {
                String key = (String) e.nextElement();
                String value = paramProperties.getProperty(key);
                jobInfo.addParam(key, value);
            }
        }
    } catch (Exception e) {
        throw new JoboxException(e);
    }
    return propFilePath;
}

From source file:org.seasar.karrta.jcr.session.JcrSessionFactory.java

/**
 * register namespaces./*from ww  w  .  ja  v a2 s.  c om*/
 * 
 * @param session
 * @param namespaces
 * @throws JcrRepositoryRuntimeException
 */
private void registerNamespaces(Session session, Properties namespaces) throws JcrRepositoryRuntimeException {

    try {
        String[] jcrNamespaces = session.getWorkspace().getNamespaceRegistry().getPrefixes();

        for (Enumeration<?> e = namespaces.propertyNames(); e.hasMoreElements();) {
            String namespace = (String) e.nextElement();
            String url = namespaces.getProperty(namespace);

            boolean isCreateNamespace = true;
            for (String n : jcrNamespaces) {
                if (namespace.equals(n)) {
                    isCreateNamespace = false;
                    break;
                }
            }
            if (isCreateNamespace) {
                session.getWorkspace().getNamespaceRegistry().registerNamespace(namespace, url);
            }
        }

    } catch (RepositoryException e) {
        throw new JcrRepositoryRuntimeException("", e);
    }
}

From source file:org.springframework.batch.core.jsr.configuration.xml.JsrBeanDefinitionDocumentReader.java

private Properties initJobParameters() {
    Properties jobParameters = new Properties();

    if (getBeanDefinitionRegistry().containsBeanDefinition(JOB_PARAMETERS_BEAN_DEFINITION_NAME)) {
        BeanDefinition beanDefintion = getBeanDefinitionRegistry()
                .getBeanDefinition(JOB_PARAMETERS_BEAN_DEFINITION_NAME);

        Properties properties = (Properties) beanDefintion.getConstructorArgumentValues()
                .getGenericArgumentValue(Properties.class).getValue();

        if (properties == null) {
            return new Properties();
        }//w  w w  .j  a v  a  2s .  com

        Enumeration<?> propertyNames = properties.propertyNames();

        while (propertyNames.hasMoreElements()) {
            String curName = (String) propertyNames.nextElement();
            jobParameters.put(curName, properties.getProperty(curName));
        }
    }

    return jobParameters;
}

From source file:org.ops4j.pax.runner.platform.equinox.internal.EquinoxPlatformBuilder.java

/**
 * Writes properties to configuration file.
 *
 * @param writer     a property writer/*from  ww  w .ja  va2s.  c  o m*/
 * @param properties properties toC be written; can be null
 */
private void appendProperties(final PropertiesWriter writer, final Properties properties) {
    if (properties != null) {
        final Enumeration enumeration = properties.propertyNames();
        while (enumeration.hasMoreElements()) {
            final String key = (String) enumeration.nextElement();
            writer.append(key, properties.getProperty(key));
        }
    }
}

From source file:com.ibm.jaggr.core.impl.options.OptionsImpl.java

/**
 * Listener method for being informed of changes to the properties file by another
 * instance of this class.  Called by other instances of this class for instances
 * that use the same properties file when properties are saved.
 *
 * @param updated/*from  www.  j a  v a2 s .  c  o m*/
 *            the updated properties
 * @param sequence
 *            the update sequence number
 */
protected void propertiesFileUpdated(Properties updated, long sequence) {
    Properties newProps = new Properties(getDefaultOptions());
    Enumeration<?> propsEnum = updated.propertyNames();
    while (propsEnum.hasMoreElements()) {
        String name = (String) propsEnum.nextElement();
        newProps.setProperty(name, updated.getProperty(name));
    }
    setProps(newProps);
    updateNotify(sequence);
}

From source file:org.metaeffekt.dcc.controller.commands.AbstractUnitBasedCommand.java

private void processCapabilities(ConfigurationUnit unit, final Properties properties,
        final CommandDefinition command) {
    for (CapabilityDefinitionReference ref : command.getCapabilities()) {
        final Id<CapabilityId> commandInputCapabilityId = Id
                .createCapabilityId(ref.getReferencedCapabilityDefId());

        if (commandInputCapabilityId != null) {
            // access the capability reference by capabilityId
            Capability commandCapability = unit.findProvidedCapability(commandInputCapabilityId);

            // for backward compatibility...
            if (commandCapability == null) {
                commandCapability = unit
                        .findProvidedCapabilityWithCapabilityDefinition(commandInputCapabilityId.getValue());
                if (commandCapability != null) {
                    LOG.warn("The unit [{}] uses a id reference to a capability definition [{}] instead of a "
                            + "concrete capability. This may not be supported in future versions. "
                            + "Please replace the reference to [{}] by the id of a provided capability.",
                            unit.getId(), commandInputCapabilityId, commandInputCapabilityId);
                }/*from  w  ww. j  a va2  s . c  o m*/
                if (commandCapability == null) {
                    commandCapability = unit.findRequiredCapability(commandInputCapabilityId);
                    if (commandCapability != null) {
                        Collection<Binding> bindings = getExecutionContext().getProfile()
                                .findBindings(commandCapability);
                        if (bindings.size() == 1) {
                            Binding binding = bindings.iterator().next();
                            commandCapability = binding.getSourceCapability();
                        } else {
                            // no action, no exception: binding may be optional
                        }
                    }
                }
            }
            if (commandCapability == null) {
                throw new IllegalStateException(String.format(
                        "The capability with id [%s] " + "for command %s in unit %s cannot be found!",
                        commandInputCapabilityId.getValue(), command.getCommandId(), unit.getId()));
            }
            final Properties propertiesToCopy = getExecutionContext().getPropertiesHolder()
                    .getProperties(commandCapability);
            if (propertiesToCopy != null) {
                for (Enumeration<?> enumeration = propertiesToCopy.propertyNames(); enumeration
                        .hasMoreElements();) {
                    final String key = (String) enumeration.nextElement();
                    properties.put(adaptKey(ref.getPrefix(), key), propertiesToCopy.getProperty(key));
                }
            }
        }
    }
}

From source file:com.zimbra.common.soap.SoapTestHarness.java

private void expandSystemProperties() throws HarnessException {

    Properties props = System.getProperties();

    if (props != null) {
        Enumeration<?> keys = props.propertyNames();
        while (keys.hasMoreElements()) {
            String key = keys.nextElement().toString();
            String value = props.getProperty(key).toString();
            if (value != null)
                setProperty(key, value);
            else//from   w  ww . j a va  2s .c  om
                throw new HarnessException("Invalid Global Property file");
        }
    }
}

From source file:org.apache.wiki.providers.AbstractFileProvider.java

/**
 * Set the custom properties provided into the given page.
 * /*  w  w w .  j  a v a 2  s  . com*/
 * @since 2.10.2
 */
protected void setCustomProperties(WikiPage page, Properties properties) {
    Enumeration propertyNames = properties.propertyNames();
    while (propertyNames.hasMoreElements()) {
        String key = (String) propertyNames.nextElement();
        if (!key.equals(WikiPage.AUTHOR) && !key.equals(WikiPage.CHANGENOTE)
                && !key.equals(WikiPage.VIEWCOUNT)) {
            page.setAttribute(key, properties.get(key));
        }
    }
}