Example usage for java.util Properties putAll

List of usage examples for java.util Properties putAll

Introduction

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

Prototype

@Override
    public synchronized void putAll(Map<?, ?> t) 

Source Link

Usage

From source file:org.ngrinder.infra.config.Config.java

/**
 * Load system related properties. (system.conf)
 *///from w ww  . j a v a2s . c o m
public synchronized void loadProperties() {
    Properties properties = checkNotNull(home).getProperties("system.conf");
    properties.put("NGRINDER_HOME", home.getDirectory().getAbsolutePath());
    if (exHome.exists()) {
        Properties exProperties = exHome.getProperties("system-ex.conf");
        if (exProperties.isEmpty()) {
            exProperties = exHome.getProperties("system.conf");
        }
        properties.putAll(exProperties);
    }
    properties.putAll(System.getProperties());
    // Override if exists
    controllerProperties = new PropertiesWrapper(properties, controllerPropertiesKeyMapper);
    clusterProperties = new PropertiesWrapper(properties, clusterPropertiesKeyMapper);
}

From source file:org.codehaus.mojo.dbupgrade.sqlexec.DefaultSQLExec.java

/**
 * Creates a new Connection as using the driver, url, userid and password specified.
 *
 * The calling method is responsible for closing the connection.
 *
 * @return Connection the newly created connection.
 * @throws SQLException if the UserId/Password/Url is not set or there is no suitable driver
 *             or the driver fails to load.
 * @throws SQLException if there is problem getting connection with valid url
 *
 *//*from  w  w  w  .  j  a v  a  2  s  .c om*/
public Connection getConnection() throws SQLException {
    if (conn != null) {
        return conn;
    }

    Properties driverProperties = new Properties();

    driverProperties.put("user", config.getUsername());

    handleWindowsDomainUser(driverProperties);

    if (!config.isEnableAnonymousPassword()) {
        if (!StringUtils.isBlank(this.config.getPassword())) {
            driverProperties.put("password", this.config.getPassword());
        }
    }

    driverProperties.putAll(this.getDriverProperties());

    Driver driverInstance = this.createJDBCDriver();

    conn = this.createConnection(driverInstance, driverProperties);

    conn.setAutoCommit(config.isAutocommit());

    return conn;
}

From source file:com.maestrodev.maestrocontinuumplugin.ContinuumWorker.java

public void release() {
    try {//from  w w w. j  a  v  a 2 s. co m
        client = getClient();
        JSONObject context = getContext();
        ProjectSummary project = getProjectSummary(context);

        String prepareGoals = getPrepareGoals();
        String performGoals = getPerformGoals();
        String arguments = getArguments();
        String tag = getScmTag();
        boolean useReleaseProfile = isUseReleaseProfile();

        Map<String, Object> properties = client.getReleasePluginParameters(project.getId());

        if (StringUtils.isNotBlank(arguments)) {
            properties.put("arguments", arguments);
        }
        if (StringUtils.isNotBlank(prepareGoals)) {
            properties.put("preparation-goals", prepareGoals);
        }
        if (StringUtils.isNotBlank(tag)) {
            properties.put("scm-tag", tag);
        }
        properties.put("use-release-profile", useReleaseProfile);

        Map<String, String> releaseVersions = new HashMap<String, String>();
        Map<String, String> developmentVersions = new HashMap<String, String>();

        // Note currently difficult to specify version to use, even with autoversionsubmodules, without the full
        // list of projects which might be released. Better in that case to just call maven release:prepare

        Properties releaseProperties = new Properties();
        releaseProperties.putAll(properties);

        writeOutput("Preparing the release\n");
        String releaseId = client.releasePrepare(project.getId(), releaseProperties, releaseVersions,
                developmentVersions, getBuildEnvironments(project.getId()), getRunUsername());

        while (releaseInProgress(project.getId(), releaseId)) {
            Thread.sleep(5000);
        }

        int releaseResultId = client.releaseCleanup(project.getId(), releaseId, "prepare");
        // TODO: seems to be a bug where Continuum doesn't populate this
        if (releaseResultId != 0) {
            writeOutput(client.getReleaseOutput(releaseResultId));
        }

        writeOutput("Performing the release\n");
        client.releasePerform(project.getId(), releaseId, performGoals, arguments, useReleaseProfile, "DEFAULT",
                getRunUsername());

        while (releaseInProgress(project.getId(), releaseId)) {
            Thread.sleep(5000);
        }

        releaseResultId = client.releaseCleanup(project.getId(), releaseId, "perform");
        // TODO: seems to be a bug where Continuum doesn't populate this
        if (releaseResultId != 0) {
            writeOutput(client.getReleaseOutput(releaseResultId));
        }

        context.put(CONTINUUM_RELEASE_ID, releaseId);
        context.put(SCM_TAG, tag);

        setField(CONTEXT_OUTPUTS, context);

        writeOutput("Completed release\n");

    } catch (Exception e) {
        logger.log(Level.WARNING, e.getLocalizedMessage(), e);
        setError("Continuum Release Failed: " + e.getMessage());
    }
}

From source file:org.apache.openaz.xacml.std.pap.StdPDPGroup.java

@Override
public Properties getPipConfigProperties() {
    Properties properties = new Properties();
    List<String> configs = new ArrayList<String>();

    for (PDPPIPConfig config : this.pipConfigs) {
        configs.add(config.getId());//from w w  w .  java2 s.c  o  m
        properties.putAll(config.getConfiguration());
    }

    properties.setProperty(XACMLProperties.PROP_PIP_ENGINES, Joiner.on(',').join(configs));

    return properties;
}

