Example usage for java.util Properties clone

List of usage examples for java.util Properties clone

Introduction

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

Prototype

@Override
    public synchronized Object clone() 

Source Link

Usage

From source file:com.tesora.dve.standalone.PETest.java

public static DBHelper buildHelper() throws Exception {
    Properties catalogProps = TestCatalogHelper.getTestCatalogProps(resourceRoot);
    Properties tempProps = (Properties) catalogProps.clone();
    tempProps.remove(DBHelper.CONN_DBNAME);
    DBHelper dbHelper = new DBHelper(tempProps);
    dbHelper.connect();/*from   w ww .j  ava 2s.  c om*/
    return dbHelper;
}

From source file:com.tesora.dve.standalone.PETest.java

public static void cleanupDatabase(int numSites, String dbName) throws Exception {
    Properties catalogProps = TestCatalogHelper.getTestCatalogProps(PETest.class);
    Properties tempProps = (Properties) catalogProps.clone();
    tempProps.remove(DBHelper.CONN_DBNAME);
    DBHelper myHelper = new DBHelper(tempProps).connect();
    try {//  w w w. j  av a2 s  .  c  o  m
        for (int i = 1; i <= numSites; i++) {
            myHelper.executeQuery("DROP DATABASE IF EXISTS site" + i + "_" + dbName);
        }
    } finally {
        myHelper.disconnect();
    }
}

From source file:com.tesora.dve.common.PEFileUtils.java

/**
 * Save the specified properties back to a file
 * //from  www.ja  va2s. c  o m
 * @param testClass
 * @param fileName
 * @param props
 * @throws PEException
 */
public static void savePropertiesToClasspath(Class<?> testClass, String fileName, Properties props)
        throws PEException {
    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream(new File(testClass.getClassLoader().getResource(fileName).toURI()));

        // We will encrypt on a cloned copy of the properties so that we can
        // continue using the properties we have
        Properties clonedProps = (Properties) props.clone();

        encrypt(clonedProps);

        clonedProps.store(fos, "This file was last updated by DVE on:");
    } catch (Exception e) {
        throw new PEException("Error saving properties file '" + fileName + "'", e);
    } finally {
        if (fos != null) {
            try {

                fos.close();
            } catch (Exception e) {
                // ignore
            }
        }
    }
}

From source file:ezbake.data.common.graph.TitanGraphConfiguration.java

public TitanGraphConfiguration(Properties props) {
    properties = (Properties) props.clone();

    for (final String key : properties.stringPropertyNames()) {
        // add only properties started with "storage"
        if (key.startsWith(GraphDatabaseConfiguration.STORAGE_NAMESPACE)) {
            setProperty(key, properties.getProperty(key));
        }/*from  w w w  . ja  v a 2 s  . co m*/

    }

}

From source file:com.bt.aloha.mockphones.MockphonesRouter.java

@Override
public IncomingDialogRouterRule findRule(String destination) {
    IncomingDialogRouterRule rule = super.findRule(destination);

    if (rule == null) {
        return rule;
    }//from  w w  w .j  av a  2s.co m

    log.debug("Checking for parameters specified in sip uri");
    String[] params = MockphonesHelper.getParams(destination);
    if (params == null || params.length == 0)
        return rule;

    log.debug(String.format("Creating new router rule for %d arguments specified in sip uri", params.length));
    Properties props = rule.getDialogProperties();
    if (props == null)
        return rule;
    props = (Properties) props.clone();
    String propertyOrdering = props.getProperty("prop.ordering");
    if (propertyOrdering == null || propertyOrdering.length() == 0)
        return rule;

    log.debug("Parsing arguments to create new router rule");
    String[] propertyOrder = propertyOrdering.split(",");
    for (int i = 0; i < params.length && i < propertyOrder.length; i++) {
        props.setProperty(propertyOrder[i].trim(), params[i]);
    }
    IncomingDialogRouterRule newRule = new IncomingDialogRouterRule(rule.getRulePattern(), props,
            rule.getDialogSipBean());
    log.debug("New rule created");

    return newRule;
}

