List of usage examples for java.util Properties getProperty
public String getProperty(String key)
From source file:cz.muni.fi.nbs.utils.Helpers.java
private static CharSequence getJVMVersion() { String version;/* w w w. ja va 2s. co m*/ Properties p = System.getProperties(); version = p.getProperty("java.vendor") + ": " + p.getProperty("java.version"); return version; }
From source file:com.opengamma.examples.simulated.DBTestUtils.java
private static void dropDatabase(String configResourceLocation) throws IOException { Properties props = loadProperties(configResourceLocation); DbTool dbTool = new DbTool(); dbTool.setCatalog("og-financial"); dbTool.setJdbcUrl(props.getProperty(JDBC_URL_KEY)); dbTool.setUser(props.getProperty(DB_USERNAME_KEY, "")); dbTool.setPassword(props.getProperty(DB_PASSWORD_KEY, "")); dbTool.setDrop(true);/* ww w .j a v a2s.c o m*/ dbTool.execute(); if (StringUtils.isNotEmpty(props.getProperty(JDBC_URL_KEY_USER))) { DbTool dbTool2 = new DbTool(); dbTool2.setCatalog("og-financial"); dbTool2.setJdbcUrl(props.getProperty(JDBC_URL_KEY_USER)); dbTool2.setUser(props.getProperty(DB_USERNAME_KEY, "")); dbTool2.setPassword(props.getProperty(DB_PASSWORD_KEY, "")); dbTool2.setDrop(true); dbTool2.execute(); } }
From source file:org.processbase.ui.core.Constants.java
public static JdbcTemplate getJdbcTemplate(Properties properties) { String driver = properties.getProperty("hibernate.connection.driver_class"); String url = properties.getProperty("hibernate.connection.url"); String username = properties.getProperty("hibernate.connection.username"); String password = properties.getProperty("hibernate.connection.password"); Driver driverInstance = null; try {//from w w w . j av a2s .co m driverInstance = (Driver) Driver.class.forName(driver).newInstance(); SimpleDriverDataSource dataSource = new SimpleDriverDataSource(driverInstance, url, username, password); return new JdbcTemplate(dataSource); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; }
From source file:io.unravelling.ferguson.configuration.FergusonConfiguration.java
/** * Validates the server type that was supplied. * @param configuration Configuration of the server. * @return Boolean indicating if the server configuration is correct or not. *///from www . jav a 2 s.c o m static boolean validateServerType(final Properties configuration) { return (configuration.containsKey(FergusonConfiguration.SERVER_TYPE) && EnumUtils .isValidEnum(ServerType.class, configuration.getProperty(FergusonConfiguration.SERVER_TYPE))); }
From source file:com.metamx.emitter.core.Emitters.java
static Map<String, Object> makeHttpMap(Properties props) { Map<String, Object> httpMap = Maps.newHashMap(); final String urlProperty = "com.metamx.emitter.http.url"; final String baseUrl = props.getProperty(urlProperty); if (baseUrl == null) { throw new IAE("Property[%s] must be set", urlProperty); }//from w ww.j a v a 2 s .c om httpMap.put("recipientBaseUrl", baseUrl); httpMap.put("flushMillis", Long.parseLong(props.getProperty("com.metamx.emitter.flushMillis", "60000"))); httpMap.put("flushCount", Integer.parseInt(props.getProperty("com.metamx.emitter.flushCount", "300"))); if (props.containsKey("com.metamx.emitter.http.basicAuthentication")) { httpMap.put("basicAuthentication", props.getProperty("com.metamx.emitter.http.basicAuthentication")); } if (props.containsKey("com.metamx.emitter.http.batchingStrategy")) { httpMap.put("batchingStrategy", props.getProperty("com.metamx.emitter.http.batchingStrategy").toUpperCase()); } if (props.containsKey("com.metamx.emitter.http.maxBatchSize")) { httpMap.put("maxBatchSize", Integer.parseInt(props.getProperty("com.metamx.emitter.http.maxBatchSize"))); } if (props.containsKey("com.metamx.emitter.http.maxBufferSize")) { httpMap.put("maxBufferSize", Long.parseLong(props.getProperty("com.metamx.emitter.http.maxBufferSize"))); } return httpMap; }
From source file:com.redhat.rcm.maven.plugin.buildmetadata.maven.MavenPropertyHelper.java
private static String getPropertiesProperty(final MavenProject project, final String name) { String value = null;/*from w w w . j av a 2s . c om*/ final Properties properties = project.getProperties(); if (properties != null) { value = properties.getProperty(name); } if (value == null) { value = getPropertiesPropertyFromParent(project, name); } return value; }
From source file:com.roche.iceboar.settings.GlobalSettingsFactory.java
private static String getTargetJavaUrl(String codeBase, Properties properties) { String targetJavaURL;//from www. j ava 2 s . c o m targetJavaURL = properties.getProperty(JNLP_TARGET_JAVA_URL); if (targetJavaURL == null) { throw new IceBoarException( "A property " + JNLP_TARGET_JAVA_URL + " is not defined. Please specify it in JNLP file!", null); } if (!isAbsolutePath(targetJavaURL) && StringUtils.isNotBlank(codeBase)) { targetJavaURL = codeBase + targetJavaURL; } return targetJavaURL; }
From source file:at.gv.egovernment.moa.id.commons.db.MOASessionDBUtils.java
public static void initHibernate(Configuration config, Properties hibernateProperties) { String scm = StringUtils.trimToNull(hibernateProperties.getProperty(SESSION_HANDLING_KEY)); if (scm != null) { automaticSessionHandling = scm.indexOf(AUTOMATIC_SESSION_HANDLING_VALUES[0]) != -1 || scm.indexOf(AUTOMATIC_SESSION_HANDLING_VALUES[1]) != -1; }// w w w . j a v a 2 s. c o m Logger.debug("Evaluating hibernate property \"" + SESSION_HANDLING_KEY + "\"."); if (automaticSessionHandling) { Logger.info("Hibernate is automatically handling session context management."); } else { Logger.info( "Hibernate is NOT automatically handling session context management. Using build-in ThreadLocal session handling."); } try { //Create the SessionFactory Logger.debug("Creating initial MOASession session factory..."); config.configure("hibernate_moasession.cfg.xml"); //serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry(); serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build(); sessionFactory = config.buildSessionFactory(serviceRegistry); Logger.debug("Initial MOASession session factory successfully created."); } catch (Throwable ex) { Logger.error("Initial MOASession session factory creation failed: " + ex.getMessage()); throw new ExceptionInInitializerError(ex); } }
From source file:com.googlecode.wmbutil.cache.LookupDataSourceFactory.java
public static synchronized LookupDataSource getDataSource() throws CacheRefreshException { if (dataSource == null) { try {/* w ww . j a v a2 s. c o m*/ Properties config = new Properties(); config.load(new FileInputStream("lookup-connection.properties")); BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(config.getProperty("lookup.class")); ds.setUrl(config.getProperty("lookup.url")); ds.setUsername(config.getProperty("lookup.username")); ds.setPassword(config.getProperty("lookup.password")); ds.setDefaultReadOnly(false); dataSource = new JdbcLookupDataSource(ds); } catch (FileNotFoundException e) { throw new CacheRefreshException("Could not find lookup-connection.properties file", e); } catch (IOException e) { throw new CacheRefreshException("Found, but could not read from lookup-connection.properties file", e); } catch (RuntimeException e) { throw new CacheRefreshException("Could not create data source", e); } } return dataSource; }
From source file:com.opengamma.examples.simulated.DBTestUtils.java
public static void createTestHsqlDB(String configResourceLocation) throws IOException { Properties props = loadProperties(configResourceLocation); DbTool dbTool = new DbTool(); dbTool.setCatalog("og-financial"); dbTool.setJdbcUrl(props.getProperty(JDBC_URL_KEY)); dbTool.setUser(props.getProperty(DB_USERNAME_KEY, "")); dbTool.setPassword(props.getProperty(DB_PASSWORD_KEY, "")); dbTool.setCreate(true);/*from ww w .j av a 2 s.com*/ dbTool.setDrop(true); dbTool.setCreateTables(true); dbTool.execute(); if (StringUtils.isNotEmpty(props.getProperty(JDBC_URL_KEY_USER))) { DbTool dbTool2 = new DbTool(); dbTool2.setCatalog("og-financial"); dbTool2.setJdbcUrl(props.getProperty(JDBC_URL_KEY_USER)); dbTool2.setUser(props.getProperty(DB_USERNAME_KEY, "")); dbTool2.setPassword(props.getProperty(DB_PASSWORD_KEY, "")); dbTool2.setCreate(true); dbTool2.setDrop(true); dbTool2.setCreateTables(true); dbTool2.execute(); } }