Example usage for java.util Properties entrySet

List of usage examples for java.util Properties entrySet

Introduction

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

Prototype

@Override
    public Set<Map.Entry<Object, Object>> entrySet() 

Source Link

Usage

From source file:org.openlmis.fulfillment.extension.ExtensionManager.java

@PostConstruct
private void loadConfigurationFile() {
    Properties prop = new Properties();
    try {/*from   ww w.j a  v  a 2 s  . c  o m*/
        prop.load(new FileInputStream(new File(EXTENSIONS_DIR, CONFIG_FILE)));
        for (final Map.Entry<Object, Object> entry : prop.entrySet()) {
            extensions.put((String) entry.getKey(), (String) entry.getValue());
        }
    } catch (IOException ex) {
        LOGGER.debug("It was not possible to load extensions" + " configuration from extension.properties file",
                ex);
    }
}

From source file:org.aon.esolutions.appconfig.client.web.SystemPropertiesListener.java

private void loadPropsFromSystem(ServletContext sc) {
    String propertiesLocationProp = sc.getInitParameter("properties.location.property");
    String privateKeyLocationProp = sc.getInitParameter("privatekey.location.property");
    String applicationName = sc.getInitParameter("application.name");
    String environmentName = sc.getInitParameter("environment.name");

    Properties props = System.getProperties();
    String propertiesFileLocation = props.getProperty(propertiesLocationProp);
    String privateKeyLocation = props.getProperty(privateKeyLocationProp);

    if (StringUtils.isEmpty(propertiesFileLocation)) {
        logger.warn("Not loading properties from system property (" + propertiesLocationProp
                + ") as it was not provided.");
        return;/*w ww.j  av  a 2  s. c o m*/
    }

    AppConfigClientFactory acClient = new AppConfigClientFactory();
    acClient.setPropertiesFileName(propertiesFileLocation);
    acClient.setPrivateKeyFileName(privateKeyLocation);

    Properties loadedProps = acClient.getAppConfigClient().loadProperties(applicationName, environmentName);

    for (Map.Entry<Object, Object> e : loadedProps.entrySet()) {
        if (props.containsKey(e.getKey()) == false)
            props.put(e.getKey(), e.getValue());
    }
}

From source file:org.codehaus.groovy.grails.plugins.spring.ws.ReloadablePayloadRootQNameEndpointMapping.java

/**
 * Maps keys to endpoint bean names. The nature of the property names depends on the exact subclass used. They can
 * be qualified names, for instance, or mime headers.
 *///from   ww  w  .  j  a va2s .c om
public void setMappings(Properties mappings) {
    for (Map.Entry<Object, Object> entry : mappings.entrySet()) {
        temporaryEndpointMap.put(String.class.cast(entry.getKey()), entry.getValue());
    }
}

From source file:org.apache.falcon.oozie.OozieBundleBuilder.java

protected CONFIGURATION getConfig(Properties props) {
    CONFIGURATION conf = new CONFIGURATION();
    for (Entry<Object, Object> prop : props.entrySet()) {
        Property confProp = new Property();
        confProp.setName((String) prop.getKey());
        confProp.setValue((String) prop.getValue());
        conf.getProperty().add(confProp);
    }//from ww  w . j  a  v  a2s  . c  o m
    return conf;
}

From source file:org.apache.archiva.rest.services.DefaultCommonServices.java

private String fromProperties(final Properties properties) {
    StringBuilder output = new StringBuilder();

    for (Map.Entry<Object, Object> entry : properties.entrySet()) {
        output.append((String) entry.getKey()).append('=').append((String) entry.getValue());
        output.append('\n');
    }/*from  ww  w  .  jav  a  2s  . co m*/

    return output.toString();
}

From source file:jp.tricreo.codegenerator.model.reader.impl.ModelReadStrategyInProperties.java

