Example usage for java.util Properties putAll

List of usage examples for java.util Properties putAll

Introduction

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

Prototype

@Override
    public synchronized void putAll(Map<?, ?> t) 

Source Link

Usage

From source file:info.evanchik.eclipse.karaf.core.KarafCorePluginUtils.java

/**
 * Loads a configuration file relative to the specified base directory. This
 * method also processes any include directives that import other properties
 * files relative to the specified property file.
 *
 * @param base//from   w ww  . j  a  va  2  s  .  co m
 *            the directory containing the file
 * @param filename
 *            the relative path to the properties file
 * @param processIncludes
 *            true if {@link #INCLUDES_PROPERTY} statements should be
 *            followed; false otherwise.
 * @return the {@link Properties} object created from the contents of
 *         configuration file
 * @throws CoreException
 *             if there is a problem loading the file
 */
public static Properties loadProperties(final File base, final String filename, final boolean processIncludes)
        throws CoreException {
    final File f = new File(base, filename);

    try {
        final Properties p = new Properties();
        p.load(new FileInputStream(f));

        final String includes = p.getProperty(INCLUDES_PROPERTY);
        if (includes != null) {
            final StringTokenizer st = new StringTokenizer(includes, "\" ", true);
            if (st.countTokens() > 0) {
                String location;
                do {
                    location = nextLocation(st);
                    if (location != null) {
                        final Properties includeProps = loadProperties(base, location);
                        p.putAll(includeProps);
                    }
                } while (location != null);
            }
            p.remove(INCLUDES_PROPERTY);
        }

        return p;
    } catch (final IOException e) {
        final String message = "Unable to load configuration file from configuration directory: "
                + f.getAbsolutePath();
        throw new CoreException(
                new Status(IStatus.ERROR, KarafCorePluginActivator.PLUGIN_ID, IStatus.OK, message, e));
    }

}

From source file:com.devicehive.application.RdbmsPersistenceConfig.java

@Bean
@Autowired/*  w  ww  .j  a v a2 s .  c  o  m*/
@DependsOn(value = { "simpleApplicationContextHolder" })
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
    factoryBean.setDataSource(dataSource);
    factoryBean.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
    factoryBean.setValidationMode(ValidationMode.CALLBACK);
    factoryBean.setJpaVendorAdapter(jpaVendorAdapter);
    factoryBean.setPackagesToScan("com.devicehive.model");

    final Properties props = new Properties();
    props.putAll(this.properties.getHibernateProperties(this.dataSource));
    factoryBean.setJpaProperties(props);
    return factoryBean;
}

From source file:star.webapp.JolokiaAdminConfiguration.java

private Properties getInitParameters() {
    Properties initParameters = new Properties();
    initParameters.putAll(this.properties.getConfig());
    return initParameters;
}

From source file:com.mindquarry.webapp.servlet.ConfigLoaderListener.java

/**
 * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
 *///from w w  w. j  a  v  a  2s  .co m
public void contextInitialized(ServletContextEvent ctxEvent) {
    try {
        // load props file
        File propFile = new File(System.getProperty(P_CONFIG_FILE, "mindquarry-webapplication.properties")); //$NON-NLS-1$
        FileInputStream is = new FileInputStream(propFile);

        // load props
        Properties props = new Properties();
        props.load(is);

        // add props to system props
        Properties sysProps = System.getProperties();
        sysProps.putAll(props);
        System.setProperties(sysProps);
    } catch (Exception e) {
        log.error("An error occured while loading system properties.", e);
        System.exit(-1);
    }
}

From source file:com.google.enterprise.connector.filesystem.ConfigTest.java

public void testInstantiation() {
    Properties props = new Properties();
    props.putAll(goodConfig);
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
    // Refer to InstanceInfo.makeConnectorWithSpring
    //(com.google.enterprise.connector.instantiator) for more info on how
    // these files are loaded to instantiate connector.
    reader.loadBeanDefinitions(new ClassPathResource(DEFAULTS_CONFIG_FILE, ConfigTest.class));
    reader.loadBeanDefinitions(new ClassPathResource(INSTANCE_CONFIG_FILE, ConfigTest.class));
    PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
    cfg.setProperties(props);//from w  ww .  j  a  va  2 s  . co m
    cfg.postProcessBeanFactory(beanFactory);
    String[] beans = beanFactory.getBeanNamesForType(Connector.class);
    assertEquals(1, beans.length);
    Object obj = beanFactory.getBean(beans[0]);
    assertTrue("Expecting instance of Connector interface but the actual " + "instance: "
            + obj.getClass().toString(), obj instanceof Connector);
}

