java.util.Properties#clone ( )源码实例Demo

下面列出了java.util.Properties#clone ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: incubator-iotdb   文件: IoTDbDataSourceFactory.java
public void setProperties(IoTDBDataSource ds, Properties prop){
    Properties properties = (Properties)prop.clone();
    String url = (String)properties.remove(DataSourceFactory.JDBC_URL);
    if(url!=null){
        ds.setUrl(url);
        logger.info("URL set {}",url);
    }

    String user = (String) properties.remove(DataSourceFactory.JDBC_USER);
    ds.setUser(user);
    logger.info("User set {}",user);


    String password = (String) properties.remove(DataSourceFactory.JDBC_PASSWORD);
    ds.setPassword(password);
    logger.info("Password set {}",password);


    logger.info("Remaining properties {}", properties.size());

    if (!properties.isEmpty()) {
        BeanConfig.configure(ds, properties);
    }
}
 
源代码2 项目: pxf   文件: PoolDescriptor.java
public PoolDescriptor(String server, String jdbcUrl, Properties connectionConfig, Properties poolConfig, String qualifier) {
    this.server = server;
    this.jdbcUrl = jdbcUrl;

    if (connectionConfig != null) {
        this.connectionConfig = (Properties) connectionConfig.clone();
        // extract credentials to treat them explicitly, remove from connection properties
        this.user = (String) this.connectionConfig.remove(USER_PROPERTY_NAME);
        this.password = (String) this.connectionConfig.remove(PASSWORD_PROPERTY_NAME);
    }

    this.poolConfig = (Properties) poolConfig.clone();
    this.qualifier = qualifier;

    // validate pool configuration
    PROHIBITED_PROPERTIES.forEach(p -> ensurePoolPropertyNotPresent(p));
}
 
源代码3 项目: r-course   文件: MultiHostConnectionProxy.java
/**
 * Initializes the hosts lists and makes a "clean" local copy of the given connection properties so that it can be later used to create standard
 * connections.
 * 
 * @param hosts
 *            The list of hosts for this multi-host connection.
 * @param props
 *            Connection properties from where to get initial settings and to be used in new connections.
 * @return
 *         The number of hosts found in the hosts list.
 */
int initializeHostsSpecs(List<String> hosts, Properties props) {
    this.autoReconnect = "true".equalsIgnoreCase(props.getProperty("autoReconnect")) || "true".equalsIgnoreCase(props.getProperty("autoReconnectForPools"));

    this.hostList = hosts;
    int numHosts = this.hostList.size();

    this.localProps = (Properties) props.clone();
    this.localProps.remove(NonRegisteringDriver.HOST_PROPERTY_KEY);
    this.localProps.remove(NonRegisteringDriver.PORT_PROPERTY_KEY);

    for (int i = 0; i < numHosts; i++) {
        this.localProps.remove(NonRegisteringDriver.HOST_PROPERTY_KEY + "." + (i + 1));
        this.localProps.remove(NonRegisteringDriver.PORT_PROPERTY_KEY + "." + (i + 1));
    }

    this.localProps.remove(NonRegisteringDriver.NUM_HOSTS_PROPERTY_KEY);
    this.localProps.setProperty("useLocalSessionState", "true");

    return numHosts;
}
 
源代码4 项目: fabric-sdk-java   文件: Orderer.java
Orderer(String name, String url, Properties properties) throws InvalidArgumentException {

        if (StringUtil.isNullOrEmpty(name)) {
            throw new InvalidArgumentException("Invalid name for orderer");
        }
        Exception e = checkGrpcUrl(url);
        if (e != null) {
            throw new InvalidArgumentException(e);
        }

        this.name = name;
        this.url = url;
        this.properties = properties == null ? new Properties() : (Properties) properties.clone(); //keep our own copy.
        logger.trace("Created " + toString());

    }
 
