Example usage for java.util Properties Properties

List of usage examples for java.util Properties Properties

Introduction

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

Prototype

public Properties() 

Source Link

Document

Creates an empty property list with no default values.

Usage

From source file:Main.java

/**
 * Returns properties for RA connection-definition element
 *//*from   www . j a v  a 2 s  .  c  o m*/
public static Properties raConnectionProperties() {
    Properties params = new Properties();
    //attributes
    params.put("use-java-context", "false");
    params.put("class-name", "Class1");
    params.put("use-ccm", "true");
    params.put("jndi-name", "java:jboss/name1");
    params.put("enabled", "false");
    //pool
    params.put("min-pool-size", "1");
    params.put("max-pool-size", "5");
    params.put("pool-prefill", "true");
    params.put("pool-use-strict-min", "true");
    params.put("flush-strategy", "IdleConnections");
    //xa-pool
    params.put("same-rm-override", "true");
    params.put("interleaving", "true");
    params.put("no-tx-separate-pool", "true");
    params.put("pad-xid", "true");
    params.put("wrap-xa-resource", "true");
    //security
    params.put("security-application", "true");
    //validation
    params.put("background-validation", "true");
    params.put("background-validation-millis", "5000");
    params.put("use-fast-fail", "true");
    //time-out
    params.put("blocking-timeout-wait-millis", "5000");
    params.put("idle-timeout-minutes", "4");
    params.put("allocation-retry", "2");
    params.put("allocation-retry-wait-millis", "3000");
    params.put("xa-resource-timeout", "300");
    //recovery
    params.put("no-recovery", "false");
    params.put("recovery-plugin-class-name", "someClass2");
    params.put("recovery-username", "sa");
    params.put("recovery-password", "sa-pass");
    //AS7-5300
    //params.put("recovery-security-domain", "HsqlDbRealm");

    return params;
}

From source file:com.krawler.portal.util.SystemEnv.java

