Example usage for java.util Properties put

List of usage examples for java.util Properties put

Introduction

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

Prototype

@Override
    public synchronized Object put(Object key, Object value) 

Source Link

Usage

From source file:com.espertech.esper.regression.db.TestDatabaseDataSourceFactory.java

public void testDBCP() throws Exception {
    Properties props = new Properties();
    props.put("driverClassName", SupportDatabaseService.DRIVER);
    props.put("url", SupportDatabaseService.FULLURL);
    props.put("username", SupportDatabaseService.DBUSER);
    props.put("password", SupportDatabaseService.DBPWD);

    ConfigurationDBRef configDB = new ConfigurationDBRef();
    // for DBCP, use setDataSourceFactoryDBCP
    configDB.setDataSourceFactory(props, SupportDataSourceFactory.class.getName());
    configDB.setConnectionLifecycleEnum(ConfigurationDBRef.ConnectionLifecycleEnum.POOLED);
    configDB.setLRUCache(100);/*from   w ww . j a  v  a2s  . com*/

    Configuration configuration = SupportConfigFactory.getConfiguration();
    configuration.addDatabaseReference("MyDB", configDB);

    epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();

    runAssertion();
}

From source file:org.cambillaum.jpapersistor.persistence.configuration.PersistenceConfiguration.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactory.setDataSource(dataSource());
    Properties jpaProperties = new Properties();
    jpaProperties.put("hibernate.show.sql", "true");
    jpaProperties.put("hibernate.hbm2ddl.auto", "create-drop");
    entityManagerFactory.setJpaProperties(jpaProperties);
    entityManagerFactory.setJpaVendorAdapter(jpaVendorAdapter());
    JpaDialect jpaDialect = new HibernateJpaDialect();
    entityManagerFactory.setJpaDialect(jpaDialect);
    entityManagerFactory.setPackagesToScan("org.cambillaum.jpapersistor");
    return entityManagerFactory;
}

From source file:se.kth.csc.config.JpaConfig.java

/**
 * Creates a new entity manager factory bean using the provided settings.
 *
 * @param dataSource  The JDBC data source to use.
 * @param hbm2ddlAuto The Hibernate setting controlling how database schemas should be automatically migrated.
 * @param dialect     The SQL dialect that Hibernate should use.
 *///from   www .  j  a  v  a  2 s  . c o m
@Autowired
@Bean
public LocalContainerEntityManagerFactoryBean configureEntityManagerFactory(DataSource dataSource,
        @Value("${hibernate.hbm2ddl.auto}") String hbm2ddlAuto, @Value("${hibernate.dialect}") String dialect) {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource);
    entityManagerFactoryBean.setPackagesToScan(Application.class.getPackage().getName());
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());

    Properties jpaProperties = new Properties();
    jpaProperties.put(Environment.DIALECT, dialect);
    jpaProperties.put(Environment.HBM2DDL_AUTO, hbm2ddlAuto);
    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    log.info(
            "Creating entity manager factory bean with automatic \"{}\" schema management and the {} SQL dialect",
            hbm2ddlAuto, dialect);
    return entityManagerFactoryBean;
}

From source file:com.anjewe.anjewewebwinkel.Config.RootConfig.java

@Bean
public Properties connectionProperties() {
    Properties properties = new Properties();
    properties.put("hibernate.dialect", env.getRequiredProperty(HIBERNATE_DIALECT));
    properties.put("hibernate.show_sql", env.getRequiredProperty(HIBERNATE_SHOW_SQL));
    properties.put("hibernate.format_sql", env.getRequiredProperty(HIBERNATE_FORMAT_SQL));
    properties.put("hibernate.hbm2ddl.auto", env.getRequiredProperty(HIBERNATE_HBM2DDL));
    return properties;
}

From source file:net.kamhon.ieagle.function.config.JpaAppConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManager = new LocalContainerEntityManagerFactoryBean();
    entityManager.setDataSource(dataSource);
    entityManager.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver());

    HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
    jpaVendorAdapter.setShowSql(env.getProperty("hibernate.show_sql", Boolean.class));

    String generateDdlMode = env.getProperty("hibernate.hbm2ddl.auto");
    boolean isGenerateDdl = generateDdlMode != null && !"validate".equalsIgnoreCase(generateDdlMode);
    jpaVendorAdapter.setGenerateDdl(isGenerateDdl);

    jpaVendorAdapter.setDatabase(Database.valueOf(env.getProperty("jpa.vendor")));
    entityManager.setJpaVendorAdapter(jpaVendorAdapter);

    // hibernate tuning
    Properties prop = new Properties();
    prop.put("hibernate.max_fetch_depth", "3");
    prop.put("hibernate.jdbc.fetch_size", "50");
    prop.put("hibernate.jdbc.batch_size", "10");
    entityManager.setJpaProperties(prop);

    // entityManager.setPersistenceUnitName("persistenceUnit");

    return entityManager;
}