From source file:com.google.code.guice.repository.configuration.PersistenceUnitConfiguration.java

public PersistenceUnitConfiguration(String persistenceUnitName, Properties properties) {
    this.persistenceUnitName = persistenceUnitName;
    this.properties = (Properties) properties.clone();
}

From source file:net.gleamynode.oil.impl.wal.store.FileLogStore.java

public void setProperties(Properties properties) {
    this.properties = (Properties) properties.clone();
}

From source file:ca.inverse.sogo.engine.source.SOGoPropertyConverter.java

private void initMappings() throws IOException {
    Properties mappings = new java.util.Properties();
    mappings.load(getClass().getResourceAsStream(SIF2ICAL_MAPPINGS_RESOURCE));
    this.sif2ICalDirectMappings = (Map) mappings.clone();
    mappings.load(getClass().getResourceAsStream(ICAL2SIF_MAPPINGS_RESOURCE));
    this.iCal2SifDirectMappings = (Map) mappings.clone();

    Map dependencies = new Hashtable();
    dependencies.put("IsRecurring", Arrays.asList(new String[] { "RecurrenceType", // just a hint: should be processed first
            "Interval", "MonthOfYear", "DayOfMonth", "DayOfWeekMask", "Instance", "PatternStartDate",
            "NoEndDate", "PatternEndDate", "Occurrences", }));
    dependencies.put("ReminderSet", Arrays
            .asList(new String[] { "ReminderMinutesBeforeStart", "ReminderSoundFile", "ReminderOptions", }));
    this.sif2ICalDependentMappings = dependencies;

    this.iCal2SifDependentMappings = new Hashtable();
    this.iCal2SifDependentMappings.put("RRULE", Boolean.TRUE);
}

From source file:com.micromux.cassandra.jdbc.CassandraConnection.java

/**
 * Instantiates a new CassandraConnection.
 *//*from   w  ww  . j a  va 2  s.  c  om*/
public CassandraConnection(Properties props) throws SQLException {

    hostListPrimary = new TreeSet<String>();
    hostListBackup = new TreeSet<String>();
    connectionProps = (Properties) props.clone();
    clientInfo = new Properties();

    url = PROTOCOL + createSubName(props);

    String[] hosts = {};
    String host = props.getProperty(TAG_SERVER_NAME);
    int port = Integer.parseInt(props.getProperty(TAG_PORT_NUMBER));

    currentKeyspace = props.getProperty(TAG_DATABASE_NAME);
    username = props.getProperty(TAG_USER);
    String password = props.getProperty(TAG_PASSWORD);
    String version = props.getProperty(TAG_CQL_VERSION, DEFAULT_CQL_VERSION);

    connectionProps.setProperty(TAG_ACTIVE_CQL_VERSION, version);
    defaultConsistencyLevel = ConsistencyLevel
            .valueOf(props.getProperty(TAG_CONSISTENCY_LEVEL, ConsistencyLevel.ONE.name()));

    // take a stab at the CQL version based on what was requested
    majorCqlVersion = getMajor(version);

    // dealing with multiple hosts passed as seeds in the JDBC URL : jdbc:cassandra://lyn4e900.tlt--lyn4e901.tlt--lyn4e902.tlt:9160/fluks
    // in this phase we get the list of all the nodes of the cluster
    String currentHost = "";

    try {

        if (host.contains("--")) {
            hosts = new String[host.split("--").length];
            int i = 0;
            for (String h : host.split("--")) {
                hosts[i] = h;
                i++;
            }
        } else {
            hosts = new String[1];
            hosts[0] = host;
        }

        Random rand = new Random();

        currentHost = hosts[rand.nextInt(hosts.length)];
        logger.debug("Chosen seed : " + currentHost);

        Cluster.Builder connectionBuilder = Cluster.builder().addContactPoint(host);

        if (port > 0) {
            connectionBuilder.withPort(port);
        }

        if (!StringUtils.isEmpty(username)) {
            connectionBuilder.withCredentials(username, password);
        }

        // configure SSL if specified
        SSLOptions sslOptions = createSSLOptions(props);

        if (sslOptions != null) {
            connectionBuilder.withSSL(sslOptions);
        }

        Cluster cluster = connectionBuilder.build();
        session = cluster.connect();

        // if keyspace was specified - use it
        if (!session.isClosed() && !StringUtils.isEmpty(currentKeyspace)) {
            session.execute(String.format("USE %s;", currentKeyspace));
        }

        // request version from session
        Configuration configuration = session.getCluster().getConfiguration();
        if ((configuration != null) && (configuration.getProtocolOptions() != null)
                && (configuration.getProtocolOptions().getProtocolVersionEnum() != null)) {
            ProtocolVersion pv = configuration.getProtocolOptions().getProtocolVersionEnum();
            this.currentCqlVersion = pv.name();

            // recompute the CQL major version from the actual...
            this.majorCqlVersion = pv.toInt();

        }

    } catch (Exception e) {
        String msg = String.format("Connection Fails to %s: %s", currentHost, e.toString());
        logger.error(msg, e);
        throw new SQLException(msg, e);
    }

}

