List of usage examples for java.util Properties setProperty
public synchronized Object setProperty(String key, String value)
From source file:com.jdom.util.PropertiesUtilTest.java
@Test public void testWritesOutPropertiesToSpecifiedLocation() throws IOException { Properties properties = new Properties(); properties.setProperty("key", "value"); File testOutputFile = new File(GamePackListModelTest.setupTestClassDir(getClass()), "output.properties"); PropertiesUtil.writePropertiesFile(properties, testOutputFile); String output = FileUtils.readFileToString(testOutputFile); assertTrue("Did not find the property set in the output file!", output.contains("key=value")); }
From source file:com.ibm.stocator.fs.common.Utils.java
/** * Read key from core-site.xml and parse it to Swift configuration * * @param conf source configuration/*from w w w . j av a2 s.c o m*/ * @param prefix configuration key prefix * @param altPrefix alternative prefix list. The last on the list wins * @param key key in the configuration file * @param props destination property set * @param propsKey key in the property set * @param required if the key is mandatory * @throws ConfigurationParseException if there was no match for the key */ public static void updateProperty(Configuration conf, String prefix, String[] altPrefix, String key, Properties props, String propsKey, boolean required) throws ConfigurationParseException { String val = conf.get(prefix + key); if (val == null) { // try alternative key for (String alternativePrefix : altPrefix) { val = conf.get(alternativePrefix + key); LOG.trace("Trying alternative key {}{}", alternativePrefix, key); } } if (required && val == null) { throw new ConfigurationParseException("Missing mandatory configuration: " + key); } if (val != null) { props.setProperty(propsKey, val.trim()); } }
From source file:com.nineteendrops.tracdrops.client.core.properties.TracPropertiesLoaderClassImpl.java
public TracProperties load() { TracProperties tracConfigProperties = new TracProperties(); Properties properties = new Properties(); properties.setProperty(TracProperties.ATTACHMENT_UPLOAD_MAX_SIZE, "256 * 1024"); properties.setProperty(TracProperties.ATTACHMENT_DOWNLOAD_PATH_BASE, System.getProperty("user.home")); properties.setProperty(TracProperties.TRAC_INVOCATION_METHOD_FAILURE_PATTERN, "cannot marshal <class 'xmlrpclib.Fault'> objects"); tracConfigProperties.populate(properties); return tracConfigProperties; }
From source file:com.remin.jblog.conf.MyBatisMapperScannerConfig.java
@Bean public MapperScannerConfigurer mapperScannerConfigurer() { MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer(); mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory"); mapperScannerConfigurer.setBasePackage("com.remin.jblog.mapper"); Properties properties = new Properties(); properties.setProperty("mappers", "com.remin.jblog.conf.MyMapper"); properties.setProperty("notEmpty", "false"); properties.setProperty("IDENTITY", "MYSQL"); mapperScannerConfigurer.setProperties(properties); return mapperScannerConfigurer; }
From source file:fr.pilato.spring.elasticsearch.annotation.AppConfig.java
@Bean public Client esClient() throws Exception { ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean(); factory.setNode(esNode());/*from w w w . j a v a2 s .c o m*/ Properties properties = new Properties(); properties.setProperty("cluster.name", "junit.cluster"); factory.setProperties(properties); factory.afterPropertiesSet(); return factory.getObject(); }
From source file:com.krawler.portal.util.SystemEnv.java
public static Properties getProperties() { Properties props = new Properties(); try {// w w w. jav a2s. c om Runtime runtime = Runtime.getRuntime(); Process process = null; String osName = System.getProperty("os.name").toLowerCase(); if (osName.indexOf("windows ") > -1) { if (osName.indexOf("windows 9") > -1) { process = runtime.exec("command.com /c set"); } else { process = runtime.exec("cmd.exe /c set"); } } else { process = runtime.exec("env"); } BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; while ((line = br.readLine()) != null) { int pos = line.indexOf(StringPool.EQUAL); if (pos != -1) { String key = line.substring(0, pos); String value = line.substring(pos + 1); props.setProperty(key, value); } } } catch (IOException ioe) { logger.warn(ioe.getMessage(), ioe); } return props; }
From source file:io.confluent.kafkarest.v2.AvroKafkaConsumerState.java
public AvroKafkaConsumerState(KafkaRestConfig config, ConsumerInstanceId instanceId, Consumer consumer) { super(config, instanceId, consumer); Properties props = new Properties(); props.setProperty("schema.registry.url", config.getString(KafkaRestConfig.SCHEMA_REGISTRY_URL_CONFIG)); }
From source file:com.commercehub.dropwizard.jclouds.blobstore.GridFSManagedBlobStoreContextFactory.java
@Override public ManagedBlobStoreContext build() { Properties overrides = new Properties(); overrides.setProperty(Constants.PROPERTY_ENDPOINT, uri.toString()); Iterable<Module> modules = ImmutableSet.<Module>of(new SLF4JLoggingModule()); BlobStoreContext context = ContextBuilder.newBuilder("gridfs").modules(modules).overrides(overrides) .buildView(BlobStoreContext.class); return ManagedBlobStoreContext.of(context); }
From source file:com.metamx.emitter.core.LoggingEmitterConfigTest.java
@Test public void testSettingEverything() { final Properties props = new Properties(); props.setProperty("com.metamx.emitter.logging.class", "Foo"); props.setProperty("com.metamx.emitter.logging.level", "INFO"); final ObjectMapper objectMapper = new ObjectMapper(); final LoggingEmitterConfig config = objectMapper.convertValue(Emitters.makeLoggingMap(props), LoggingEmitterConfig.class); Assert.assertEquals("Foo", config.getLoggerClass()); Assert.assertEquals("INFO", config.getLogLevel()); }
From source file:no.dusken.aranea.spring.AraneaContextLoaderListener.java
public void addDeveloperModeReplacer(ConfigurableWebApplicationContext wac) { PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); final Properties properties = new Properties(); properties.setProperty("developerMode", Boolean.toString(System.getProperty("developerMode") != null)); configurer.setProperties(properties); configurer.setIgnoreUnresolvablePlaceholders(true); wac.addBeanFactoryPostProcessor(configurer); }