From source file:org.csc.phynixx.spring.integration.config.JTAPersistenceConfig.java

@Override
@Bean(initMethod = "init", destroyMethod = "close")
public DataSource dataSource() throws SQLException {

    /**  no XA support for hsqldb
            //  www .  j a  v a  2s  .c o  m
    JDBCXADataSource hsqlXaDataSource= new JDBCXADataSource();
            
    hsqlXaDataSource.setUrl("jdbc:hsqldb:mem:" + "Test");
    hsqlXaDataSource.setUser("sa");
    hsqlXaDataSource.setPassword("");
            
            
    MysqlXADataSource mysqlXaDataSource = new MysqlXADataSource();
    mysqlXaDataSource.setUrl(this.environment.getProperty("dataSource.url"));
    mysqlXaDataSource.setPinGlobalTxToPhysicalConnection(true);
    mysqlXaDataSource.setPassword(this.environment.getProperty("dataSource.password"));
    mysqlXaDataSource.setUser(this.environment.getProperty("dataSource.password"));
    **/
    PoolingDataSource ds = new PoolingDataSource();
    // a h2 in-memory database...make sure to use the XADatasources for other databases
    ds.setClassName("org.h2.jdbcx.JdbcDataSource");
    ds.setUniqueName("ds1");
    ds.setMaxPoolSize(10);
    Properties props = new Properties();
    props.put("URL", "jdbc:h2:mem:ds1");
    props.put("user", "sa");
    props.put("password", "");
    ds.setDriverProperties(props);
    ds.init();

    return ds;
}

From source file:org.esigate.http.HeaderManagerTest.java

/**
 * Test that we set a X-Forwarded-Proto header in backend requests.
 * //from ww w .  j a  v  a 2 s. co m
 * @throws Exception
 */
public void testXForwardedProtoHeader() throws Exception {
    Properties props = new Properties();
    props.put(Parameters.REMOTE_URL_BASE.getName(), "http://www.foo.com/");
    Driver driver = Driver.builder().setName("test").setProperties(props).build();
    DriverRequest driverRequest = TestUtils.createDriverRequest("https://wwww.foo.com", driver);
    OutgoingRequest outgoingRequest = new OutgoingRequest(
            driverRequest.getOriginalRequest().getRequestLine().getMethod(),
            driverRequest.getOriginalRequest().getRequestLine().getUri(),
            driverRequest.getOriginalRequest().getRequestLine().getProtocolVersion(), driverRequest, null,
            null);
    headerManager.copyHeaders(driverRequest, outgoingRequest);
    Header[] headers = outgoingRequest.getHeaders("X-Forwarded-Proto");
    assertEquals("We should have 1 X-Forwarded-Proto header", 1, headers.length);
    assertEquals("Wrong X-Forwarded-Proto header", "https", headers[0].getValue());
}

From source file:de.avanux.livetracker.mobile.LocationReceiver.java

private Properties buildResponse(Tracking tracking) {
    Properties configuration = new Properties();
    configuration.put(ConfigurationConstants.MIN_TIME_INTERVAL,
            "" + Configuration.getInstance().getMinTimeInterval());
    configuration.put(ConfigurationConstants.TRACKER_COUNT, "" + tracking.getTrackerCount());
    return configuration;
}

From source file:com.consol.citrus.demo.devoxx.service.MailService.java

/**
 * Send mail via SMTP connection.//from ww w  .  ja va  2s. c  o m
 * @param to
 * @param subject
 * @param body
 */
public void sendMail(String to, String subject, String body) {
    Properties props = new Properties();
    props.put("mail.smtp.host", mailServerHost);
    props.put("mail.smtp.port", mailServerPort);
    props.put("mail.smtp.auth", true);

    Authenticator authenticator = new Authenticator() {
        private PasswordAuthentication pa = new PasswordAuthentication(username, password);

        @Override
        public PasswordAuthentication getPasswordAuthentication() {
            return pa;
        }
    };

    Session session = Session.getInstance(props, authenticator);
    session.setDebug(true);
    MimeMessage message = new MimeMessage(session);
    try {
        message.setFrom(new InternetAddress(from));
        InternetAddress[] address = { new InternetAddress(to) };
        message.setRecipients(Message.RecipientType.TO, address);
        message.setSubject(subject);
        message.setSentDate(new Date());
        message.setText(body);
        Transport.send(message);
    } catch (MessagingException e) {
        log.error("Failed to send mail!", e);
    }
}