From source file:de.innovationgate.webgate.api.jdbc.pool.DBCPReplicationConnectionProvider.java

public void configure(Map propsMap) throws HibernateException {
    try {//ww w .  j a va 2s .  co m
        log.info("Configure DBCPReplicationConnectionProvider");
        Properties props = new Properties();
        props.putAll(propsMap);

        String jdbcUrl = props.getProperty(Environment.URL);

        // split jdbcURL by "|" and configure masterDS for first and slaveDataSources for all other URLs
        _jdbcUrls = jdbcUrl.split("\\|");

        // spec. configuration for dbcp
        if (!props.containsKey("hibernate.connection.connectTimeout")) {
            props.setProperty("hibernate.dbcp.poolPreparedStatements", "true");
        }
        if (!props.containsKey("hibernate.connection.connectTimeout")) {
            props.setProperty("hibernate.connection.connectTimeout", "5000");
        }
        if (!props.containsKey("hibernate.connection.socketTimeout")) {
            props.setProperty("hibernate.connection.socketTimeout", "20000");
        }
        if (!props.containsKey("hibernate.dbcp.testOnBorrow")) {
            props.setProperty("hibernate.dbcp.testOnBorrow", "true");
        }
        if (!props.containsKey("hibernate.dbcp.validationQuery")) {
            props.setProperty("hibernate.dbcp.validationQuery", "select 1");
        }

        // create master DS
        log.info("configuring master datasource on url: " + _jdbcUrls[0]);
        Properties masterProps = (Properties) props.clone();
        masterProps.setProperty(Environment.URL, _jdbcUrls[0]);
        DBCPConnectionProvider masterProvider = new DBCPConnectionProvider();
        masterProvider.configure(masterProps);
        _masterDS = masterProvider.getDs();

        // create slave datasources
        for (int i = 1; i < _jdbcUrls.length; i++) {
            log.info("configuring slave datasource on url: " + _jdbcUrls[i]);

            Properties slaveProps = (Properties) props.clone();
            slaveProps.setProperty(Environment.URL, _jdbcUrls[i]);
            DBCPConnectionProvider slaveProvider = new DBCPConnectionProvider();
            slaveProvider.configure(slaveProps);
            _slaveDSList.add(slaveProvider.getDs());
        }
        log.info("Configure DBCPReplicationConnectionProvider complete");
    } catch (Exception e) {
        log.fatal("Could not create DBCPReplicationConnectionProvider.", e);
        throw new HibernateException("Could not create DBCPReplicationConnectionProvider.", e);
    }
}