源代码5 项目: fabric-sdk-java   文件: Peer.java
Peer(String name, String grpcURL, Properties properties) throws InvalidArgumentException {
    reconnectCount = new AtomicLong(0L);
    id = config.getNextID();

    Exception e = checkGrpcUrl(grpcURL);
    if (e != null) {
        throw new InvalidArgumentException("Bad peer url.", e);

    }

    if (StringUtil.isNullOrEmpty(name)) {
        throw new InvalidArgumentException("Invalid name for peer");
    }

    this.url = grpcURL;
    this.name = name;
    this.properties = properties == null ? new Properties() : (Properties) properties.clone(); //keep our own copy.

    logger.debug("Created " + toString());
}
 
源代码6 项目: warp10-platform   文件: QuasarTokenFilter.java
private QuasarTokenFilter(Properties props, KeyStore keystore, String tokenAesKeyName) {
  this.properties = (Properties) props.clone();
  if( keystore == null ) {
    throw new RuntimeException("keystore is null");
  }

  ByteBuffer bb = ByteBuffer.wrap(getKey(keystore, KeyStore.SIPHASH_TOKEN));
  bb.order(ByteOrder.BIG_ENDIAN);
  tokenSipHashKeyK0 = bb.getLong();
  tokenSipHashKeyK1 = bb.getLong();

  byte[] appSipHashKey = getKey(keystore,KeyStore.SIPHASH_APPID);
  byte[] tokenAESKey = getKey(keystore, tokenAesKeyName);

  this.quasarTokenDecoder = new QuasarTokenDecoder(tokenSipHashKeyK0, tokenSipHashKeyK1, tokenAESKey);
  this.quasarTokenRevoked = new QuasarTokensRevoked(properties, appSipHashKey);
}
 
源代码7 项目: rebuild   文件: AesPreferencesConfigurer.java
/**
    * @param props
    */
private void afterLoad(Properties props) {
	final Object[] keys = props.keySet().toArray(new Object[0]);
	for (Object key : keys) {
		String cleanKey = key.toString();
		// AES decrypt if have `.aes` suffix
		if (cleanKey.endsWith(".aes")) {
			String val = props.getProperty(cleanKey);
			val = AES.decryptQuietly(val);

			props.remove(cleanKey);
			cleanKey = cleanKey.replace(".aes", "");
			props.put(cleanKey, val);
		}
		
		// Overrides by command-line
		String viaCL = System.getProperty(cleanKey);
		if (StringUtils.isNotBlank(viaCL)) {
			props.put(cleanKey, viaCL);
		}
	}

	// SPEC MYSQL PORT
	String mysqlPort = System.getProperty("mysql.port");
	String dbUrl = props.getProperty("db.url");
	if (StringUtils.isNotBlank(mysqlPort) && StringUtils.isNotBlank(dbUrl)) {
		dbUrl = dbUrl.replace("3306", mysqlPort);
		props.put("db.url", dbUrl);
	}

	// MUST NOT BE NULL
       setIfEmpty(props, ConfigurableItem.CacheHost, "127.0.0.1");
       setIfEmpty(props, ConfigurableItem.CachePort, "6379");

	propsHold = (Properties) props.clone();
}
 
源代码8 项目: cacheonix-core   文件: PropertiesHelper.java
/**
 * replace a property by a starred version
 *
 * @param props properties to check
 * @param key proeprty to mask
 * @return cloned and masked properties
 */
public static Properties maskOut(Properties props, String key) {
	Properties clone = (Properties) props.clone();
	if (clone.get(key) != null) {
		clone.setProperty(key, "****");
	}
	return clone;
}
 
源代码9 项目: pentaho-reporting   文件: DriverDataSourceCache.java
public DriverManagerDataSource( final String jdbcConnectString,
                                final Properties properties ) {
  if ( jdbcConnectString == null ) {
    throw new NullPointerException();
  }
  if ( properties == null ) {
    throw new NullPointerException();
  }
  this.jdbcConnectString = jdbcConnectString;
  this.jdbcProperties = (Properties) properties.clone();
}
 
源代码10 项目: tajo   文件: CliClientParamsFactory.java
public static Properties get(@Nullable Properties connParam) {
  Properties copy = connParam == null ? new Properties() : (Properties) connParam.clone();
  for (Map.Entry<String, String> entry : DEFAULT_PARAMS.entrySet()) {
    if (!copy.contains(entry.getKey())) {
      copy.setProperty(entry.getKey(), entry.getValue());
    }
  }
  return copy;
}
 
