List of usage examples for java.util Properties getProperty
public String getProperty(String key)
From source file:consumer.kafka.ProcessedOffsetManager.java
public static String processedPath(int partition, Properties props) { String consumerZkPath = "/consumers"; if (props.getProperty("zookeeper.consumer.path") != null) { consumerZkPath = props.getProperty("zookeeper.consumer.path"); }/* w w w . j av a 2 s.c o m*/ return consumerZkPath + "/" + props.getProperty(Config.KAFKA_CONSUMER_ID) + "/processed/" + props.getProperty(Config.KAFKA_TOPIC) + "/" + partition; }
From source file:com.ms.commons.test.tool.exportdata.DatabasePropertiesLoader.java
public static List<DatabaseConfigItem> getDatabaseConfigItems() { File fn = new File(System.getProperty("user.home") + ".frameworktest_db_config.properties"); if (!fn.exists()) { throwNoConfigException(fn);//from ww w . java2s . co m } Properties properties = loadProperties(fn); List<String> dbConfs = StrUtil.splitStringToList(properties.getProperty("intltest.conns"), ','); if (dbConfs.isEmpty()) { throwNoConfigException(fn); } List<DatabaseConfigItem> itemList = new ArrayList<DatabaseConfigItem>(); for (String dbConfName : dbConfs) { itemList.add(getDatabaseConfigItem(properties, dbConfName)); } return itemList; }
From source file:de.alpharogroup.message.system.ApplicationJettyRunner.java
/** * Checks if a postgresql database exists. * * @return true, if successful/* w w w .j a v a 2s. c o m*/ * @throws IOException * Signals that an I/O exception has occurred. * @throws ClassNotFoundException * the class not found exception * @throws SQLException * the SQL exception */ protected static boolean existsPostgreSQLDatabase() throws IOException, ClassNotFoundException, SQLException { final Properties databaseProperties = PropertiesExtensions.loadProperties("jdbc.properties"); final String hostname = databaseProperties.getProperty("jdbc.host"); final String databaseName = databaseProperties.getProperty("jdbc.db.name"); final String databaseUser = databaseProperties.getProperty("jdbc.user"); final String databasePassword = databaseProperties.getProperty("jdbc.password"); final boolean dbExists = ConnectionsExtensions.existsPostgreSQLDatabase(hostname, databaseName, databaseUser, databasePassword); return dbExists; }
From source file:de.alpharogroup.message.system.ApplicationJettyRunner.java
/** * Gets the project name.//w w w.jav a 2 s . c om * * @return the project name * @throws IOException * Signals that an I/O exception has occurred. */ protected static String getProjectName() throws IOException { final Properties projectProperties = PropertiesExtensions.loadProperties("project.properties"); final String projectName = projectProperties.getProperty("artifactId"); return projectName; }
From source file:com.mgmtp.perfload.perfalyzer.util.TestMetadata.java
public static TestMetadata create(final String rawResultsDir, final Properties properties) { ZonedDateTime start = ZonedDateTime.parse(properties.getProperty("test.start"), DateTimeFormatter.ISO_OFFSET_DATE_TIME); ZonedDateTime end = ZonedDateTime.parse(properties.getProperty("test.finish"), DateTimeFormatter.ISO_OFFSET_DATE_TIME); String duration = DurationFormatUtils.formatDurationHMS(Duration.between(start, end).toMillis()); String operationsString = properties.getProperty("operations"); Set<String> operations = newTreeSet(on(',').trimResults().split(operationsString)); return new TestMetadata(start, end, duration, properties.getProperty("test.file"), rawResultsDir, properties.getProperty("perfload.implementation.version"), properties.getProperty("test.comment"), operations);// w ww. j a v a2 s.co m }
From source file:com.sec.ose.osi.UIMain.java
private static double getJavaVersion() { Properties prop = System.getProperties(); String java_specification_version = prop.getProperty("java.specification.version"); StringTokenizer st = new StringTokenizer(java_specification_version, "."); String major = st.nextToken(); String minor = st.nextToken(); try {//w ww . j ava2 s . c o m double version = Double.parseDouble(major + "." + minor); return version; } catch (NumberFormatException e) { log.warn(e); return 0; } }
From source file:com.github.peholmst.springsecuritydemo.VersionInfo.java
private static void readApplicationVersion() { if (logger.isDebugEnabled()) { logger.debug("Attempting to read application version from 'version.properties'"); }//from w w w . ja va2 s . c o m InputStream is = VersionInfo.class.getResourceAsStream("/version.properties"); if (is != null) { Properties props = new Properties(); try { props.load(is); version = props.getProperty("app.version"); if (version != null) { if (logger.isInfoEnabled()) { logger.info("Application version is '" + version + "'"); } return; } } catch (IOException e) { if (logger.isErrorEnabled()) { logger.error("Could not load version properties", e); } } } if (logger.isWarnEnabled()) { logger.warn("Could not retrieve a version number, using 'unversioned'"); } version = "unversioned"; }
From source file:com.sonar.runner.it.ScannerTestCase.java
private static Version artifactVersion() { if (artifactVersion == null) { String scannerVersion = System.getProperty("scanner.version"); if (StringUtils.isNotBlank(scannerVersion)) { LOG.info("Use provided Scanner version: " + scannerVersion); artifactVersion = Version.create(scannerVersion); } else {//from w ww . j a va 2 s . co m try (FileInputStream fis = new FileInputStream( new File("../target/maven-archiver/pom.properties"))) { Properties props = new Properties(); props.load(fis); artifactVersion = Version.create(props.getProperty("version")); return artifactVersion; } catch (IOException e) { throw new IllegalStateException(e); } } } return artifactVersion; }
From source file:Main.java
public static Map<String, String> propertiesToMap(Properties properties) { final Map<String, String> result = new HashMap<String, String>(); for (final Object propKey : properties.keySet()) { result.put(propKey.toString(), properties.getProperty(propKey.toString())); }/*w w w .j a v a2 s . c o m*/ return result; }
From source file:com.vamonossoftware.core.TextUtil.java
/** * Replaces variables in a string with values from a properties object. * So, if the string is/* w w w . j ava 2s . c om*/ * "Hello ${name}." * And the properties contains * "name" -> "Mr Ed" * Then the result will be * "Hello Mr Ed." */ public static String replace(String input, Properties properties) { for (Object key : properties.keySet()) { input = StringUtils.replace(input, START + key + END, properties.getProperty((String) key)); } return input; }