List of usage examples for java.util Properties setProperty
public synchronized Object setProperty(String key, String value)
From source file:com.vangent.hieos.services.xds.bridge.utils.JUnitHelper.java
/** * Method description/*from w w w. ja v a 2 s . co m*/ * * * @return */ public static XConfigActor createXDSBridgeActor() { System.setProperty(XConfig.SYSPROP_HIEOS_XDSBRIDGE_DIR, String.format("%s/src/test/resources/config/xdsbridge", System.getProperty("user.dir"))); Properties props = new Properties(); props.setProperty(XDSBridgeConfig.CONFIG_FILE_PROP, "TESTxdsbridgeconfig.xml"); props.setProperty(XDSBridgeConfig.TEMPLATE_METADATA_PROP, "TESTProvideAndRegisterMetadata.xml"); return new MockXConfigActor(props); }
From source file:de.pawlidi.openaletheia.utils.PropertiesUtils.java
public static void setObjectProperty(Properties properties, final String key, final Object value) { if (value != null) { properties.setProperty(key, value.toString()); }/*from www.j a va 2s .c om*/ }
From source file:at.riemers.velocity2js.velocity.Velocity2Js.java
public static void generateDir(String templateDir, String javascriptDir, List<I18NBundle> bundles) throws Exception { Properties p = new Properties(); p.setProperty("resource.loader", "file"); p.setProperty("file.resource.loader.description", "Velocity File Resource Loader"); p.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader"); p.setProperty("file.resource.loader.path", templateDir); Velocity2Js.init(p);//from w w w . j a va 2 s . com File tDir = new File(templateDir); for (I18NBundle bundle : bundles) { BufferedWriter out = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(javascriptDir + "/vel2js" + bundle.getLocale() + ".js"), "UTF8")); //BufferedWriter out = new BufferedWriter(new FileWriter(new File(javascriptDir + "/vel2js" + bundle.getLocale() + ".js"))); process(tDir, null, out, bundle.getBundle()); out.flush(); out.close(); } }
From source file:de.pawlidi.openaletheia.utils.PropertiesUtils.java
public static void setDateProperty(Properties properties, final String key, final DateTime value) { if (value != null) { properties.setProperty(key, Constants.DATE_FORMAT.print(value)); }//from w w w .ja v a 2 s . co m }
From source file:Main.java
public static boolean setProperty(String filePath, String fileName, String... propertyArray) { if (propertyArray == null || propertyArray.length % 2 != 0) { throw new IllegalArgumentException("make sure 'propertyArray' argument is 'ket/value' pairs"); }/*from w w w .j av a2s .c o m*/ try { Properties p = loadPropertyInstance(filePath, fileName); for (int i = 0; i < propertyArray.length / 2; i++) { p.setProperty(propertyArray[i * 2], propertyArray[i * 2 + 1]); } String comment = "Update '" + propertyArray[0] + "..." + "' value"; return storePropertyInstance(filePath, fileName, p, comment); } catch (Exception e) { e.printStackTrace(); return false; } }
From source file:com.weaverplatform.nifi.CreateIndividualTest.java
@BeforeClass public static void beforeClass() throws IOException { // Define property file for NiFi Properties props = System.getProperties(); props.setProperty("nifi.properties.file.path", Resources.getResource("nifi.properties").getPath()); // Read test properties Properties testProperties = new Properties(); testProperties.load(Resources.getResource("test.properties").openStream()); WEAVER_URL = testProperties.get("weaver.url").toString(); WEAVER_DATASET = testProperties.get("weaver.global.dataset").toString(); // Set Nifi Weaver properties NiFiProperties.getInstance().put(WeaverProperties.URL, WEAVER_URL); NiFiProperties.getInstance().put(WeaverProperties.DATASET, WEAVER_DATASET); }
From source file:com.panet.imeta.core.database.ConnectionPoolUtil.java
private static void createPool(DatabaseMeta databaseMeta, String partitionId, int initialSize, int maximumSize) throws KettleDatabaseException { LogWriter.getInstance().logBasic(databaseMeta.toString(), Messages.getString("Database.CreatingConnectionPool", databaseMeta.getName())); GenericObjectPool gpool = new GenericObjectPool(); gpool.setMaxIdle(-1);/*from w w w . ja v a2 s . c o m*/ gpool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW); gpool.setMaxActive(maximumSize); String clazz = databaseMeta.getDriverClass(); try { Class.forName(clazz).newInstance(); } catch (Exception e) { throw new KettleDatabaseException(Messages.getString( "Database.UnableToLoadConnectionPoolDriver.Exception", databaseMeta.getName(), clazz), e); } String url; String userName; String password; try { url = databaseMeta.environmentSubstitute(databaseMeta.getURL(partitionId)); userName = databaseMeta.environmentSubstitute(databaseMeta.getUsername()); password = databaseMeta.environmentSubstitute(databaseMeta.getPassword()); } catch (RuntimeException e) { url = databaseMeta.getURL(partitionId); userName = databaseMeta.getUsername(); password = databaseMeta.getPassword(); } // Get the list of pool properties Properties originalProperties = databaseMeta.getConnectionPoolingProperties(); //Add user/pass originalProperties.setProperty("user", Const.NVL(userName, "")); originalProperties.setProperty("password", Const.NVL(password, "")); // Now, replace the environment variables in there... Properties properties = new Properties(); Iterator<Object> iterator = originalProperties.keySet().iterator(); while (iterator.hasNext()) { String key = (String) iterator.next(); String value = originalProperties.getProperty(key); properties.put(key, databaseMeta.environmentSubstitute(value)); } // Create factory using these properties. // ConnectionFactory cf = new DriverManagerConnectionFactory(url, properties); new PoolableConnectionFactory(cf, gpool, null, null, false, false); for (int i = 0; i < initialSize; i++) { try { gpool.addObject(); } catch (Exception e) { throw new KettleDatabaseException( Messages.getString("Database.UnableToPreLoadConnectionToConnectionPool.Exception"), e); } } pd.registerPool(databaseMeta.getName(), gpool); LogWriter.getInstance().logBasic(databaseMeta.toString(), Messages.getString("Database.CreatedConnectionPool", databaseMeta.getName())); }
From source file:musite.MusiteInit.java
public static Properties defaultGlobalProps() { Properties props = new Properties(); props.setProperty(GLOBAL_PROP_VERSION, globalPropsVersion); //String thirdParty = MusiteInit.thirdPartyDirFile.getAbsolutePath(); props.setProperty(GLOBAL_PROP_VSL2_FILE, THIRD_PARTY_DIR + File.separator + "VSL2.jar"); if (org.apache.commons.lang.SystemUtils.IS_OS_WINDOWS) { props.setProperty(GLOBAL_PROP_SVM_TRAIN_FILE, THIRD_PARTY_DIR + File.separator + "svm_learn.exe"); props.setProperty(GLOBAL_PROP_SVM_CLASSIFY_FILE, THIRD_PARTY_DIR + File.separator + "svm_classify.exe"); //props.setProperty(GLOBAL_PROP_BLAST_CLUST_FILE, THIRD_PARTY_DIR+File.separator+"blastclust.exe"); props.setProperty(GLOBAL_PROP_CDHIT_FILE, THIRD_PARTY_DIR + File.separator + "cd_hit.exe"); } else if (org.apache.commons.lang.SystemUtils.IS_OS_MAC) { // linux props.setProperty(GLOBAL_PROP_SVM_TRAIN_FILE, THIRD_PARTY_DIR + File.separator + "svm_learn_osx"); props.setProperty(GLOBAL_PROP_SVM_CLASSIFY_FILE, THIRD_PARTY_DIR + File.separator + "svm_classify_osx"); //props.setProperty(GLOBAL_PROP_BLAST_CLUST_FILE, THIRD_PARTY_DIR+File.separator+"blastclust"); props.setProperty(GLOBAL_PROP_CDHIT_FILE, THIRD_PARTY_DIR + File.separator + "cd_hit_osx"); } else { // linux/unix props.setProperty(GLOBAL_PROP_SVM_TRAIN_FILE, THIRD_PARTY_DIR + File.separator + "svm_learn_linux"); props.setProperty(GLOBAL_PROP_SVM_CLASSIFY_FILE, THIRD_PARTY_DIR + File.separator + "svm_classify_linux"); //props.setProperty(GLOBAL_PROP_BLAST_CLUST_FILE, THIRD_PARTY_DIR+File.separator+"blastclust"); props.setProperty(GLOBAL_PROP_CDHIT_FILE, THIRD_PARTY_DIR + File.separator + "cd_hit_linux"); }/*from w w w . j a v a 2 s . c o m*/ return props; }
From source file:musite.MusiteInit.java
public static Properties defaultTrainingProps() { Properties props = new Properties(); props.setProperty(TRAINING_PROPS_SVM_PARAMETERS, "-t 2 -g 1 -c 10 -m 256"); props.setProperty(TRAINING_PROPS_NO_OF_BOOTS, "2000"); props.setProperty(TRAINING_PROPS_NO_OF_CLASSIFIERS, "5"); props.setProperty(TRAINING_PROPS_NEGATIVE_CONTROL_SIZE, "10000"); props.setProperty(TRAINING_PROPS_USE_KNN_FEATURES, "true"); props.setProperty(TRAINING_PROPS_SUBSTITUTION_MATRIX, "blosum62"); props.setProperty(TRAINING_PROPS_KNN_WINDOW_SIZE, "13"); props.setProperty(TRAINING_PROPS_KNN_NEIGHBOR_SIZE, "0.25,0.5,1,2,4"); props.setProperty(TRAINING_PROPS_USE_DISORDER_FEATURES, "true"); props.setProperty(TRAINING_PROPS_DISORDER_WINDOW_SIZES, "1,5,13"); props.setProperty(TRAINING_PROPS_USE_FREQUENCY_FEATURES, "true"); props.setProperty(TRAINING_PROPS_FREQUENCY_WINDOW_SIZE, "13"); props.setProperty(TRAINING_PROPS_FREQUENCY_FEATURE_NUMBER, "20"); props.setProperty(TRAINING_PROPS_PADDING_TERMINALS, "true"); return props; }
From source file:com.runwaysdk.business.generation.maven.MavenClasspathBuilder.java
public static MavenProject loadProject(File pomFile) throws IOException, XmlPullParserException { MavenProject ret = null;//from w w w. j a v a 2 s .co m MavenXpp3Reader mavenReader = new MavenXpp3Reader(); if (pomFile != null && pomFile.exists()) { FileReader reader = null; try { reader = new FileReader(pomFile); Model model = mavenReader.read(reader); model.setPomFile(pomFile); List<Repository> repositories = model.getRepositories(); Properties properties = model.getProperties(); properties.setProperty("basedir", pomFile.getParent()); Parent parent = model.getParent(); if (parent != null) { File parentPom = new File(pomFile.getParent(), parent.getRelativePath()); MavenProject parentProj = loadProject(parentPom); if (parentProj == null) { throw new CoreException("Unable to load parent project at " + parentPom.getAbsolutePath()); } repositories.addAll(parentProj.getRepositories()); model.setRepositories(repositories); properties.putAll(parentProj.getProperties()); } ret = new MavenProject(model); } finally { reader.close(); } } return ret; }