Example usage for java.util Properties setProperty

List of usage examples for java.util Properties setProperty

Introduction

In this page you can find the example usage for java.util Properties setProperty.

Prototype

public synchronized Object setProperty(String key, String value) 

Source Link

Document

Calls the Hashtable method put .

Usage

From source file:net.sf.beanlib.hibernate3.Hibernate3SequenceGenerator.java

/** Returns the identifier generator created for the specified sequence and session. */
private static IdentifierGenerator createIdentifierGenerator(String sequenceName, Session session) {
    SessionFactory sessionFactory = session.getSessionFactory();

    if (!(sessionFactory instanceof SessionFactoryImpl))
        throw new IllegalStateException("Not yet know how to handle the session factory of the given session!");
    SessionFactoryImpl sessionFactoryImpl = (SessionFactoryImpl) sessionFactory;
    Settings settings = sessionFactoryImpl.getSettings();
    Dialect dialect = settings.getDialect();

    Properties params = new Properties();
    params.setProperty("sequence", sequenceName);

    return IdentifierGeneratorFactory.create("sequence", TypeFactory.heuristicType("long"), params, dialect);
}

From source file:com.sap.prd.mobile.ios.mios.ModuleBuildTest.java

@BeforeClass
public static void __setup() throws Exception {
    dynamicVersion = "1.0." + String.valueOf(System.currentTimeMillis());
    testName = ModuleBuildTest.class.getName() + File.separator
            + Thread.currentThread().getStackTrace()[1].getMethodName();

    remoteRepositoryDirectory = getRemoteRepositoryDirectory(ModuleBuildTest.class.getName());

    prepareRemoteRepository(remoteRepositoryDirectory);

    Properties pomReplacements = new Properties();
    pomReplacements.setProperty(PROP_NAME_DEPLOY_REPO_DIR, remoteRepositoryDirectory.getAbsolutePath());
    pomReplacements.setProperty(PROP_NAME_DYNAMIC_VERSION, dynamicVersion);

    test(testName, new File(getTestRootDirectory(), "moduleBuild"), "deploy", THE_EMPTY_LIST, THE_EMPTY_MAP,
            pomReplacements, new NullProjectModifier());

    testExecutionDirectoryLibrary = getTestExecutionDirectory(testName, "moduleBuild/MyLibrary");
    testExecutionDirectoryApplication = getTestExecutionDirectory(testName, "moduleBuild/MyApp");

}

From source file:Main.java

public static void setProperties(Properties properties, String keystorePath, String keystorePassword,
        Boolean disableCertVerification) {
    properties.setProperty("javax.net.ssl.keyStore", keystorePath);
    properties.setProperty("javax.net.ssl.trustStore", keystorePath);
    properties.setProperty("javax.net.ssl.keyStorePassword", keystorePassword);
    properties.setProperty("javax.net.ssl.keyStoreType", "bks");
    properties.setProperty("android.gov.nist.javax.sip.ENABLED_CIPHER_SUITES",
            "TLS_RSA_WITH_AES_128_CBC_SHA SSL_RSA_WITH_3DES_EDE_CBC_SHA");
    if (disableCertVerification != null && disableCertVerification) {
        properties.setProperty("android.gov.nist.javax.sip.TLS_CLIENT_AUTH_TYPE", "DisabledAll");
    }/* w  w  w . j  a  va2 s. c  o  m*/
}

From source file:Main.java

/**
 * Convert a map to a {@link Properties} object.
 *
 * @param map/*from w w w  . j  a v a  2 s . c  o  m*/
 *            map object
 * @return properties view of the map
 */
public static Properties asProperties(final Map<String, String> map) {
    final Properties properties = new Properties();
    for (final Map.Entry<String, String> entry : map.entrySet()) {
        properties.setProperty(entry.getKey(), entry.getValue());
    }
    return properties;

}

From source file:gobblin.compliance.HivePartitionFinder.java

private static List<HiveDataset> getHiveDatasets(FileSystem fs, State state) throws IOException {
    Preconditions.checkArgument(state.contains(ComplianceConfigurationKeys.COMPLIANCE_DATASET_WHITELIST),
            "Missing required property " + ComplianceConfigurationKeys.COMPLIANCE_DATASET_WHITELIST);
    Properties prop = new Properties();
    prop.setProperty(ComplianceConfigurationKeys.HIVE_DATASET_WHITELIST,
            state.getProp(ComplianceConfigurationKeys.COMPLIANCE_DATASET_WHITELIST));
    HiveDatasetFinder finder = new HiveDatasetFinder(fs, prop);
    return finder.findDatasets();
}

