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:uk.ac.ebi.eva.pipeline.configuration.CommonConfiguration.java

@Bean
private static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();

    Properties properties = new Properties();
    properties.put("input.vcf", "");
    properties.put("input.vcf.id", "1");
    properties.put("input.vcf.aggregation", "NONE");
    properties.put("input.study.type", "COLLECTION");
    properties.put("input.study.name", "input.study.name");
    properties.put("input.study.id", "1");
    properties.put("input.pedigree", "");
    properties.put("input.gtf", "");
    properties.put("input.fasta", "");

    properties.put("output.dir", "/tmp");
    properties.put("output.dir.annotation", "");
    properties.put("output.dir.statistics", "/tmp");

    properties.put("statistics.overwrite", "false");

    properties.put("db.hosts", "localhost:27017");
    //        properties.put("dbName", null);
    properties.put("db.collection.variants.name", "variants");
    properties.put("db.collection.files.name", "files");
    properties.put("db.collections.features.name", "features");
    properties.put("config.db.read-preference", "primary");

    properties.put("app.opencga.path", opencgaHome);
    properties.put("app.vep.path", "");
    properties.put("app.vep.cache.path", "");
    properties.put("app.vep.cache.version", "");
    properties.put("app.vep.cache.species", "");
    properties.put("app.vep.num-forks", "3");

    properties.put("config.restartability.allow", false);

    configurer.setProperties(properties);

    return configurer;
}

From source file:test.java.ecplugins.weblogic.TestUtils.java

public static Properties getProperties() throws Exception {

    if (props == null) {
        props = new Properties();
        InputStream is = null;//from ww  w  . j a  va2s.co m
        is = new FileInputStream("ecplugin.properties");
        props.load(is);
        is.close();
    }

    return props;
}

From source file:com.khs.sherpa.util.Util.java

public static Properties getProperties(URL url) throws IOException {
    Properties properties = new Properties();
    properties.load(url.openStream());//from  w  ww.j a  v a2s  .com
    return properties;
}

From source file:com.groupdocs.ui.ViewerUtils.java

public static Path getProjectBaseDir() {
    Properties props = new Properties();
    try {/*from ww  w.  j  a v  a 2s  . c om*/
        InputStream i = ViewerUtils.class.getResourceAsStream("/project.properties");
        props.load(i);
    } catch (IOException x) {
        throw new RuntimeException(x);
    }
    return FileSystems.getDefault().getPath(props.getProperty("project.basedir"));
}

From source file:com.carrotgarden.maven.aws.grv.TestCarrotGroovyRunner.java

@Test
public void testFile() throws Exception {

    final Properties properties = new Properties();
    properties.put("prop-key", "prop-value-1");

    assertEquals(properties.get("prop-key"), "prop-value-1");

    final MavenProject project = mock(MavenProject.class);

    when(project.getProperties()).thenReturn(properties);

    final CarrotGroovyRunner runner = new CarrotGroovyRunner(project);

    final File script = new File("./src/test/resources/script.groovy");

    final Object result = runner.execute(script);

    assertEquals(result, "result");

    assertEquals(properties.get("prop-key"), "prop-value-2");

}

From source file:org.wso2.mdm.qsg.utils.QSGUtils.java