源代码11 项目: Komondor   文件: ConnectionPropertiesImpl.java
/**
 * Initializes driver properties that come from URL or properties passed to
 * the driver manager.
 * 
 * @param info
 * @throws SQLException
 */
protected void initializeProperties(Properties info) throws SQLException {
    if (info != null) {
        // For backwards-compatibility
        String profileSqlLc = info.getProperty("profileSql");

        if (profileSqlLc != null) {
            info.put("profileSQL", profileSqlLc);
        }

        Properties infoCopy = (Properties) info.clone();

        infoCopy.remove(NonRegisteringDriver.HOST_PROPERTY_KEY);
        infoCopy.remove(NonRegisteringDriver.USER_PROPERTY_KEY);
        infoCopy.remove(NonRegisteringDriver.PASSWORD_PROPERTY_KEY);
        infoCopy.remove(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
        infoCopy.remove(NonRegisteringDriver.PORT_PROPERTY_KEY);
        infoCopy.remove("profileSql");

        int numPropertiesToSet = PROPERTY_LIST.size();

        for (int i = 0; i < numPropertiesToSet; i++) {
            java.lang.reflect.Field propertyField = PROPERTY_LIST.get(i);

            try {
                ConnectionProperty propToSet = (ConnectionProperty) propertyField.get(this);

                propToSet.initializeFrom(infoCopy, getExceptionInterceptor());
            } catch (IllegalAccessException iae) {
                throw SQLError.createSQLException(Messages.getString("ConnectionProperties.unableToInitDriverProperties") + iae.toString(),
                        SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
            }
        }

        postInitialization();
    }
}
 
源代码12 项目: spliceengine   文件: EmbedConnectionMaker.java
/**
 * Intended to be called the very first time we connect to a newly initialized database.  This
 * method appears to be responsible for setting the initial password for our 'splice' user.
 */
public Connection createFirstNew(SConfiguration configuration,Properties dbProperties) throws SQLException {
    Properties properties = (Properties)dbProperties.clone();
    String auth = configuration.getAuthentication();
    if (!"LDAP".equalsIgnoreCase(auth)){
        properties.remove(EmbedConnection.INTERNAL_CONNECTION);
    }
    final String SPLICE_DEFAULT_PASSWORD = "admin";
    return driver.connect(JDBC_URL + ";create=true;password=" + SPLICE_DEFAULT_PASSWORD, properties);
}
 
源代码13 项目: ignite   文件: ConnectionPropertiesImpl.java
/**
 * @param url URL connection.
 * @param props Environment properties.
 * @throws SQLException On error.
 */
public void init(String url, Properties props) throws SQLException {
    Properties props0 = (Properties)props.clone();

    if (!F.isEmpty(url))
        parseUrl(url, props0);

    for (ConnectionProperty aPropsArray : propsArray)
        aPropsArray.init(props0);

    if (!F.isEmpty(props.getProperty("user"))) {
        setUsername(props.getProperty("user"));
        setPassword(props.getProperty("password"));
    }
}
 
源代码14 项目: vividus   文件: PropertyParser.java
public void setProperties(Properties properties)
{
    this.properties = (Properties) properties.clone();
}
 
源代码15 项目: javamelody   文件: JdbcDriver.java
/** {@inheritDoc} */
@Override
public Connection connect(String url, Properties info) throws SQLException {
	if ("false".equals(info.get("javamelody"))) {
		// if property javamelody=false then it's not for us
		// (we pass here from the DriverManager.getConnection below)
		return null;
	}
	String myUrl = url;
	// we load first the driver class from the info or the url, to be sure that it will be found
	String proxiedDriver = info.getProperty("driver");
	if (proxiedDriver == null && myUrl != null) {
		// if not in the info, the driver class could also be passed at the end of the url, for example ...?driver=org.h2.Driver
		final int index = myUrl.indexOf("driver=");
		if (index != -1) {
			proxiedDriver = myUrl.substring(index + "driver=".length());
			myUrl = myUrl.substring(0, index - 1);
		}
	}
	if (proxiedDriver == null) {
		// if the driver is not defined in the info or in the url
		// it could still be found automatically if the driver is in the classpath
		// or (in WEB-INF/lib and if the jdbc drivers are not loaded by the JDK before this webapp)
		// but we don't want to create proxies and increment counts for the connections inside datasources
		// so we only accept and go further if driver is defined in the info or in the url
		return null;
	}
	try {
		// on utilise Thread.currentThread().getContextClassLoader() car le driver peut ne pas être
		// dans le même classLoader que les classes de javamelody
		// Class driverClass =
		Class.forName(proxiedDriver, true, Thread.currentThread().getContextClassLoader());
		// et non Class.forName(proxiedDriver);
	} catch (final ClassNotFoundException e) {
		throw new SQLException(e.getMessage(), e);
	}

	final Properties myInfo = (Properties) info.clone();
	myInfo.remove("driver");
	myInfo.put("javamelody", "false");
	Parameters.initJdbcDriverParameters(myUrl, myInfo);
	// we could call driverClass.newInstance().connect(myUrl, myInfo)
	// possibly by looking the driver which accepts the url in DriverManager.getDrivers()
	// but we prefer calling the standard DriverManager.getConnection(myUrl, myInfo)
	return JdbcWrapper.SINGLETON
			.createConnectionProxy(DriverManager.getConnection(myUrl, myInfo));
}
 
源代码16 项目: netbeans-mmd-plugin   文件: MMapURI.java
private MMapURI(@Nonnull final URI uri, final boolean isFile, @Nullable final Properties properties) {
  this.uri = uri;
  this.fileUriFlag = isFile;
  this.parameters = properties == null ? new Properties() : (Properties) properties.clone();
}
 
源代码17 项目: r-course   文件: NonRegisteringDriver.java
protected java.sql.Connection connectReplicationConnection(String url, Properties info) throws SQLException {
    Properties parsedProps = parseURL(url, info);

    if (parsedProps == null) {
        return null;
    }

    Properties masterProps = (Properties) parsedProps.clone();
    Properties slavesProps = (Properties) parsedProps.clone();

    // Marker used for further testing later on, also when
    // debugging
    slavesProps.setProperty("com.mysql.jdbc.ReplicationConnection.isSlave", "true");

    int numHosts = Integer.parseInt(parsedProps.getProperty(NUM_HOSTS_PROPERTY_KEY));

    if (numHosts < 2) {
        throw SQLError.createSQLException("Must specify at least one slave host to connect to for master/slave replication load-balancing functionality",
                SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE, null);
    }
    List<String> slaveHostList = new ArrayList<String>();
    List<String> masterHostList = new ArrayList<String>();

    String firstHost = masterProps.getProperty(HOST_PROPERTY_KEY + ".1") + ":" + masterProps.getProperty(PORT_PROPERTY_KEY + ".1");

    boolean usesExplicitServerType = NonRegisteringDriver.isHostPropertiesList(firstHost);

    for (int i = 0; i < numHosts; i++) {
        int index = i + 1;

        masterProps.remove(HOST_PROPERTY_KEY + "." + index);
        masterProps.remove(PORT_PROPERTY_KEY + "." + index);
        slavesProps.remove(HOST_PROPERTY_KEY + "." + index);
        slavesProps.remove(PORT_PROPERTY_KEY + "." + index);

        String host = parsedProps.getProperty(HOST_PROPERTY_KEY + "." + index);
        String port = parsedProps.getProperty(PORT_PROPERTY_KEY + "." + index);
        if (usesExplicitServerType) {
            if (isHostMaster(host)) {
                masterHostList.add(host);
            } else {
                slaveHostList.add(host);
            }
        } else {
            if (i == 0) {
                masterHostList.add(host + ":" + port);
            } else {
                slaveHostList.add(host + ":" + port);
            }
        }
    }

    slavesProps.remove(NUM_HOSTS_PROPERTY_KEY);
    masterProps.remove(NUM_HOSTS_PROPERTY_KEY);
    masterProps.remove(HOST_PROPERTY_KEY);
    masterProps.remove(PORT_PROPERTY_KEY);
    slavesProps.remove(HOST_PROPERTY_KEY);
    slavesProps.remove(PORT_PROPERTY_KEY);

    return ReplicationConnectionProxy.createProxyInstance(masterHostList, masterProps, slaveHostList, slavesProps);
}
 
源代码18 项目: FoxTelem   文件: DefaultPropertySet.java
public void initializeProperties(Properties props) {
    if (props != null) {
        Properties infoCopy = (Properties) props.clone();

        // TODO do we need to remove next properties (as it was before)?
        infoCopy.remove(PropertyKey.HOST.getKeyName());
        infoCopy.remove(PropertyKey.PORT.getKeyName());
        infoCopy.remove(PropertyKey.USER.getKeyName());
        infoCopy.remove(PropertyKey.PASSWORD.getKeyName());
        infoCopy.remove(PropertyKey.DBNAME.getKeyName());

        for (PropertyKey propKey : PropertyDefinitions.PROPERTY_KEY_TO_PROPERTY_DEFINITION.keySet()) {
            try {
                RuntimeProperty<?> propToSet = getProperty(propKey);
                propToSet.initializeFrom(infoCopy, null);

            } catch (CJException e) {
                throw ExceptionFactory.createException(WrongArgumentException.class, e.getMessage(), e);
            }
        }

        // Translate legacy SSL properties if sslMode isn't explicitly set. Default sslMode is PREFERRED.
        RuntimeProperty<SslMode> sslMode = this.<SslMode> getEnumProperty(PropertyKey.sslMode);
        if (!sslMode.isExplicitlySet()) {
            RuntimeProperty<Boolean> useSSL = this.getBooleanProperty(PropertyKey.useSSL);
            RuntimeProperty<Boolean> verifyServerCertificate = this.getBooleanProperty(PropertyKey.verifyServerCertificate);
            RuntimeProperty<Boolean> requireSSL = this.getBooleanProperty(PropertyKey.requireSSL);
            if (useSSL.isExplicitlySet() || verifyServerCertificate.isExplicitlySet() || requireSSL.isExplicitlySet()) {
                if (!useSSL.getValue()) {
                    sslMode.setValue(SslMode.DISABLED);
                } else if (verifyServerCertificate.getValue()) {
                    sslMode.setValue(SslMode.VERIFY_CA);
                } else if (requireSSL.getValue()) {
                    sslMode.setValue(SslMode.REQUIRED);
                }
            }
        }

        // add user-defined properties
        for (Object key : infoCopy.keySet()) {
            String val = infoCopy.getProperty((String) key);
            PropertyDefinition<String> def = new StringPropertyDefinition((String) key, null, val, PropertyDefinitions.RUNTIME_MODIFIABLE,
                    Messages.getString("ConnectionProperties.unknown"), "8.0.10", PropertyDefinitions.CATEGORY_USER_DEFINED, Integer.MIN_VALUE);
            RuntimeProperty<String> p = new StringProperty(def);
            addProperty(p);
        }
        postInitialization();
    }
}
 
源代码19 项目: zeppelin   文件: JDBCUserConfigurations.java
public void setPropertyMap(String dbPrefix, Properties properties) {
  Properties p = (Properties) properties.clone();
  propertiesMap.put(dbPrefix, p);
}
 
源代码20 项目: database   文件: AbstractTransactionService.java
public AbstractTransactionService(final Properties properties) {
    
    this.properties = (Properties) properties.clone();

    {
        
        this.minReleaseAge = LongValidator.GTE_ZERO.parse(
                Options.MIN_RELEASE_AGE, properties.getProperty(
                        Options.MIN_RELEASE_AGE,
                        Options.DEFAULT_MIN_RELEASE_AGE));

        if (log.isInfoEnabled())
            log.info(Options.MIN_RELEASE_AGE + "=" + minReleaseAge);
    
    }
    
    runState = TxServiceRunState.Starting;
    
}