Java Code Examples for org.apache.commons.configuration.Configuration#getList()
The following examples show how to use
org.apache.commons.configuration.Configuration#getList() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocationResolverBolt.java From cognition with Apache License 2.0 | 6 votes |
@Override public void configure(Configuration conf) throws ConfigurationException { _luceneIndexDir = conf.getString(LUCENE_INDEX_DIR); _localIndexDir = conf.getString(LOCAL_INDEX_DIR); _textFields = conf.getList(TEXT_FIELDS); _pipClavinLocationPrefix = conf.getString(PIP_CLAVIN_LOCATION_PREFIX, "pip.clavinLocation_"); _fieldName = conf.getString(FIELD_NAME, FIELD_NAME); _name = conf.getString(NAME, NAME); _admin1Code = conf.getString(ADMIN1CODE, ADMIN1CODE); _admin2Code = conf.getString(ADMIN2CODE, ADMIN2CODE); _countryCode = conf.getString(COUNTRYCODE, COUNTRYCODE); _latitude = conf.getString(LATITUDE, LATITUDE); _longitude = conf.getString(LONGITUDE, LONGITUDE); _confidence = conf.getString(CONFIDENCE, CONFIDENCE); Configuration hadoopConfigSubset = conf.subset(HADOOP_CONFIG); for (Iterator<String> itr = hadoopConfigSubset.getKeys(); itr.hasNext(); ) { String key = itr.next(); String value = hadoopConfigSubset.getString(key); hadoopConfig.put(key, value); } }
Example 2
Source File: ConfigurationMapEntryUtils.java From cognition with Apache License 2.0 | 6 votes |
/** * Extracts map entries from configuration. * * @param conf * @param mappingEntry * @param fields first field should be unique and exist in all entries, other fields are optional from map * @return */ public static Map<String, Map<String, String>> extractMapList( final Configuration conf, final String mappingEntry, final String... fields) { String keyField = fields[0]; List<Object> keys = conf.getList(mappingEntry + "." + keyField); Map<String, Map<String, String>> maps = new HashMap<>(keys.size()); for (int i = 0; i < keys.size(); i++) { Map<String, String> map = new HashMap<>(); Object key = keys.get(i); map.put(keyField, key.toString()); for (int j = 1; j < fields.length; j++) { String field = fields[j]; String fieldPath = String.format("%s(%s).%s", mappingEntry, i, field); String value = conf.getString(fieldPath); if (value != null) map.put(field, value); } maps.put(key.toString(), map); } return maps; }
Example 3
Source File: ConfigurePropertyUtils.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public static List<BasePath> getMicroservicePaths(Configuration configuration) { List<BasePath> basePaths = new ArrayList<>(); for (Object path : configuration.getList("service_description.paths")) { BasePath basePath = new BasePath(); Map<String, ?> pathMap = (Map<String, ?>) path; basePath.setPath(buildPath((String) pathMap.get("path"))); basePath.setProperty((Map<String, String>) pathMap.get("property")); basePaths.add(basePath); } return basePaths; }
Example 4
Source File: ExtensionAlertFilters.java From zap-extensions with Apache License 2.0 | 5 votes |
@Override public void importContextData(Context ctx, Configuration config) { List<Object> list = config.getList(CONTEXT_CONFIG_ALERT_FILTER); ContextAlertFilterManager m = getContextAlertFilterManager(ctx.getId()); for (Object o : list) { AlertFilter af = AlertFilter.decode(ctx.getId(), o.toString()); m.addAlertFilter(af); } }
Example 5
Source File: ExtensionAccessControl.java From zap-extensions with Apache License 2.0 | 5 votes |
@Override public void importContextData(Context ctx, Configuration config) throws ConfigurationException { List<Object> serializedRules = config.getList(CONTEXT_CONFIG_ACCESS_RULES_RULE); if (serializedRules != null) { ContextAccessRulesManager contextManager = getContextAccessRulesManager(ctx); // Make sure we reload the context tree contextManager.reloadContextSiteTree(Model.getSingleton().getSession()); for (Object serializedRule : serializedRules) { contextManager.importSerializedRule(serializedRule.toString()); } } }
Example 6
Source File: SetDateBoltTest.java From cognition with Apache License 2.0 | 5 votes |
@Test public void testConfigure(@Injectable Configuration conf) { new Expectations() {{ conf.getList(SetDateBolt.DATE_FIELD); result = Arrays.asList("field0"); conf.getString(SetDateBolt.DATE_FORMAT); result = "format0"; }}; bolt.configure(conf); assertThat(bolt.dateFields.get(0), is("field0")); assertThat(bolt.dateFormat, is("format0")); }
Example 7
Source File: DatabaseJobHistoryStoreSchemaManager.java From incubator-gobblin with Apache License 2.0 | 5 votes |
private static Properties getProperties(Configuration config) { Properties props = new Properties(); char delimiter = (config instanceof AbstractConfiguration) ? ((AbstractConfiguration) config).getListDelimiter() : ','; Iterator keys = config.getKeys(); while (keys.hasNext()) { String key = (String) keys.next(); List list = config.getList(key); props.setProperty("flyway." + key, StringUtils.join(list.iterator(), delimiter)); } return props; }
Example 8
Source File: BroMessageFilter.java From opensoc-streaming with Apache License 2.0 | 5 votes |
/** * @param filter Commons configuration for reading properties files * @param key Key in a JSON mesage where the protocol field is located */ @SuppressWarnings({ "unchecked", "rawtypes" }) public BroMessageFilter(Configuration conf, String key) { _key = key; _known_protocols = new HashSet<String>(); List known_protocols = conf.getList("source.known.protocols"); _known_protocols.addAll(known_protocols); }
Example 9
Source File: SegmentFetcherFactory.java From incubator-pinot with Apache License 2.0 | 5 votes |
/** * Initializes the segment fetcher factory. This method should only be called once. */ public static void init(Configuration config) throws Exception { @SuppressWarnings("unchecked") List<String> protocols = config.getList(PROTOCOLS_KEY); for (String protocol : protocols) { String segmentFetcherClassName = config.getString(protocol + SEGMENT_FETCHER_CLASS_KEY_SUFFIX); SegmentFetcher segmentFetcher; if (segmentFetcherClassName == null) { LOGGER.info("Segment fetcher class is not configured for protocol: {}, using default", protocol); switch (protocol) { case HTTP_PROTOCOL: segmentFetcher = new HttpSegmentFetcher(); break; case HTTPS_PROTOCOL: segmentFetcher = new HttpsSegmentFetcher(); break; default: segmentFetcher = new PinotFSSegmentFetcher(); } } else { LOGGER.info("Creating segment fetcher for protocol: {} with class: {}", protocol, segmentFetcherClassName); segmentFetcher = (SegmentFetcher) Class.forName(segmentFetcherClassName).newInstance(); } segmentFetcher.init(config.subset(protocol)); SEGMENT_FETCHER_MAP.put(protocol, segmentFetcher); } }
Example 10
Source File: StarTreeV2Metadata.java From incubator-pinot with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public StarTreeV2Metadata(Configuration metadataProperties) { _numDocs = metadataProperties.getInt(TOTAL_DOCS); _dimensionsSplitOrder = metadataProperties.getList(DIMENSIONS_SPLIT_ORDER); _functionColumnPairs = new HashSet<>(); for (Object functionColumnPair : metadataProperties.getList(FUNCTION_COLUMN_PAIRS)) { _functionColumnPairs.add(AggregationFunctionColumnPair.fromColumnName((String) functionColumnPair)); } _maxLeafRecords = metadataProperties.getInt(MAX_LEAF_RECORDS); _skipStarNodeCreationForDimensions = new HashSet<>(metadataProperties.getList(SKIP_STAR_NODE_CREATION_FOR_DIMENSIONS)); }
Example 11
Source File: FreeFlowAnalysis.java From AisAbnormal with GNU Lesser General Public License v3.0 | 5 votes |
@Inject public FreeFlowAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository) { super(eventRepository, trackingService, null); this.statisticsService = statisticsService; this.xL = configuration.getInt(CONFKEY_ANALYSIS_FREEFLOW_XL, 8); this.xB = configuration.getInt(CONFKEY_ANALYSIS_FREEFLOW_XB, 8); this.dCog = configuration.getFloat(CONFKEY_ANALYSIS_FREEFLOW_DCOG, 15f); this.minReportingIntervalMillis = configuration.getInt(CONFKEY_ANALYSIS_FREEFLOW_MIN_REPORTING_PERIOD_MINUTES, 60) * 60 * 1000; String csvFileNameTmp = configuration.getString(CONFKEY_ANALYSIS_FREEFLOW_CSVFILE, null); if (csvFileNameTmp == null || isBlank(csvFileNameTmp)) { this.csvFileName = null; LOG.warn("Writing of free flow events to CSV file is disabled"); } else { this.csvFileName = csvFileNameTmp.trim(); LOG.info("Free flow events are appended to CSV file: " + this.csvFileName); } List<Object> bboxConfig = configuration.getList(CONFKEY_ANALYSIS_FREEFLOW_BBOX); if (bboxConfig != null) { final double n = Double.valueOf(bboxConfig.get(0).toString()); final double e = Double.valueOf(bboxConfig.get(1).toString()); final double s = Double.valueOf(bboxConfig.get(2).toString()); final double w = Double.valueOf(bboxConfig.get(3).toString()); this.areaToBeAnalysed = BoundingBox.create(Position.create(n, e), Position.create(s, w), CoordinateSystem.CARTESIAN); } setTrackPredictionTimeMax(configuration.getInteger(CONFKEY_ANALYSIS_FREEFLOW_PREDICTIONTIME_MAX, -1)); setAnalysisPeriodMillis(configuration.getInt(CONFKEY_ANALYSIS_FREEFLOW_RUN_PERIOD, 30000) * 1000); LOG.info(this.getClass().getSimpleName() + " created (" + this + ")."); }
Example 12
Source File: ConfigurationMapEntryUtils.java From cognition with Apache License 2.0 | 3 votes |
/** * Extracts Map<String, String> from XML of the format: * <pre> * {@code <mapName> * <entry> * <key>k0</key> * <value>v0</value> * </entry> * <entry> * <key>k1</key> * <value>v1</value> * </entry> * </mapName> * } * </pre> * * @param conf * @param mapName * @param entry * @param key * @param value * @return */ public static Map<String, String> extractSimpleMap(final Configuration conf, final String mapName, final String entry, final String key, final String value) { List<Object> fieldsList = conf.getList(mapName + "." + entry + "." + key); LinkedHashMap<String, String> map = new LinkedHashMap<String, String>(); for (int i = 0; i < fieldsList.size(); i++) { String relevanceField = conf.getString(mapName + "." + entry + "(" + i + ")." + value); map.put(fieldsList.get(i).toString(), relevanceField); } return map; }