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.apache.kylin.common.persistence.JDBCConnectionManager.java

public Properties getDbcpProperties() {
    Properties ret = new Properties();
    ret.putAll(dbcpProps);
    return ret;
}

From source file:com.spotify.ffwd.kafka.KafkaOutputPlugin.java

@Override
public Module module(final Key<PluginSink> key) {
    return new PrivateModule() {
        @Provides/*from  ww w  .  jav a  2s . c o  m*/
        public Producer<byte[], byte[]> producer() {
            final Properties props = new Properties();
            props.putAll(properties);
            final ProducerConfig config = new ProducerConfig(props);
            return new Producer<byte[], byte[]>(config);
        }

        @Override
        protected void configure() {
            bind(KafkaRouter.class).toInstance(router);
            bind(KafkaPartitioner.class).toInstance(partitioner);

            if (serializer == null) {
                // bind to default implementation, provided by core.
                bind(Serializer.class).to(Key.get(Serializer.class, Names.named("default")));
            } else {
                bind(Serializer.class).toInstance(serializer);
            }

            if (flushInterval != null) {
                bind(BatchedPluginSink.class).to(KafkaPluginSink.class);
                bind(key).toInstance(new FlushingPluginSink(flushInterval));
            } else {
                bind(key).to(KafkaPluginSink.class);
            }

            expose(key);
        }
    };
}

From source file:org.owasp.webgoat.i18n.LabelProvider.java

/**
 * <p>getLabels.</p>/*from  w  w  w  .j a  v  a 2s.co  m*/
 * Returns a merged map of all the labels for a specified language or the
 * default language, if the given language is not supported
 *
 * @param locale The Locale to get all the labels for
 * @return A Map of all properties with their values
 */
public Map<String, String> getLabels(Locale locale) {
    Properties messages = labels.getMessages(locale);
    messages.putAll(pluginLabels.getMessages(useLocaleOrFallbackToEnglish(locale)));
    Map<String, String> labelsMap = new HashMap<>();
    for (Map.Entry<Object, Object> entry : messages.entrySet()) {
        if (entry.getKey() != null && entry.getValue() != null) {
            labelsMap.put(entry.getKey().toString(), entry.getValue().toString());
        }
    }
    return labelsMap;
}

From source file:org.apache.flink.table.catalog.hive.util.HiveTableUtil.java

/**
 * Create properties info to initialize a SerDe.
 * @param storageDescriptor/*ww w  .j  ava2 s. c  o  m*/
 * @return
 */
public static Properties createPropertiesFromStorageDescriptor(StorageDescriptor storageDescriptor) {
    SerDeInfo serDeInfo = storageDescriptor.getSerdeInfo();
    Map<String, String> parameters = serDeInfo.getParameters();
    Properties properties = new Properties();
    properties.setProperty(serdeConstants.SERIALIZATION_FORMAT,
            parameters.get(serdeConstants.SERIALIZATION_FORMAT));
    List<String> colTypes = new ArrayList<>();
    List<String> colNames = new ArrayList<>();
    List<FieldSchema> cols = storageDescriptor.getCols();
    for (FieldSchema col : cols) {
        colTypes.add(col.getType());
        colNames.add(col.getName());
    }
    properties.setProperty(serdeConstants.LIST_COLUMNS,
            StringUtils.join(colNames, String.valueOf(SerDeUtils.COMMA)));
    // Note: serdeConstants.COLUMN_NAME_DELIMITER is not defined in previous Hive. We use a literal to save on shim
    properties.setProperty("column.name.delimite", String.valueOf(SerDeUtils.COMMA));
    properties.setProperty(serdeConstants.LIST_COLUMN_TYPES,
            StringUtils.join(colTypes, DEFAULT_LIST_COLUMN_TYPES_SEPARATOR));
    properties.setProperty(serdeConstants.SERIALIZATION_NULL_FORMAT, "NULL");
    properties.putAll(parameters);
    return properties;
}

From source file:com.splicemachine.derby.utils.SpliceAdmin.java

/**
 * Get the values of all properties for the current connection.
 *
 * @param rs array of result set objects that contains all of the defined properties
 *           for the JVM, service, database, and app.
 * @throws SQLException Standard exception policy.
 **///from ww w .j ava 2  s .  c om
