java.util.Properties.putAll()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(281)

本文整理了Java中java.util.Properties.putAll()方法的一些代码示例,展示了Properties.putAll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Properties.putAll()方法的具体详情如下:
包路径:java.util.Properties
类名称:Properties
方法名:putAll

Properties.putAll介绍

暂无

代码示例

代码示例来源:origin: apache/flink

/**
 * Returns a {@link Properties} object from this {@link ParameterTool}.
 *
 * @return A {@link Properties}
 */
public Properties getProperties() {
  Properties props = new Properties();
  props.putAll(this.data);
  return props;
}

代码示例来源:origin: alibaba/druid

public String getProperties() {
  Properties properties = new Properties();
  properties.putAll(connectProperties);
  if (properties.containsKey("password")) {
    properties.put("password", "******");
  }
  return properties.toString();
}

代码示例来源:origin: apache/incubator-gobblin

private static Properties propertiesForConstruction(Properties properties) {
 Properties newProperties = new Properties();
 newProperties.putAll(properties);
 newProperties.setProperty(Trash.SNAPSHOT_CLEANUP_POLICY_CLASS_KEY,
   NoopSnapshotCleanupPolicy.class.getCanonicalName());
 newProperties.setProperty(Trash.TRASH_LOCATION_KEY, "/test/path");
 return newProperties;
}

代码示例来源:origin: docker-java/docker-java

/**
 * Creates a new Properties object containing values overridden from the System properties
 *
 * @param p
 *            The original set of properties to override
 * @return A copy of the original Properties with overridden values
 */
private static Properties overrideDockerPropertiesWithSystemProperties(Properties p, Properties systemProperties) {
  Properties overriddenProperties = new Properties();
  overriddenProperties.putAll(p);
  for (String key : CONFIG_KEYS) {
    if (systemProperties.containsKey(key)) {
      overriddenProperties.setProperty(key, systemProperties.getProperty(key));
    }
  }
  return overriddenProperties;
}

代码示例来源:origin: allure-framework/allure2

