Example usage for java.util Properties put

List of usage examples for java.util Properties put

Introduction

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

Prototype

@Override
    public synchronized Object put(Object key, Object value) 

Source Link

Usage

From source file:com.messagehub.samples.bluemix.BluemixEnvironment.java

/**
 * injects into the client configuration the properties needed for locating the SSL trustore 
 * @param clientProperties client configuration 
 *///from   www . ja va  2s  . c o  m
public static void addSSLTrustoreTo(Properties clientProperties) {
    String userDir = System.getProperty("user.dir");
    clientProperties.put("ssl.truststore.location",
            userDir + "/.java-buildpack/open_jdk_jre/lib/security/cacerts");
    clientProperties.put("ssl.truststore.type", "JKS");
    // This is the JDK's default truststore password.
    clientProperties.put("ssl.truststore.password", "changeit");
}

From source file:org.log.kafka.consumer.MessageConsumer.java

private static ConsumerConfig createConsumerConfig() {

    Properties props = new Properties();
    props.put("zookeeper.connect", MessageConsumer.buildEndPoint(ZK_IP, ZK_PORT));
    props.put("group.id", KAFKA_GROUPID);
    props.put("zookeeper.session.timeout.ms", "6000");
    props.put("zookeeper.sync.time.ms", "200");
    props.put("auto.commit.interval.ms", "1000");
    logger.info("Kafka consumer config: " + ZK_IP + ":" + ZK_PORT + "::" + topic + "::" + KAFKA_GROUPID);
    return new ConsumerConfig(props);

}

From source file:ezbake.security.persistence.impl.FileRegManagerTest.java

private static FileRegManager setUpManager(File testFile) {
    Properties properties = new Properties();
    properties.put(FileRegManager.REGISTRATION_FILE_PATH, testFile.getAbsolutePath());
    return new FileRegManager(properties);
}

From source file:com.tacitknowledge.util.migration.jdbc.util.SqlUtil.java

/**
 * Established and returns a connection based on the specified parameters.
 *
 * @param driver the JDBC driver to use//from  w  w w. j  a v a2s .  com
 * @param url    the database URL
 * @param user   the username
 * @param pass   the password
 * @return a JDBC connection
 * @throws ClassNotFoundException if the driver could not be loaded
 * @throws SQLException           if a connnection could not be made to the database
 */
public static Connection getConnection(String driver, String url, String user, String pass)
        throws ClassNotFoundException, SQLException {
    Connection conn = null;
    try {
        Class.forName(driver);
        log.debug("Getting Connection to " + url);
        conn = DriverManager.getConnection(url, user, pass);
    } catch (Exception e) {
        /* work around for DriverManager 'feature'.  
         * In some cases, the jdbc driver jar is injected into a new 
         * child classloader (for example, maven provides different 
         * class loaders for different build lifecycle phases). 
         * 
         * Since DriverManager uses the calling class' loader instead 
         * of the current context's loader, it fails to find the driver.
         * 
         * Our work around is to give the current context's class loader 
         * a shot at finding the driver in cases where DriverManager fails.  
         * This 'may be' a security hole which is why DriverManager implements 
         * things in such a way that it doesn't use the current thread context class loader.
         */
        try {
            Class driverClass = Class.forName(driver, true, Thread.currentThread().getContextClassLoader());
            Driver driverImpl = (Driver) driverClass.newInstance();
            Properties props = new Properties();
            props.put("user", user);
            props.put("password", pass);
            conn = driverImpl.connect(url, props);
        } catch (InstantiationException ie) {
            log.debug(ie);
            throw new SQLException(ie.getMessage());
        } catch (IllegalAccessException iae) {
            log.debug(iae);
            throw new SQLException(iae.getMessage());
        }
    }

    return conn;
}

From source file:com.turn.griffin.utils.GriffinConsumer.java

private static ConsumerConfig createConsumerConfig(String zkAddress, String groupId, Properties userProps) {
    Properties props = new Properties();
    props.put("zookeeper.connect", zkAddress);
    props.put("zookeeper.session.timeout.ms", "30000");
    props.put("zookeeper.connection.timeout.ms", "30000");
    props.put("zookeeper.sync.time.ms", "6000");

    props.put("group.id", groupId);

    props.put("auto.commit.enable", "true");
    props.put("auto.commit.interval.ms", "300000"); // 5 min
    props.put("rebalance.backoff.ms", "20000");

    /* Add user specified properties */
    /* Should be the last line to allow overriding any of the properties above */
    props.putAll(userProps);/*  ww w  .ja  va  2  s .co  m*/

    /* A hack to set the consumer offset to zero if the user specified smallest offset */
    if ("smallest".equals(props.get("auto.offset.reset"))) {
        ZkUtils.maybeDeletePath(zkAddress, new ZKGroupDirs(groupId).consumerGroupDir());
    }
    return new ConsumerConfig(props);
}

From source file:Main.java

/**
 * Returns properties for complex XA datasource
 * @param indiName//from  ww  w .  j av  a 2 s.co  m
 */
public static Properties xaDsProperties(String jndiName) {
    Properties params = commonDsProperties(jndiName);
    //attributes

    //common
    params.put("xa-datasource-class", "org.jboss.as.connector.subsystems.datasources.ModifiableXaDataSource");
    //xa-pool
    params.put("same-rm-override", "true");
    params.put("interleaving", "true");
    params.put("no-tx-separate-pool", "true");
    params.put("pad-xid", "true");
    params.put("wrap-xa-resource", "true");
    //time-out
    params.put("xa-resource-timeout", "120");
    //recovery
    params.put("no-recovery", "false");
    params.put("recovery-plugin-class-name", "someClass5");
    params.put("recovery-username", "sa");
    params.put("recovery-password", "sa");
    params.put("recovery-security-domain", "HsqlDbRealm");

    return params;
}

From source file:com.linkedin.pinot.common.utils.KafkaStarterUtils.java

public static void configureLogRetentionSizeBytes(Properties properties, int logRetentionSizeBytes) {
    properties.put("log.retention.bytes", Integer.toString(logRetentionSizeBytes));
}

From source file:Main.java

public static Properties convertResourceBundleToProperties(ResourceBundle resource) {
    Properties properties = new Properties();

    Enumeration<String> keys = resource.getKeys();
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        properties.put(key, resource.getString(key));
        //System.out.println("key: '" + key + "' value: '" + properties.get(key) + "'");
    }/*from  w  w w.  j av  a  2s . co m*/

    return properties;
}

From source file:org.ecloudmanager.tmrk.cloudapi.CloudapiEndpointFactory.java

public static Properties createConfiguration(String accessKey, String privateKey) {
    Properties configuration = new Properties();
    configuration.put(TMRK_API_ACCESS_KEY_PROP, accessKey);
    configuration.put(TMRK_API_PRIVATE_KEY_PROP, privateKey);
    return configuration;
}

From source file:com.linkedin.pinot.common.utils.KafkaStarterUtils.java

public static void configureTopicDeletion(Properties configuration, boolean topicDeletionEnabled) {
    configuration.put("delete.topic.enable", Boolean.toString(topicDeletionEnabled));
}