当前位置: 首页>>代码示例>>Java>>正文


Java Properties.putAll方法代码示例

本文整理汇总了Java中java.util.Properties.putAll方法的典型用法代码示例。如果您正苦于以下问题:Java Properties.putAll方法的具体用法?Java Properties.putAll怎么用?Java Properties.putAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Properties的用法示例。


在下文中一共展示了Properties.putAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getConnection

import java.util.Properties; //导入方法依赖的package包/类
public Connection getConnection()
        throws SQLException {
    Driver driver = getDriver();

    Properties props = new Properties();

    if (stringHasValue(userId)) {
        props.setProperty("user", userId); //$NON-NLS-1$
    }

    if (stringHasValue(password)) {
        props.setProperty("password", password); //$NON-NLS-1$
    }

    props.putAll(otherProperties);

    Connection conn = driver.connect(connectionURL, props);

    if (conn == null) {
        throw new SQLException(getString("RuntimeError.7")); //$NON-NLS-1$
    }

    return conn;
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:25,代码来源:JDBCConnectionFactory.java

示例2: loadConfig

import java.util.Properties; //导入方法依赖的package包/类
private String loadConfig(ConfigFileOutputFormat outputFormat, String appId, String clusterName,
                          String namespace, String dataCenter, String clientIp,
                          HttpServletRequest request,
                          HttpServletResponse response) throws IOException {
  ApolloConfig apolloConfig = configController.queryConfig(appId, clusterName, namespace,
      dataCenter, "-1", clientIp, null, request, response);

  if (apolloConfig == null || apolloConfig.getConfigurations() == null) {
    return null;
  }

  String result = null;

  switch (outputFormat) {
    case PROPERTIES:
      Properties properties = new Properties();
      properties.putAll(apolloConfig.getConfigurations());
      result = PropertiesUtil.toString(properties);
      break;
    case JSON:
      result = gson.toJson(apolloConfig.getConfigurations());
      break;
  }

  return result;
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:27,代码来源:ConfigFileController.java

示例3: loadManagementProperties

import java.util.Properties; //导入方法依赖的package包/类
public static Properties loadManagementProperties() {
    Properties props = new Properties();

    // Load the management properties from the config file

    String fname = System.getProperty(CONFIG_FILE);
    readConfiguration(fname, props);

    // management properties can be overridden by system properties
    // which take precedence
    Properties sysProps = System.getProperties();
    synchronized (sysProps) {
        props.putAll(sysProps);
    }

    return props;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:Agent.java

示例4: agentmain

import java.util.Properties; //导入方法依赖的package包/类
public static void agentmain(String args) throws Exception {
    if (args == null || args.length() == 0) {
        args = JMXREMOTE;           // default to local management
    }

    Properties arg_props = parseString(args);

    // Read properties from the config file
    Properties config_props = new Properties();
    String fname = arg_props.getProperty(CONFIG_FILE);
    readConfiguration(fname, config_props);

    // Arguments override config file
    config_props.putAll(arg_props);
    startAgent(config_props);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:Agent.java

示例5: getMergedProperties

import java.util.Properties; //导入方法依赖的package包/类
private Properties getMergedProperties() {
  Properties props = new Properties();
  // add store properties
  if (this.storeProperties != null) {
    props.putAll(this.storeProperties);
  }
  // add reader properties
  if (reader.getProperties() != null) {
    props.putAll(reader.getProperties());
  }
  // override with user properties
  if (writer.getProperties() != null) {
    props.putAll(writer.getProperties());
  }

  return props;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:LocalTierStore.java

示例6: buildDefaults

import java.util.Properties; //导入方法依赖的package包/类
private Properties buildDefaults() throws CertificateException, NoSuchAlgorithmException,
    KeyStoreException, IOException, URISyntaxException {
  Properties defaultProperties = new Properties();
  Properties herokuKafkaConfigVarProperties = buildHerokuKafkaConfigVars();
  Properties kafkaStreamsProperties = buildKafkaStreamsDefaults();

  defaultProperties.putAll(herokuKafkaConfigVarProperties);
  defaultProperties.putAll(kafkaStreamsProperties);


  return defaultProperties;
}
 
开发者ID:kissaten,项目名称:kafka-streams-on-heroku,代码行数:13,代码来源:AnomalyDetectorConfig.java

示例7: exposeKafkaProperties

import java.util.Properties; //导入方法依赖的package包/类
@Produces
@RequestScoped
public Properties exposeKafkaProperties() throws IOException {
    final Properties properties = new Properties();
    properties.putAll(kafkaProperties);
    return properties;
}
 
开发者ID:sdaschner,项目名称:scalable-coffee-shop,代码行数:8,代码来源:KafkaConfigurator.java

示例8: loadLocalStorage

import java.util.Properties; //导入方法依赖的package包/类
private boolean loadLocalStorage(String accountNameValue, Map<String, String> customMap)
{
    WebDriver webDriver = util.getEngine().getDriver();
    if(webDriver instanceof WebStorage)
    {
        WebStorage webStorage = (WebStorage) webDriver;
        LocalStorage localStorage = webStorage.getLocalStorage();

        Properties pro = new Properties();
        if(PathUtil.proLoad(pro, "localStorage." + accountNameValue))
        {
            if(pro.isEmpty())
            {
                return false;
            }
            
            pro.putAll(customMap);

            pro.stringPropertyNames().parallelStream().forEach((key) -> {
            	localStorage.setItem(key, pro.getProperty(key));
            });

            return true;
        }
    }

    return false;
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:29,代码来源:AutoModuleProxy.java

示例9: getConnectionFromDriver

import java.util.Properties; //导入方法依赖的package包/类
/**
 * Build properties for the Driver, including the given username and password (if any),
 * and obtain a corresponding Connection.
 * @param username the name of the user
 * @param password the password to use
 * @return the obtained Connection
 * @throws SQLException in case of failure
 * @see java.sql.Driver#connect(String, java.util.Properties)
 */
protected Connection getConnectionFromDriver(String username, String password) throws SQLException {
	Properties mergedProps = new Properties();
	Properties connProps = getConnectionProperties();
	if (connProps != null) {
		mergedProps.putAll(connProps);
	}
	if (username != null) {
		mergedProps.setProperty("user", username);
	}
	if (password != null) {
		mergedProps.setProperty("password", password);
	}
	return getConnectionFromDriver(mergedProps);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:AbstractDriverBasedDataSource.java

示例10: loadAllureProperties

import java.util.Properties; //导入方法依赖的package包/类
public static Properties loadAllureProperties() {
    final Properties properties = new Properties();
    if (Objects.nonNull(ClassLoader.getSystemResource(ALLURE_PROPERTIES_FILE))) {
        try (InputStream stream = ClassLoader.getSystemResourceAsStream(ALLURE_PROPERTIES_FILE)) {
            properties.load(stream);
        } catch (IOException e) {
            LOGGER.error("Error while reading allure.properties file from classpath: %s", e.getMessage());
        }
    }
    properties.putAll(System.getProperties());
    return properties;
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:13,代码来源:PropertiesUtils.java

示例11: createConsumer

import java.util.Properties; //导入方法依赖的package包/类
/**
 * Sets up a {@link KafkaConsumer} from a copy of the given configuration that has
 * {@link ConsumerConfig#AUTO_OFFSET_RESET_CONFIG} set to "earliest" and {@link ConsumerConfig#ENABLE_AUTO_COMMIT_CONFIG}
 * set to "true" to prevent missing events as well as repeat consumption.
 * @param consumerConfig Consumer configuration
 * @return Consumer
 */
private static <K, V> KafkaConsumer<K, V> createConsumer(final Properties consumerConfig) {
    final Properties filtered = new Properties();
    filtered.putAll(consumerConfig);
    filtered.setProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
    filtered.setProperty(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "true");
    return new KafkaConsumer<>(filtered);
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:15,代码来源:IntegrationTestUtils.java

示例12: startRemoteManagementAgent

import java.util.Properties; //导入方法依赖的package包/类
private static synchronized void startRemoteManagementAgent(String args) throws Exception {
    if (jmxServer != null) {
        throw new RuntimeException(getText(INVALID_STATE, "Agent already started"));
    }

    try {
        Properties argProps = parseString(args);
        configProps = new Properties();

        // Load the management properties from the config file
        // if config file is not specified readConfiguration implicitly
        // reads <java.home>/conf/management/management.properties

        String fname = System.getProperty(CONFIG_FILE);
        readConfiguration(fname, configProps);

        // management properties can be overridden by system properties
        // which take precedence
        Properties sysProps = System.getProperties();
        synchronized (sysProps) {
            configProps.putAll(sysProps);
        }

        // if user specifies config file into command line for either
        // jcmd utilities or attach command it overrides properties set in
        // command line at the time of VM start
        String fnameUser = argProps.getProperty(CONFIG_FILE);
        if (fnameUser != null) {
            readConfiguration(fnameUser, configProps);
        }

        // arguments specified in command line of jcmd utilities
        // override both system properties and one set by config file
        // specified in jcmd command line
        configProps.putAll(argProps);

        // jcmd doesn't allow to change ThreadContentionMonitoring, but user
        // can specify this property inside config file, so enable optional
        // monitoring functionality if this property is set
        final String enableThreadContentionMonitoring =
                configProps.getProperty(ENABLE_THREAD_CONTENTION_MONITORING);

        if (enableThreadContentionMonitoring != null) {
            ManagementFactory.getThreadMXBean().
                    setThreadContentionMonitoringEnabled(true);
        }

        String jmxremotePort = configProps.getProperty(JMXREMOTE_PORT);
        if (jmxremotePort != null) {
            jmxServer = ConnectorBootstrap.
                    startRemoteConnectorServer(jmxremotePort, configProps);

            startDiscoveryService(configProps);
        } else {
            throw new AgentConfigurationError(INVALID_JMXREMOTE_PORT, "No port specified");
        }
    } catch (JdpException e) {
        error(e);
    } catch (AgentConfigurationError err) {
        error(err);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:63,代码来源:Agent.java

示例13: transformApolloConfigToProperties

import java.util.Properties; //导入方法依赖的package包/类
private Properties transformApolloConfigToProperties(ApolloConfig apolloConfig) {
  Properties result = new Properties();
  result.putAll(apolloConfig.getConfigurations());
  return result;
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:6,代码来源:RemoteConfigRepository.java

示例14: testEnableTLSVersion

import java.util.Properties; //导入方法依赖的package包/类
/**
 * Tests fix for Bug#87379. This allows TLS version to be overridden through a new configuration
 * option - enabledTLSProtocols. When set to some combination of TLSv1, TLSv1.1, or TLSv1.2 (comma-
 * separated, no spaces), the default behaviour restricting the TLS version based on JRE and MySQL
 * Server version is bypassed to enable or restrict specific TLS versions.
 * 
 * This test requires community server (with yaSSL) in -Dcom.mysql.jdbc.testsuite.url and
 * commercial server (with OpenSSL) in -Dcom.mysql.jdbc.testsuite.url.sha256default
 * 
 * Test certificates from testsuite/ssl-test-certs must be installed on both servers.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testEnableTLSVersion() throws Exception {

    final String[] testDbUrls;
    Properties props = new Properties();
    props.setProperty("allowPublicKeyRetrieval", "true");
    props.setProperty("useSSL", "true");
    props.setProperty("requireSSL", "true");
    props.setProperty("trustCertificateKeyStoreUrl", "file:src/testsuite/ssl-test-certs/ca-truststore");
    props.setProperty("trustCertificateKeyStoreType", "JKS");
    props.setProperty("trustCertificateKeyStorePassword", "password");

    if (this.sha256Conn != null && ((MySQLConnection) this.sha256Conn).versionMeetsMinimum(5, 5, 7)) {
        testDbUrls = new String[] { BaseTestCase.dbUrl, sha256Url };
    } else {
        testDbUrls = new String[] { BaseTestCase.dbUrl };
    }

    for (String testDbUrl : testDbUrls) {
        System.out.println(testDbUrl);
        System.out.println(System.getProperty("java.version"));
        Connection sslConn = getConnectionWithProps(testDbUrl, props);
        assertTrue(((MySQLConnection) sslConn).getIO().isSSLEstablished());
        List<String> expectedProtocols = new ArrayList<String>();
        expectedProtocols.add("TLSv1");
        if (Util.getJVMVersion() > 6 && ((MySQLConnection) sslConn).versionMeetsMinimum(5, 7, 10)) {
            ResultSet rs1 = sslConn.createStatement().executeQuery("SELECT @@global.tls_version");
            assertTrue(rs1.next());
            String supportedTLSVersions = rs1.getString(1);
            System.out.println("Server reported TLS version support: " + supportedTLSVersions);
            expectedProtocols.addAll(Arrays.asList(supportedTLSVersions.split("\\s*,\\s*")));
        }

        String[] testingProtocols = { "TLSv1.2", "TLSv1.1", "TLSv1" };
        for (String protocol : testingProtocols) {
            Properties testProps = new Properties();
            testProps.putAll(props);
            testProps.put("enabledTLSProtocols", protocol);
            System.out.println("Testing " + protocol + " expecting connection: " + expectedProtocols.contains(protocol));
            try {
                Connection tlsConn = getConnectionWithProps(testDbUrl, testProps);
                if (!expectedProtocols.contains(protocol)) {
                    fail("Expected to fail connection with " + protocol + " due to lack of server support.");
                }
                ResultSet rset = tlsConn.createStatement().executeQuery("SHOW STATUS LIKE 'ssl_version'");
                assertTrue(rset.next());
                String tlsVersion = rset.getString(2);
                assertEquals(protocol, tlsVersion);
                tlsConn.close();
            } catch (Exception e) {
                if (expectedProtocols.contains(protocol)) {
                    e.printStackTrace();
                    fail("Expected to be able to connect with " + protocol + " protocol, but failed.");
                }
            }
        }
        sslConn.close();
    }
}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:73,代码来源:ConnectionRegressionTest.java

示例15: createPropertiesFromMap

import java.util.Properties; //导入方法依赖的package包/类
@SuppressWarnings( {"unchecked"} )
private static Properties createPropertiesFromMap(Map map) {
	Properties properties = new Properties();
	properties.putAll( map );
	return properties;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:SessionFactoryImpl.java


注:本文中的java.util.Properties.putAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。