public static Optional<String> getProperty(final String key) {
  final Properties properties = new Properties();
  properties.putAll(System.getenv());
  return Optional.ofNullable(properties.getProperty(key)).filter(StringUtils::isNotBlank);
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Cache the system properties and set the system properties to the
 * new values.
 * @throws BuildException if Security prevented this operation.
 */
public void setSystem() throws BuildException {
  try {
    sys = System.getProperties();
    Properties p = new Properties();
    for (String name : sys.stringPropertyNames()) {
      String value = sys.getProperty(name);
      if (value != null) {
        p.put(name, value);
      }
    }
    p.putAll(mergePropertySets());
    for (Environment.Variable v : variables) {
      v.validate();
      p.put(v.getKey(), v.getValue());
    }
    System.setProperties(p);
  } catch (SecurityException e) {
    throw new BuildException("Cannot modify system properties", e);
  }
}

代码示例来源:origin: hibernate/hibernate-orm

protected void init(boolean audited, String auditStrategy) throws IOException {
  this.audited = audited;
  Properties configurationProperties = new Properties();
  configurationProperties.putAll( Environment.getProperties() );
  if ( !audited ) {
    configurationProperties.setProperty( EnversIntegrator.AUTO_REGISTER, "false" );
  }
  if ( createSchema() ) {
    configurationProperties.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
    configurationProperties.setProperty( Environment.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
    configurationProperties.setProperty( EnversSettings.USE_REVISION_ENTITY_WITH_NATIVE_ID, "false" );
  }
  if ( auditStrategy != null && !"".equals( auditStrategy ) ) {
    configurationProperties.setProperty( "org.hibernate.envers.audit_strategy", auditStrategy );
  }
  addConfigurationProperties( configurationProperties );
  configurationProperties.put( AvailableSettings.LOADED_CLASSES, Arrays.asList( getAnnotatedClasses() ) );
  entityManagerFactoryBuilder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(
      new PersistenceUnitDescriptorAdapter(),
      configurationProperties
  );
  emf = entityManagerFactoryBuilder.build().unwrap( HibernateEntityManagerFactory.class );
  serviceRegistry = (StandardServiceRegistryImpl) emf.getSessionFactory()
      .getServiceRegistry()
      .getParentServiceRegistry();
  newEntityManager();
}

代码示例来源:origin: apache/nifi

private JDBCConnectionHolder(InetSocketAddress host, String username, String password, Map<String, String> customProperties, long connectionTimeoutMillis) {
  this.connectionUrl = "jdbc:mysql://" + host.getHostString() + ":" + host.getPort();
  if (customProperties != null) {
    connectionProps.putAll(customProperties);
  }
  connectionProps.put("user", username);
  connectionProps.put("password", password);
  this.connectionTimeoutMillis = connectionTimeoutMillis;
}

代码示例来源:origin: apache/drill

/**
 * Creates HiveConf based on properties in given HiveConf and configuration properties.
 *
 * @param hiveConf hive conf
 * @param properties config properties
 * @return instance of HiveConf
 */
public static HiveConf generateHiveConf(HiveConf hiveConf, Map<String, String> properties) {
 Properties changedProperties = hiveConf.getChangedProperties();
 changedProperties.putAll(properties);
 HiveConf newHiveConf = new HiveConf();
 changedProperties.stringPropertyNames()
   .forEach(name -> newHiveConf.set(name, changedProperties.getProperty(name)));
 return newHiveConf;
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public AppSettings load() {
 Properties p = loadPropertiesFile(homeDir);
 p.putAll(CommandLineParser.parseArguments(cliArguments));
 p.setProperty(PATH_HOME.getKey(), homeDir.getAbsolutePath());
 p = ConfigurationUtils.interpolateVariables(p, System.getenv());
 // the difference between Properties and Props is that the latter
 // supports decryption of values, so it must be used when values
 // are accessed
 Props props = new Props(p);
 completeDefaults(props);
 Arrays.stream(consumers).forEach(c -> c.accept(props));
 return new AppSettingsImpl(props);
}

代码示例来源:origin: apache/kafka

public static Properties addDeserializerToConfig(Properties properties,
                         Deserializer<?> keyDeserializer,
                         Deserializer<?> valueDeserializer) {
  Properties newProperties = new Properties();
  newProperties.putAll(properties);
  if (keyDeserializer != null)
    newProperties.put(KEY_DESERIALIZER_CLASS_CONFIG, keyDeserializer.getClass().getName());
  if (valueDeserializer != null)
    newProperties.put(VALUE_DESERIALIZER_CLASS_CONFIG, valueDeserializer.getClass().getName());
  return newProperties;
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * 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(@Nullable String username, @Nullable 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);
  }
  Connection con = getConnectionFromDriver(mergedProps);
  if (this.catalog != null) {
    con.setCatalog(this.catalog);
  }
  if (this.schema != null) {
    con.setSchema(this.schema);
  }
  return con;
}

代码示例来源:origin: prestodb/presto

static Properties updateSplitSchema(Properties splitSchema, List<HiveColumnHandle> columns)
{
  requireNonNull(splitSchema, "splitSchema is null");
  requireNonNull(columns, "columns is null");
  // clone split properties for update so as not to affect the original one
  Properties updatedSchema = new Properties();
  updatedSchema.putAll(splitSchema);
  updatedSchema.setProperty(LIST_COLUMNS, buildColumns(columns));
  updatedSchema.setProperty(LIST_COLUMN_TYPES, buildColumnTypes(columns));
  ThriftTable thriftTable = parseThriftDdl(splitSchema.getProperty(SERIALIZATION_DDL));
  updatedSchema.setProperty(SERIALIZATION_DDL,
      thriftTableToDdl(pruneThriftTable(thriftTable, columns)));
  return updatedSchema;
}

代码示例来源:origin: ctripcorp/apollo

@SuppressWarnings("unchecked")
public static Properties readConfigFile(String configPath, Properties defaults) {
 Properties props = new Properties();
 if (defaults != null) {
  props.putAll(defaults);
  StringBuilder sb = new StringBuilder();
  for (String propertyName : props.stringPropertyNames()) {
   sb.append(propertyName).append('=').append(props.getProperty(propertyName)).append('\n');

代码示例来源:origin: hibernate/hibernate-orm

public Properties getParametersAsProperties() {
  Properties properties = new Properties();
  properties.putAll( parameters );
  return properties;
}

代码示例来源:origin: pentaho/pentaho-kettle

Properties sp = new Properties();
sp.putAll( System.getProperties() );
 sp.put( key, space.getVariable( key ) );
 List<String> list = transMeta.getUsedVariables();
 for ( String varName : list ) {
  String varValue = sp.getProperty( varName, "" );
  if ( vars.getRowMeta().indexOfValue( varName ) < 0 && !varName.startsWith( Const.INTERNAL_VARIABLE_PREFIX ) ) {
   vars.addValue( new ValueMetaString( varName ), varValue );
 List<String> list = jobMeta.getUsedVariables();
 for ( String varName : list ) {
  String varValue = sp.getProperty( varName, "" );
  if ( vars.getRowMeta().indexOfValue( varName ) < 0 && !varName.startsWith( Const.INTERNAL_VARIABLE_PREFIX ) ) {
   vars.addValue( new ValueMetaString( varName ), varValue );

代码示例来源:origin: apache/flume

private void setProducerProps(Context ctx, String bootStrapServers) {
 producerProps.clear();
 producerProps.put(ProducerConfig.ACKS_CONFIG, DEFAULT_ACKS);
 producerProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, DEFAULT_KEY_SERIALIZER);
 producerProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, DEFAULT_VALUE_SERIAIZER);
 // Defaults overridden based on config
 producerProps.putAll(ctx.getSubProperties(KAFKA_PRODUCER_PREFIX));
 producerProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootStrapServers);
 KafkaSSLUtil.addGlobalSSLParameters(producerProps);
}

代码示例来源:origin: robolectric/robolectric

final Properties properties = getProperties(baseDir.resolve("project.properties"));
Properties overrideProperties = getProperties(baseDir.resolve("test-project.properties"));
properties.putAll(overrideProperties);
while ((lib = properties.getProperty("android.library.reference." + libRef)) != null) {
 Path libraryDir = baseDir.resolve(lib);
 if (Files.isDirectory(libraryDir)) {

代码示例来源:origin: apache/kafka

public static Properties addSerializerToConfig(Properties properties,
                        Serializer<?> keySerializer,
                        Serializer<?> valueSerializer) {
  Properties newProperties = new Properties();
  newProperties.putAll(properties);
  if (keySerializer != null)
    newProperties.put(KEY_SERIALIZER_CLASS_CONFIG, keySerializer.getClass().getName());
  if (valueSerializer != null)
    newProperties.put(VALUE_SERIALIZER_CLASS_CONFIG, valueSerializer.getClass().getName());
  return newProperties;
}

代码示例来源:origin: docker-java/docker-java

private static Properties overrideDockerPropertiesWithEnv(Properties properties, Map<String, String> env) {
  Properties overriddenProperties = new Properties();
  overriddenProperties.putAll(properties);
  // special case which is a sensible default
  if (env.containsKey(DOCKER_HOST)) {
    overriddenProperties.setProperty(DOCKER_HOST, env.get(DOCKER_HOST));
  }
  for (Map.Entry<String, String> envEntry : env.entrySet()) {
    String envKey = envEntry.getKey();
    if (CONFIG_KEYS.contains(envKey)) {
      overriddenProperties.setProperty(envKey, envEntry.getValue());
    }
  }
  return overriddenProperties;
}

相关文章

微信公众号

最新文章

更多