From source file:org.atricore.idbus.capabilities.sso.main.common.producers.SSOProducer.java

protected void recordInfoAuditTrail(String action, ActionOutcome actionOutcome, String principal,
        CamelMediationExchange exchange, Properties otherProps) {

    AbstractSSOMediator mediator = (AbstractSSOMediator) channel.getIdentityMediator();
    AuditingServer aServer = mediator.getAuditingServer();

    Properties props = null;

    String remoteAddr = (String) exchange.getIn().getHeader("org.atricore.idbus.http.RemoteAddress");
    if (remoteAddr != null) {
        if (props == null)
            props = new Properties();
        props.setProperty("remoteAddress", remoteAddr);
    }/*from   www . jav a2  s.  c  o  m*/

    String session = (String) exchange.getIn().getHeader("org.atricore.idbus.http.Cookie.JSESSIONID");
    if (session != null) {
        if (props == null)
            props = new Properties();
        props.setProperty("httpSession", session);
    }

    if (otherProps != null) {
        if (props == null)
            props = new Properties();
        props.putAll(otherProps);
    }

    aServer.processAuditTrail(mediator.getAuditCategory(), "INFO", action, actionOutcome,
            principal != null ? principal : "UNKNOWN", new java.util.Date(), null, props);
}

From source file:org.apache.sqoop.manager.OracleManager.java

/**
 * Create a connection to the database; usually used only from within
 * getConnection(), which enforces a singleton guarantee around the
 * Connection object./*  ww  w . j  a v a 2s  . com*/
 *
 * Oracle-specific driver uses READ_COMMITTED which is the weakest
 * semantics Oracle supports.
 */
protected Connection makeConnection() throws SQLException {

    Connection connection;
    String driverClass = getDriverClass();

    try {
        Class.forName(driverClass);
    } catch (ClassNotFoundException cnfe) {
        throw new RuntimeException("Could not load db driver class: " + driverClass);
    }

    String username = options.getUsername();
    String password = options.getPassword();
    String connectStr = options.getConnectString();

    connection = CACHE.getConnection(connectStr, username);
    if (null == connection) {
        // Couldn't pull one from the cache. Get a new one.
        LOG.debug("Creating a new connection for " + connectStr + ", using username: " + username);
        Properties connectionParams = options.getConnectionParams();
        if (connectionParams != null && connectionParams.size() > 0) {
            LOG.debug("User specified connection params. "
                    + "Using properties specific API for making connection.");

            Properties props = new Properties();
            if (username != null) {
                props.put("user", username);
            }

            if (password != null) {
                props.put("password", password);
            }

            props.putAll(connectionParams);
            connection = DriverManager.getConnection(connectStr, props);
        } else {
            LOG.debug("No connection paramenters specified. " + "Using regular API for making connection.");
            if (username == null) {
                connection = DriverManager.getConnection(connectStr);
            } else {
                connection = DriverManager.getConnection(connectStr, username, password);
            }
        }
    }

    // We only use this for metadata queries. Loosest semantics are okay.
    connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);

    // Setting session time zone
    setSessionTimeZone(connection);

    return connection;
}

From source file:org.apache.jackrabbit.core.config.RepositoryConfigurationParser.java

/**
 * Creates a new instance of a configuration parser but with overlayed
 * variables and the same connection factory as this parser.
 *
 * @param variables the variables overlay
 * @return a new configuration parser instance
 */// w  w  w . j a v  a  2 s  .  co m
protected RepositoryConfigurationParser createSubParser(Properties variables) {
    // overlay the properties
    Properties props = new Properties(getVariables());
    props.putAll(variables);
    return new RepositoryConfigurationParser(props, connectionFactory);
}

From source file:edu.gsgp.experiment.config.PropertiesManager.java

private Properties loadProperties(String path) throws Exception {
    path = this.preProcessPath(path);
    File parameterFile = new File(path);
    if (!parameterFile.canRead()) {
        throw new FileNotFoundException("Parameter file can not be read: " + parameterFile.getCanonicalPath());
    }/*from ww  w  .  jav a  2s.co m*/
    FileInputStream fileInput = new FileInputStream(parameterFile);
    Properties property = new Properties();
    property.load(fileInput);
    if (property.containsKey(ParameterList.PARENT_FILE.name)) {
        Properties propertyParent = loadProperties(property.getProperty("parent").trim());
        propertyParent.putAll(property);
        property = propertyParent;
    }
    return property;
}

From source file:org.apache.nifi.cdc.mysql.processors.CaptureChangeMySQL.java

/**
 * using Thread.currentThread().getContextClassLoader(); will ensure that you are using the ClassLoader for you NAR.
 *
 * @throws InitializationException if there is a problem obtaining the ClassLoader
 *//*from w  w  w  .j a v a2 s  .  co  m*/
protected Connection getJdbcConnection(String locationString, String drvName, InetSocketAddress host,
        String username, String password, Map<String, String> customProperties)
        throws InitializationException, SQLException {
    Properties connectionProps = new Properties();
    if (customProperties != null) {
        connectionProps.putAll(customProperties);
    }
    connectionProps.put("user", username);
    connectionProps.put("password", password);

    return DriverManager.getConnection("jdbc:mysql://" + host.getHostString() + ":" + host.getPort(),
            connectionProps);
}