/** * 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; }
public String getProperties() { Properties properties = new Properties(); properties.putAll(connectProperties); if (properties.containsKey("password")) { properties.put("password", "******"); } return properties.toString(); }
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; }
/** * 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; }
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); }
/** * 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); } }
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(); }
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; }
/** * 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; }
@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); }
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; }
/** * 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; }
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; }
@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');
public Properties getParametersAsProperties() { Properties properties = new Properties(); properties.putAll( parameters ); return properties; }
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 );
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); }
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)) {
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; }
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; }