public static void SYSCS_GET_ALL_PROPERTIES(ResultSet[] rs) throws SQLException {
    try {
        LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
        TransactionController tc = lcc.getTransactionExecute();

        // Fetch all the properties.
        Properties jvmProps = addTypeToProperties(System.getProperties(), "JVM", true);
        Properties dbProps = addTypeToProperties(tc.getProperties()); // Includes both database and service properties.
        ModuleFactory monitor = Monitor.getMonitorLite();
        Properties appProps = addTypeToProperties(monitor.getApplicationProperties(), "APP", false);

        // Merge the properties using the correct search order.
        // SEARCH ORDER: JVM, Service, Database, App
        appProps.putAll(dbProps); // dbProps already has been overwritten with service properties.
        appProps.putAll(jvmProps);
        ArrayList<ExecRow> rows = new ArrayList<>(appProps.size());

        // Describe the format of the input rows (ExecRow).
        //
        // Columns of "virtual" row:
        //   KEY         VARCHAR
        //   VALUE         VARCHAR
        //   TYPE         VARCHAR (JVM, SERVICE, DATABASE, APP)
        DataValueDescriptor[] dvds = new DataValueDescriptor[] { new SQLVarchar(), new SQLVarchar(),
                new SQLVarchar() };
        int numCols = dvds.length;
        ExecRow dataTemplate = new ValueRow(numCols);
        dataTemplate.setRowArray(dvds);

        // Transform the properties into rows.  Sort the properties by key first.
        ArrayList<String> keyList = new ArrayList<>();
        for (Object o : appProps.keySet()) {
            if (o instanceof String)
                keyList.add((String) o);
        }
        Collections.sort(keyList);
        for (String key : keyList) {
            String[] typedValue = (String[]) appProps.get(key);
            dvds[0].setValue(key);
            dvds[1].setValue(typedValue[0]);
            dvds[2].setValue(typedValue[1]);
            rows.add(dataTemplate.getClone());
        }

        // Describe the format of the output rows (ResultSet).
        ResultColumnDescriptor[] columnInfo = new ResultColumnDescriptor[numCols];
        columnInfo[0] = new GenericColumnDescriptor("KEY",
                DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, 50));
        columnInfo[1] = new GenericColumnDescriptor("VALUE",
                DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, 40));
        columnInfo[2] = new GenericColumnDescriptor("TYPE",
                DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, 10));
        EmbedConnection defaultConn = (EmbedConnection) getDefaultConn();
        Activation lastActivation = defaultConn.getLanguageConnection().getLastActivation();
        IteratorNoPutResultSet resultsToWrap = new IteratorNoPutResultSet(rows, columnInfo, lastActivation);
        resultsToWrap.openCore();
        EmbedResultSet ers = new EmbedResultSet40(defaultConn, resultsToWrap, false, null, true);
        rs[0] = ers;
    } catch (StandardException se) {
        throw PublicAPI.wrapStandardException(se);
    }
}

From source file:ws.salient.aws.dynamodb.DynamoDBProfiles.java

@Override
public Properties getProperties(String accountId, List<String> profiles) {
    Settings settings = getSettings(accountId);
    Properties properties = new Properties();
    properties.putAll(getSettings(ROOT_ACCOUNT_ID).getProperties(profiles));
    properties.putAll(settings.getProperties(profiles));
    return properties;
}

From source file:net.jcreate.e3.templateEngine.webmacro.WebMacroTemplateEngine.java

/**
 * /*from   w w w  .  j  ava2s  .c om*/
 */
protected void mergeFileTemplate(Template pTemplate, Context pContext, Writer pWriter)
        throws MergeTemplateException {

    Properties props = WebMacroHelper.getDefaultProperties();
    props.putAll(this.properties);

    props.setProperty("TemplateEncoding", pTemplate.getInputEncoding());
    String path = pTemplate.getResource();
    if (log.isDebugEnabled()) {
        log.debug("?: \"" + path + "\" WebMacro?.");
        log.debug("?: \"" + path + "\" ??" + pTemplate.getInputEncoding());
    }

    /**
     * @FIXME
     * WebMacro????????Engine,??
     * WebMacro?????.
     */
    WM wm = WebMacroHelper.getWMEngine(props);

    org.webmacro.Context c = new org.webmacro.Context(wm.getBroker());
    Map params = pContext.getParameters();
    for (Iterator i = params.keySet().iterator(); i.hasNext();) {
        String key = (String) i.next();
        Object value = params.get(key);
        c.put(key, value);
    }

    org.webmacro.Template t = null;
    try {
        t = wm.getTemplate(pTemplate.getResource());
    } catch (ResourceException e) {
        final String MSG = "?? \"" + path + "\"  !" + e.getMessage();
        if (log.isErrorEnabled()) {
            log.error(MSG, e);
        }
        throw new MergeTemplateException(MSG, e);
    }

    String result = null;
    try {
        result = t.evaluateAsString(c);
    } catch (PropertyException e) {
        final String MSG = "?? \"" + path + "\"  !" + e.getMessage();
        if (log.isErrorEnabled()) {
            log.error(MSG, e);
        }
        throw new MergeTemplateException(MSG, e);
    }

    try {
        pWriter.write(result);
    } catch (IOException e) {
        final String MSG = "?? \"" + path + "\"  !" + e.getMessage();
        if (log.isErrorEnabled()) {
            log.error(MSG, e);
        }
        throw new MergeTemplateException(MSG, e);
    }
}

From source file:org.apache.whirr.service.yarn.YarnResourceManagerHandler.java

@Override
protected void afterConfigure(ClusterActionEvent event) throws IOException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    Instance resourceManager = cluster.getInstanceMatching(role(ROLE));
    LOG.info("Resource manager web UI available at http://{}:{}", resourceManager.getPublicHostName(),
            RESOURCE_MANAGER_WEB_UI_PORT);

    Properties mrConfig = createClientSideMapReduceProperties(clusterSpec);
    createClientSideMapReduceSiteFile(clusterSpec, mrConfig);

    Properties yarnConfig = createClientSideYarnProperties(clusterSpec, resourceManager);
    createClientSideYarnSiteFile(clusterSpec, yarnConfig);

    Properties combined = new Properties();
    combined.putAll(cluster.getConfiguration());
    combined.putAll(mrConfig);//from   w  w  w. j  a va2  s  . com
    combined.putAll(yarnConfig);
    event.setCluster(new Cluster(cluster.getInstances(), combined));
}

From source file:org.apache.cxf.dosgi.singlebundle.AggregatedActivatorTest.java

@Override
protected void tearDown() throws Exception {
    super.tearDown();
    Properties props = new Properties();
    props.putAll(savedProps);
    System.setProperties(props);// w  ww.ja  va  2 s.com

    AggregatedActivator.DEFAULT_HTTP_PORT = oldDefaultPort;
}

From source file:org.apache.kylin.source.kafka.config.KafkaConsumerProperties.java

public Properties extractKafkaConfigToProperties() {
    Properties prop = new Properties();
    prop.putAll(this.properties);
    return prop;/*from ww w  .  jav a 2s .  c  om*/
}