@Override
public Collection<ClassMetaModel> readAll() throws IOException {
    Set<ClassMetaModel> result = new HashSet<ClassMetaModel>();
    Map<String, Map<String, Object>> classMetaModels = new HashMap<String, Map<String, Object>>();
    Properties properties = loadProperties(propertiesFilePath);
    for (Entry<Object, Object> propertiesEntry : properties.entrySet()) {
        String key = (String) propertiesEntry.getKey();
        if (key.startsWith("models")) {
            String[] splits = key.split("\\.");
            String id = splits[1];
            Map<String, Object> classMetaModel = getOrNewPutGetClassMetaModel(classMetaModels, id);
            String property = splits[2];
            String value = properties.getProperty(key);
            if (property.equals("fields")) {
                String fieldName = splits[3];
                Map<String, String> fieldModels = getOrNewPutGetFieldMetaModel(classMetaModel);
                fieldModels.put(fieldName, value);
            } else {
                classMetaModel.put(property, value);
            }// w  ww . jav a2s  .c  om
        }
    }
    Set<Entry<String, Map<String, Object>>> entrySet = classMetaModels.entrySet();
    for (Entry<String, Map<String, Object>> entry : entrySet) {
        String className = (String) entry.getValue().get("className");
        String packageName = (String) entry.getValue().get("packageName");

        @SuppressWarnings("unchecked")
        Map<String, String> fieldModels = (Map<String, String>) entry.getValue().get("fields");
        Set<Entry<String, String>> fieldModelsEntrySet = fieldModels.entrySet();

        final List<FieldMetaModel> fieldMetaModels = new ArrayList<FieldMetaModel>();
        for (Entry<String, String> fieldModelsEntry : fieldModelsEntrySet) {
            FieldMetaModel fieldMetaModel = new FieldMetaModel(fieldModelsEntry.getKey(),
                    fieldModelsEntry.getValue());
            fieldMetaModels.add(fieldMetaModel);
        }

        ClassMetaModel classMetaModel = new ClassMetaModel(className, packageName, fieldMetaModels);
        result.add(classMetaModel);
    }

    return result;
}

From source file:org.vbossica.springbox.config.PropertyPlaceholderDebuggingConfigurer.java

@Override
protected void loadProperties(Properties props) throws IOException {
    super.loadProperties(props);

    if (log.isDebugEnabled()) {
        log.debug("Loading properties");
        for (Map.Entry<Object, Object> entry : props.entrySet()) {
            log.debug("{}: '{}'", entry.getKey(), entry.getValue());
        }/*from   w w  w .  j  a v a  2  s.co m*/
    }
}

From source file:org.slc.sli.ingestion.util.ExposedPropertyPlaceholderConfigurer.java

@Override
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)
        throws BeansException {
    Map<String, String> tmpProperties = new HashMap<String, String>(props.size());
    super.processProperties(beanFactoryToProcess, props);
    for (Entry<Object, Object> entry : props.entrySet()) {
        tmpProperties.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue()));
    }/*ww w  .  j  ava  2 s  .  co  m*/
    this.properties = Collections.unmodifiableMap(tmpProperties);
}

From source file:mitm.djigzo.web.utils.SetDefaultSystemPropertiesServletContextListener.java

@Override
public void contextInitialized(ServletContextEvent contextEvent) {
    String propertiesParam = contextEvent.getServletContext().getInitParameter("djigzo.system.properties");

    if (propertiesParam != null) {
        Properties properties = new Properties();

        try {//w  w  w . j a v  a 2 s . c  om
            properties.load(IOUtils.toInputStream(propertiesParam, "UTF-8"));

            for (Map.Entry<Object, Object> entry : properties.entrySet()) {
                if (System.getProperty((String) entry.getKey()) == null) {
                    System.setProperty((String) entry.getKey(), (String) entry.getValue());
                }
            }
        } catch (IOException e) {
            logger.error("Error loading properties.", e);
        }
    } else {
        logger.warn("property djigzo.systemproperties.default is missing.");
    }
}

From source file:de.kaiserpfalzEdv.commons.jee.spring.CommonsConfigurationConfigurer.java

private void loadProperties(Properties props, String filename) throws ConfigurationException {
    DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(filename);
    configuration = builder.getConfiguration();

    Properties commonsProperties = ConfigurationConverter.getProperties(configuration);

    log.debug("got properties " + commonsProperties);
    for (Map.Entry<Object, Object> entry : commonsProperties.entrySet()) {
        props.setProperty((String) entry.getKey(), (String) entry.getValue());
    }/*from   w  ww .  j ava2s . com*/
}