From source file:StringUtils.java

/**
 *  Creates a Properties object based on an array which contains alternatively
 *  a key and a value.  It is useful for generating default mappings.
 *  For example:/* ww w . j  a  va2s . c o  m*/
 *  <pre>
 *     String[] properties = { "jspwiki.property1", "value1",
 *                             "jspwiki.property2", "value2 };
 *
 *     Properties props = TextUtil.createPropertes( values );
 *
 *     System.out.println( props.getProperty("jspwiki.property1") );
 *  </pre>
 *  would output "value1".
 *
 *  @param values Alternating key and value pairs.
 *  @return Property object
 *  @see java.util.Properties
 *  @throws IllegalArgumentException if the property array is missing
 *          a value for a key.
 *  @since 2.2.
 */

public static Properties createProperties(String[] values) throws IllegalArgumentException {
    if (values.length % 2 != 0)
        throw new IllegalArgumentException("One value is missing.");

    Properties props = new Properties();

    for (int i = 0; i < values.length; i += 2) {
        props.setProperty(values[i], values[i + 1]);
    }

    return props;
}

From source file:com.hazelcast.jet.benchmark.trademonitor.FlinkTradeMonitor.java

private static Properties getKafkaProperties(String brokerUrl, String offsetReset) {
    Properties props = new Properties();
    props.setProperty("bootstrap.servers", brokerUrl);
    props.setProperty("group.id", UUID.randomUUID().toString());
    props.setProperty("key.deserializer", LongDeserializer.class.getName());
    props.setProperty("value.deserializer", TradeDeserializer.class.getName());
    props.setProperty("auto.offset.reset", offsetReset);
    props.setProperty("max.poll.records", "32768");
    return props;
}

From source file:GitHubApiTest.java

/**
 * It's not possible to store username/password in the test file,
 * this cretentials are stored in a properties file
 * under user home directory.//from  w w w . j av  a 2  s .c  o m
 *
 * This method would be used to fetch parameters for the test
 * and allow to avoid committing createntials with source file.
 * @return username, repo, password
 */
@NotNull
public static Properties readGitHubAccount() {
    File propsFile = new File(System.getenv("USERPROFILE"), ".github.test.account");
    System.out.println("Loading properites from: " + propsFile);
    try {
        if (!propsFile.exists()) {
            FileUtil.createParentDirs(propsFile);
            Properties ps = new Properties();
            ps.setProperty(URL, "https://api.github.com");
            ps.setProperty(USERNAME, "jonnyzzz");
            ps.setProperty(REPOSITORY, "TeamCity.GitHub");
            ps.setProperty(PASSWORD_REV, rewind("some-password-written-end-to-front"));
            PropertiesUtil.storeProperties(ps, propsFile, "mock properties");
            return ps;
        } else {
            return PropertiesUtil.loadProperties(propsFile);
        }
    } catch (IOException e) {
        throw new RuntimeException("Could not read Amazon Access properties: " + e.getMessage(), e);
    }
}

From source file:test.SomeMainClass.java

private static String dumpConfiguration(Configuration configuration) {
    StringBuilder sb = new StringBuilder("Config@" + configuration.hashCode());
    sb.append("\n");
    sb.append(configuration.toString());
    sb.append("\n");

    Properties props = new Properties();
    if (configuration != null) {
        for (Map.Entry<String, String> entry : configuration) {
            props.setProperty(entry.getKey(), entry.getValue());
        }//  w  w w  . j  a  v  a2s.c om
    }

    return sb.append(props.toString()).toString();
}

From source file:com.qubole.quark.server.EndToEndTest.java

public static void setupTables(String dbUrl, String filename)
        throws ClassNotFoundException, SQLException, IOException, URISyntaxException {

    Class.forName("org.h2.Driver");
    Properties props = new Properties();
    props.setProperty("user", "sa");
    props.setProperty("password", "");

    Connection connection = DriverManager.getConnection(dbUrl, props);

    Statement stmt = connection.createStatement();
    java.net.URL url = EndToEndTest.class.getResource("/" + filename);
    java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI());
    String sql = new String(java.nio.file.Files.readAllBytes(resPath), "UTF8");

    stmt.execute(sql);//w  ww.  j  a va  2  s . co  m
}