public static Properties getProperties() {
    Properties props = new Properties();

    try {/*from   w w  w  .  j  a  v  a  2 s  . co m*/
        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:Main.java

/**
 * Returns properties for RA connection-definition element
             // w  w  w  . j a va2 s  .co  m
 */
public static Properties raConnectionProperties() {
    Properties params = new Properties();
    //attributes
    params.put("use-java-context", "false");
    params.put("class-name", "Class1");
    params.put("use-ccm", "true");
    params.put("jndi-name", "java:jboss/name1");
    params.put("enabled", "false");
    //pool
    params.put("min-pool-size", "1");
    params.put("max-pool-size", "5");
    params.put("pool-prefill", "true");
    params.put("pool-use-strict-min", "true");
    params.put("flush-strategy", "IdleConnections");
    //xa-pool
    params.put("same-rm-override", "true");
    params.put("interleaving", "true");
    params.put("no-tx-separate-pool", "true");
    params.put("pad-xid", "true");
    params.put("wrap-xa-resource", "true");
    //security
    params.put("application", "true");
    params.put("security-domain-and-application", "HsqlDbRealm1");
    params.put("security-domain", "HsqlDbRealm");
    //validation
    params.put("background-validation", "true");
    params.put("background-validation-millis", "5000");
    params.put("use-fast-fail", "true");
    //time-out
    params.put("blocking-timeout-wait-millis", "5000");
    params.put("idle-timeout-minutes", "4");
    params.put("allocation-retry", "2");
    params.put("allocation-retry-wait-millis", "3000");
    params.put("xa-resource-timeout", "300");
    //recovery
    params.put("no-recovery", "false");
    params.put("recovery-plugin-class-name", "someClass2");
    params.put("recovery-username", "sa");
    params.put("recovery-password", "sa-pass");
    params.put("recovery-security-domain", "HsqlDbRealm");

    return params;
}

From source file:com.esofthead.mycollab.servlet.InstallUtils.java

public static void checkSMTPConfig(String host, int port, String username, String password, boolean auth,
        boolean isStartTls, boolean isSSL) {
    try {/*  w w  w .  j  a v a  2  s.c om*/
        Properties props = new Properties();
        if (auth) {
            props.setProperty("mail.smtp.auth", "true");
        } else {
            props.setProperty("mail.smtp.auth", "false");
        }
        if (isStartTls) {
            props.setProperty("mail.smtp.starttls.enable", "true");
            props.setProperty("mail.smtp.startssl.enable", "true");
        } else if (isSSL) {
            props.setProperty("mail.smtp.startssl.enable", "false");
            props.setProperty("mail.smtp.ssl.enable", "true");
            props.setProperty("mail.smtp.ssl.socketFactory.fallback", "false");

        }

        Email email = new SimpleEmail();
        email.setHostName(host);
        email.setSmtpPort(port);
        email.setAuthenticator(new DefaultAuthenticator(username, password));
        if (isStartTls) {
            email.setStartTLSEnabled(true);
        } else {
            email.setStartTLSEnabled(false);
        }

        if (isSSL) {
            email.setSSLOnConnect(true);
        } else {
            email.setSSLOnConnect(false);
        }
        email.setFrom(username);
        email.setSubject("MyCollab Test Email");
        email.setMsg("This is a test mail ... :-)");
        email.addTo(username);
        email.send();
    } catch (Exception e) {
        throw new UserInvalidInputException(e);
    }
}

From source file:com.l2jfree.security.HexID.java

/**
 * Save hexadecimal ID of the server in the properties file.
 * //from   w  ww  .j  ava  2  s . c om
 * @param string (String) : hexadecimal ID of the server to store
 * @param fileName (String) : name of the properties file
 */
public static void saveHexid(String string, String fileName) {
    OutputStream out = null;
    try {
        out = new FileOutputStream(fileName);

        final Properties hexSetting = new Properties();
        hexSetting.setProperty("HexID", string);
        hexSetting.store(out, "the hexID to auth into login");
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(out);
    }
}

From source file:Main.java

/**
 * Creates an Properties object initialized with the value from the given Map.
 * <p>/*from  www.j  ava 2 s . co m*/
 * @param map the Map supply the keys and value for the Properties object.
 * @return a Properties object initialized with the key and value from the Map.
 * @see java.util.Map
 * @see java.util.Properties
 */
public static Properties createProperties(final Map<String, String> map) {
    Properties properties = new Properties();

    if (!(map == null || map.isEmpty())) {
        for (Entry<String, String> entry : map.entrySet()) {
            properties.setProperty(entry.getKey(), entry.getValue());
        }
    }

    return properties;
}

From source file:org.excalibur.core.util.Properties2.java

public static Properties load(InputStream inStream) {
    Properties properties = new Properties();

    try {//  w  ww  . j a va 2 s. c  o m
        properties.load(inStream);
    } catch (IOException e) {
        LOGGER.error("Error on loading the properties. Error message: {}", e.getMessage());
        AnyThrow.throwUncheked(e);
    }

    return properties;
}

From source file:org.trustedanalytics.platformcontext.unit.TestConfiguration.java

@Bean
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {

    PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
    ppc.setIgnoreResourceNotFound(true);
    final Properties properties = new Properties();
    properties.setProperty("cf.resource", ApiControllerTest.CF_RESOURCE);
    properties.setProperty("cf.cli.version", "");
    properties.setProperty("cf.cli.url", "");
    properties.setProperty("platform.version", "0.1");
    properties.setProperty("platform.coreorg", "coreOrg");
    ppc.setProperties(properties);/*from   w ww  .  ja v  a2  s.c  o m*/

    return ppc;
}

From source file:eu.planets_project.ifr.core.common.conf.PlanetsServerConfig.java

/**
 * Static property loader.//from   w  w w  .jav  a2 s  . c  om
 * @return The Properties array:
 */
private static Properties loadProps() {
    Properties props = new Properties();
    InputStream stream = null;
    try {
        stream = PlanetsServerConfig.class.getResourceAsStream(
                "/eu/planets_project/ifr/core/common/conf/planets-server-config.properties");
        props.load(stream);
    } catch (IOException e) {
        log.severe("Server properties failed to load! :: " + e);
        IOUtils.closeQuietly(stream);
    }
    return props;
}

From source file:gobblin.util.PropertiesUtils.java

/**
 * Combine a variable number of {@link Properties} into a single {@link Properties}.
 *//*w  w  w .jav a 2s.c  om*/
public static Properties combineProperties(Properties... properties) {
    Properties combinedProperties = new Properties();
    for (Properties props : properties) {
        combinedProperties.putAll(props);
    }
    return combinedProperties;
}