public static EMMQSGConfig initConfig() {
    Properties props = new Properties();
    InputStream input = null;/*w ww  .  j ava 2  s.  c o m*/
    EMMQSGConfig emmConfig = null;
    try {
        input = new FileInputStream("config.properties");
        // load a properties file and set the properties
        props.load(input);
        emmConfig = EMMQSGConfig.getInstance();
        emmConfig.setEmmHost(props.getProperty("emm-host"));
        emmConfig.setDcrEndPoint(props.getProperty("dcr-endpoint"));
        emmConfig.setOauthEndPoint(props.getProperty("oauth-endpoint"));
        emmConfig.setUsername(props.getProperty("username"));
        emmConfig.setPassword(props.getProperty("password"));
    } catch (IOException ex) {
        ex.printStackTrace();
    } finally {
        if (input != null) {
            try {
                input.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    return emmConfig;
}

From source file:eu.forgestore.ws.util.EmailUtil.java

public static void SendRegistrationActivationEmail(String email, String messageBody) {

    Properties props = new Properties();

    // Session session = Session.getDefaultInstance(props, null);

    props.setProperty("mail.transport.protocol", "smtp");
    if ((FStoreRepository.getPropertyByName("mailhost").getValue() != null)
            && (!FStoreRepository.getPropertyByName("mailhost").getValue().isEmpty()))
        props.setProperty("mail.host", FStoreRepository.getPropertyByName("mailhost").getValue());
    if ((FStoreRepository.getPropertyByName("mailuser").getValue() != null)
            && (!FStoreRepository.getPropertyByName("mailuser").getValue().isEmpty()))
        props.setProperty("mail.user", FStoreRepository.getPropertyByName("mailuser").getValue());
    if ((FStoreRepository.getPropertyByName("mailpassword").getValue() != null)
            && (!FStoreRepository.getPropertyByName("mailpassword").getValue().isEmpty()))
        props.setProperty("mail.password", FStoreRepository.getPropertyByName("mailpassword").getValue());

    String adminemail = FStoreRepository.getPropertyByName("adminEmail").getValue();
    String subj = FStoreRepository.getPropertyByName("activationEmailSubject").getValue();
    logger.info("adminemail = " + adminemail);
    logger.info("subj = " + subj);

    Session mailSession = Session.getDefaultInstance(props, null);
    Transport transport;//  ww  w . j  a  v  a 2  s  .com
    try {
        transport = mailSession.getTransport();

        MimeMessage msg = new MimeMessage(mailSession);
        msg.setSentDate(new Date());
        msg.setFrom(new InternetAddress(adminemail, adminemail));
        msg.setSubject(subj);
        msg.setContent(messageBody, "text/html; charset=ISO-8859-1");
        msg.addRecipient(Message.RecipientType.TO, new InternetAddress(email, email));

        transport.connect();
        transport.sendMessage(msg, msg.getRecipients(Message.RecipientType.TO));

        transport.close();

    } catch (NoSuchProviderException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (MessagingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:gr.upatras.ece.nam.baker.util.EmailUtil.java

public static void SendRegistrationActivationEmail(String email, String messageBody) {

    Properties props = new Properties();

    // Session session = Session.getDefaultInstance(props, null);

    props.setProperty("mail.transport.protocol", "smtp");
    if ((BakerRepository.getPropertyByName("mailhost").getValue() != null)
            && (!BakerRepository.getPropertyByName("mailhost").getValue().isEmpty()))
        props.setProperty("mail.host", BakerRepository.getPropertyByName("mailhost").getValue());
    if ((BakerRepository.getPropertyByName("mailuser").getValue() != null)
            && (!BakerRepository.getPropertyByName("mailuser").getValue().isEmpty()))
        props.setProperty("mail.user", BakerRepository.getPropertyByName("mailuser").getValue());
    if ((BakerRepository.getPropertyByName("mailpassword").getValue() != null)
            && (!BakerRepository.getPropertyByName("mailpassword").getValue().isEmpty()))
        props.setProperty("mail.password", BakerRepository.getPropertyByName("mailpassword").getValue());

    String adminemail = BakerRepository.getPropertyByName("adminEmail").getValue();
    String subj = BakerRepository.getPropertyByName("activationEmailSubject").getValue();
    logger.info("adminemail = " + adminemail);
    logger.info("subj = " + subj);

    Session mailSession = Session.getDefaultInstance(props, null);
    Transport transport;/*w w w .j a  v  a 2  s  . c o m*/
    try {
        transport = mailSession.getTransport();

        MimeMessage msg = new MimeMessage(mailSession);
        msg.setSentDate(new Date());
        msg.setFrom(new InternetAddress(adminemail, adminemail));
        msg.setSubject(subj);
        msg.setContent(messageBody, "text/html; charset=ISO-8859-1");
        msg.addRecipient(Message.RecipientType.TO, new InternetAddress(email, email));

        transport.connect();
        transport.sendMessage(msg, msg.getRecipients(Message.RecipientType.TO));

        transport.close();

    } catch (NoSuchProviderException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (MessagingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:com.ts.db.connector.ConnectorMap.java

public ConnectorMap(List<String> idList, Properties props) {
    for (String id : idList) {
        Properties p = new Properties();
        copyPropertyById(id, "name", props, p);
        copyPropertyById(id, "driver", props, p);
        copyPropertyById(id, "classpath", props, p);
        copyPropertyById(id, "url", props, p);
        copyPropertyById(id, "user", props, p);
        copyPropertyById(id, "password", props, p);
        copyPropertyById(id, "password.class", props, p);
        copyPropertyById(id, "readonly", props, p);
        copyPropertyById(id, "rollback", props, p);
        Connector connector = new Connector(id, p);
        put(id, connector);/*from  w  w w.j  a va  2  s.c om*/
    }
}

From source file:com.google.code.oauth.OAuth2Authenticator.java

/**
 * Connects and authenticates to an IMAP server with OAuth2. You must have called {@code initialize}.
 *
 * @param userEmail Email address of the user to authenticate, for example {@code oauth@gmail.com}.
 * @param oauthToken The user's OAuth token.
 *
 * @return An authenticated IMAPStore that can be used for IMAP operations.
 *//* www  .j  a  va  2s  .c  o m*/
public static IMAPStore connectToImap(String userEmail, String oauthToken) throws MessagingException {
    Properties props = new Properties();
    props.put("mail.imaps.sasl.enable", "true");
    props.put("mail.imaps.sasl.mechanisms", "XOAUTH2");
    props.put(OAuth2SaslClientFactory.OAUTH_TOKEN_PROP, oauthToken);
    Session session = Session.getInstance(props);

    IMAPSSLStore store = new IMAPSSLStore(session, null);
    store.connect("imap.gmail.com", 993, userEmail, StringUtils.EMPTY);
    return store;
}