From source file:com.migratebird.launch.ant.BaseAntTask.java

@SuppressWarnings({ "unchecked" })
protected Properties getAntProperties() {
    Properties properties = new Properties();
    properties.putAll(getProject().getProperties());
    return properties;
}

From source file:com.mkwhitacre.kafka.mapreduce.utils.KafkaBrokerTestHarness.java

/**
 * Creates a collection of Kafka Broker configurations based on the number of brokers and zookeeper.
 * @param brokers the number of brokers to create configuration for.
 * @param zookeeperPort the zookeeper port for the brokers to connect to.
 * @param baseProperties basic properties that should be applied for each broker config.  These properties will be
 *                       honored in favor of any default properties.
 * @return configuration for a collection of brokers.
 * @throws IllegalArgumentException if {@code brokers} is less than 1 or {@code baseProperties} is {@code null}.
 *//*  w  w w. j av a 2  s. c om*/
public static List<KafkaConfig> getBrokerConfig(int brokers, int zookeeperPort, Properties baseProperties) {
    if (brokers < 1) {
        throw new IllegalArgumentException("Invalid broker count: " + brokers);
    }
    if (baseProperties == null) {
        throw new IllegalArgumentException("The 'baseProperties' cannot be 'null'.");
    }

    int ports[] = KafkaTestUtils.getPorts(brokers);

    List<KafkaConfig> configs = new ArrayList<KafkaConfig>(brokers);
    for (int i = 0; i < brokers; ++i) {
        Properties props = new Properties();
        props.setProperty(KAFKA_ZOOKEEPERS, "localhost:" + zookeeperPort);
        props.setProperty("broker.id", String.valueOf(i + 1));
        props.setProperty("host.name", "localhost");
        props.setProperty("port", String.valueOf(ports[i]));
        props.setProperty("log.dir", KafkaTestUtils.getTempDir().getAbsolutePath());
        props.setProperty("log.flush.interval.messages", String.valueOf(1));
        props.setProperty("num.partitions", String.valueOf(PARTITIONS_PER_TOPIC));
        props.setProperty("default.replication.factor", String.valueOf(brokers));
        props.setProperty("auto.create.topics.enable", Boolean.FALSE.toString());

        props.putAll(baseProperties);

        configs.add(new KafkaConfig(props));
    }
    return configs;
}

From source file:com.athina.queue.manager.quartz.QuartzConfiguration.java

@Profile("mysql-jobstore")
@Bean/*from ww w  .j a  v  a 2 s  .com*/
public SchedulerFactoryBean quartzSchedulerFactoryWithJobStore(JobFactory jobFactory,
        Optional<DataSource> dataSource, QuartzProperties quartzProperties) {
    Properties props = quartzProperties.buildQuartzProperties();
    props.putAll(quartzProperties.getJobstore().buildQuartzProperties());
    return buildSchedulerFactory(jobFactory, dataSource, props);
}

From source file:ch.nydi.spring.config.SystemPropertiesFactoryBean.java

@Override
protected Properties createProperties() throws IOException {
    final Properties originalProperties = super.createProperties();
    final Properties propertiesReplaced = new Properties();

    final PropertyVariableParser propertyParser = new PropertyVariableParser();

    for (final Map.Entry<Object, Object> entry : originalProperties.entrySet()) {
        propertiesReplaced.put(entry.getKey(), propertyParser.replaceVariables((String) entry.getValue()));
    }//from w  w w  . j a v  a 2  s.co m

    if (propagateToSystemProperties) {
        final Properties systemProperties = System.getProperties();
        systemProperties.putAll(propertiesReplaced);
        System.setProperties(systemProperties);
    }

    return propertiesReplaced;
}

From source file:com.cognifide.qa.bb.config.ConfigStrategy.java

/**
 * Determines how all properties are being processed.
 * <p>//from  ww  w. ja  v  a2s  .  co  m
 * The default implementation uses the following order:
 * <ol>
 * <li>Load the default configuration included by Bobcat itself (via {@link #loadDefaultConfig()} method)</li>
 * <li>Load the config from Bobcat user files (via {@link #loadConfig()} method); override any previous
 * properties</li>
 * <li>Override the loaded properties from system properties provided from command line</li>
 * <li>Set system properties with loaded properties that start with {@value ConfigKeys#WEBDRIVER_PROP_PREFIX}</li>
 * </ol>
 *
 * @return all loaded and processed {@link Properties}
 */
default Properties gatherProperties() {
    Properties config = loadDefaultConfig();
    config.putAll(loadConfig());
    Properties overridenConfig = overrideFromSystemProperties(config);
    setSystemProperties(overridenConfig);
    return overridenConfig;
}