List of usage examples for java.util Properties containsKey
@Override public boolean containsKey(Object key)
From source file:org.gvnix.dynamic.configuration.roo.addon.config.PropertiesDynamicConfiguration.java
/** * {@inheritDoc}/* w w w . ja v a 2 s . c om*/ */ public void write(DynPropertyList dynProps) { OutputStream outputStream = null; try { // Get the properties file path MutableFile file = getFile(); if (file != null) { Properties props = new Properties(); props.load(file.getInputStream()); for (DynProperty dynProp : dynProps) { if (props.containsKey(dynProp.getKey())) { props.put(dynProp.getKey(), dynProp.getValue()); } else { logger.log(Level.WARNING, "Property key ".concat(dynProp.getKey()) .concat(" to put value not exists on file")); } } outputStream = file.getOutputStream(); props.store(outputStream, null); } else if (!dynProps.isEmpty()) { logger.log(Level.WARNING, "File ".concat(getFilePath()) .concat(" not exists and there are dynamic properties to set it")); } } catch (IOException ioe) { throw new IllegalStateException(ioe); } finally { if (outputStream != null) { IOUtils.closeQuietly(outputStream); } } }
From source file:org.apache.sling.launchpad.webapp.integrationtest.jcrinstall.JcrinstallTestBase.java
protected int getActiveBundlesCount() throws IOException { final String key = "bundles.in.state." + Bundle.ACTIVE; final Properties props = getJcrInstallProperties(); int result = 0; if (props.containsKey(key)) { result = Integer.valueOf(props.getProperty(key)); }// w w w. jav a2 s . c o m return result; }
From source file:gobblin.data.management.conversion.hive.query.HiveAvroORCQueryGenerator.java
private static Properties getTableProperties(Properties tableProperties) { if (null == tableProperties || tableProperties.size() == 0) { return DEFAULT_TBL_PROPERTIES; }//from w ww . ja v a 2 s . co m for (String property : DEFAULT_TBL_PROPERTIES.stringPropertyNames()) { if (!tableProperties.containsKey(property)) { tableProperties.put(property, DEFAULT_TBL_PROPERTIES.get(property)); } } return tableProperties; }
From source file:org.apache.zeppelin.interpreter.launcher.SparkInterpreterLauncher.java
private void mergeSparkProperty(Properties sparkProperties, String propertyName, String propertyValue) { if (sparkProperties.containsKey(propertyName)) { String oldPropertyValue = sparkProperties.getProperty(propertyName); sparkProperties.setProperty(propertyName, oldPropertyValue + "," + propertyValue); } else {//from ww w .j ava 2s . c o m sparkProperties.setProperty(propertyName, propertyValue); } }
From source file:gobblin.kafka.schemareg.LiKafkaSchemaRegistry.java
/** * @param props properties should contain property "kafka.schema.registry.url", and optionally * "kafka.schema.registry.max.cache.size" (default = 1000) and * "kafka.schema.registry.cache.expire.after.write.min" (default = 10). *///from w w w. j av a 2 s . c om public LiKafkaSchemaRegistry(Properties props) { Preconditions.checkArgument( props.containsKey(KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_URL), String.format("Property %s not provided.", KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_URL)); this.url = props.getProperty(KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_URL); int objPoolSize = Integer .parseInt(props.getProperty(ConfigurationKeys.KAFKA_SOURCE_WORK_UNITS_CREATION_THREADS, "" + ConfigurationKeys.KAFKA_SOURCE_WORK_UNITS_CREATION_DEFAULT_THREAD_COUNT)); LOG.info("Create HttpClient pool with size " + objPoolSize); GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(objPoolSize); config.setMaxIdle(objPoolSize); this.httpClientPool = new GenericObjectPool<>(new HttpClientFactory(), config); }
From source file:net.big_oh.postoffice.PostOfficeServiceFactoryUnitTest.java
/** * Test method for/*from ww w. j a v a2s . c om*/ * {@link net.big_oh.postoffice.PostOfficeServiceFactory#readDefaultPostOfficeProperties()} * . */ @Test public void testReadDefaultPostOfficeProperties() { final Properties defaultPostOfficeProperties = PostOfficeServiceFactory.readDefaultPostOfficeProperties(); assertNotNull(defaultPostOfficeProperties); assertTrue(defaultPostOfficeProperties.containsKey(PostOfficeServiceFactory.PROPERTY_KEY_HOST)); assertFalse(StringUtils .isBlank(defaultPostOfficeProperties.getProperty(PostOfficeServiceFactory.PROPERTY_KEY_HOST))); }
From source file:com.opengamma.language.context.DefaultGlobalContextEventHandler.java
/** * Merges user specified settings into the "system" settings. Typically, settings * will be provided by the O/S launcher (e.g. from the registry on Windows). A * properties file can be used for a fallback if the properties aren't defined in * the registry. For example to provide defaults. * //from w w w . j a v a 2 s. c o m * @param systemSettings the default settings to use */ public void setSystemSettings(final Properties systemSettings) { ArgumentChecker.notNull(systemSettings, "systemSettings"); final Properties existingSettings = System.getProperties(); final Enumeration<Object> keys = systemSettings.keys(); while (keys.hasMoreElements()) { final Object keyObject = keys.nextElement(); if (existingSettings.containsKey(keyObject)) { s_logger.debug("Ignoring {} in favour of system property", keyObject); } else { if (keyObject instanceof String) { final String key = (String) keyObject; final String value = systemSettings.getProperty(key); existingSettings.setProperty(key, value); s_logger.debug("Using {}={}", key, value); } } } }
From source file:org.apache.solr.client.solrj.io.sql.DriverImpl.java
public Connection connect(String url, Properties props) throws SQLException { if (!acceptsURL(url)) { return null; }/*from www. j ava 2 s .c o m*/ URI uri = processUrl(url); loadParams(uri, props); if (!props.containsKey("collection")) { throw new SQLException( "The connection url has no connection properties. At a mininum the collection must be specified."); } String collection = (String) props.remove("collection"); if (!props.containsKey("aggregationMode")) { props.setProperty("aggregationMode", "facet"); } // JDBC requires metadata like field names from the SQLHandler. Force this property to be true. props.setProperty("includeMetadata", "true"); String zkHost = uri.getAuthority() + uri.getPath(); return new ConnectionImpl(url, zkHost, collection, props); }
From source file:gobblin.data.management.retention.profile.MultiDatasetFinder.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public MultiDatasetFinder(FileSystem fs, Properties jobProps) { this.jobProps = jobProps; try {/*from w w w . j av a2 s. c o m*/ this.datasetFinders = Lists.newArrayList(); if (jobProps.containsKey(datasetFinderClassKey())) { try { log.info(String.format("Instantiating datasetfinder %s ", jobProps.getProperty(datasetFinderClassKey()))); this.datasetFinders.add((DatasetsFinder) ConstructorUtils.invokeConstructor( Class.forName(jobProps.getProperty(datasetFinderClassKey())), fs, jobProps)); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) { log.error(String.format("Retention ignored could not instantiate datasetfinder %s.", jobProps.getProperty(datasetFinderClassKey())), e); Throwables.propagate(e); } } else if (jobProps.containsKey(datasetFinderImportedByKey())) { log.info("Instatiating dataset finders using tag " + jobProps.getProperty(datasetFinderImportedByKey())); ConfigClient client = ConfigClientCache.getClient(VersionStabilityPolicy.STRONG_LOCAL_STABILITY); Collection<URI> importedBys = Lists.newArrayList(); for (String tag : TAGS_SPLITTER.split(jobProps.getProperty(datasetFinderImportedByKey()))) { log.info("Looking for datasets that import tag " + tag); importedBys.addAll(client.getImportedBy(new URI(tag), false)); } for (URI importedBy : importedBys) { Config datasetClassConfig = client.getConfig(importedBy); try { this.datasetFinders.add((DatasetsFinder) GobblinConstructorUtils.invokeFirstConstructor( Class.forName(datasetClassConfig.getString(datasetFinderClassKey())), ImmutableList.of(fs, jobProps, datasetClassConfig), ImmutableList.of(fs, jobProps))); log.info(String.format("Instantiated datasetfinder %s for %s.", datasetClassConfig.getString(datasetFinderClassKey()), importedBy)); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | ClassNotFoundException e) { log.error(String.format("Retention ignored for %s. Could not instantiate datasetfinder %s.", importedBy, datasetClassConfig.getString(datasetFinderClassKey())), e); Throwables.propagate(e); } } } else { log.warn(String.format( "NO DATASET_FINDERS FOUND. Either specify dataset finder class at %s or specify the imported tags at %s", datasetFinderClassKey(), datasetFinderImportedByKey())); } } catch (IllegalArgumentException | VersionDoesNotExistException | ConfigStoreFactoryDoesNotExistsException | ConfigStoreCreationException | URISyntaxException e) { Throwables.propagate(e); } }
From source file:net.sourceforge.pmd.cpd.CsTokenizer.java
public void setProperties(Properties properties) { if (properties.containsKey(IGNORE_USINGS)) { ignoreUsings = Boolean.parseBoolean(properties.getProperty(IGNORE_USINGS, "false")); }//from w w w . j a va 2 s. c om }