Package org.geowebcache.diskquota.jdbc.JDBCConfiguration

Examples of org.geowebcache.diskquota.jdbc.JDBCConfiguration.ConnectionPoolConfiguration


        // now enable it in JDBC mode, with H2 local storage
        quota.setEnabled(true);
        quota.setQuotaStore("JDBC");
        jdbc = new JDBCConfiguration();
        jdbc.setDialect("H2");
        ConnectionPoolConfiguration pool = new ConnectionPoolConfiguration();
        pool.setDriver("org.h2.Driver");
        pool.setUrl("jdbc:h2:./target/quota-h2");
        pool.setUsername("sa");
        pool.setPassword("");
        pool.setMinConnections(1);
        pool.setMaxConnections(1);
        pool.setMaxOpenPreparedStatements(50);
        jdbc.setConnectionPool(pool);
        gwc.saveDiskQuotaConfig(quota, jdbc);
        jdbcConfigFile = dd.findFile("gwc/geowebcache-diskquota-jdbc.xml");
        assertNotNull("jdbc config should be there", jdbcConfigFile);
        assertNull("jdbc store should be there", dd.findDataFile("gwc/diskquota_page_store_h2"));
View Full Code Here


     *
     * @param configuration A deep copy ofthe configuration, with the password encoded
     * @return
     */
    public JDBCConfiguration encryptPassword(JDBCConfiguration configuration) {
        ConnectionPoolConfiguration pool = configuration.getConnectionPool();
        if (pool != null && pool.getPassword() != null) {
            String password = pool.getPassword();
            String encoded = passwords.encode(password);

            configuration = cloneAndSetPassword(configuration, encoded);
        }

View Full Code Here

        return configuration;
    }

    private JDBCConfiguration cloneAndSetPassword(JDBCConfiguration configuration, String encoded) {
        // do a deep clone of the config to avoid altering its contents
        ConnectionPoolConfiguration original = configuration.getConnectionPool();
        ConnectionPoolConfiguration clone = new ConnectionPoolConfiguration();
        clone.setConnectionTimeout(original.getConnectionTimeout());
        clone.setDriver(original.getDriver());
        clone.setMaxConnections(original.getMaxConnections());
        clone.setMaxOpenPreparedStatements(original.getMaxOpenPreparedStatements());
        clone.setMinConnections(original.getMinConnections());
        clone.setPassword(encoded);
        clone.setUrl(original.getUrl());
        clone.setUsername(original.getUsername());
        clone.setValidationQuery(original.getValidationQuery());

        JDBCConfiguration result = new JDBCConfiguration();
        result.setConnectionPool(clone);
        result.setDialect(configuration.getDialect());
        result.setJNDISource(configuration.getJNDISource());
View Full Code Here

    }
   
    public void testRoundTripConnectionPool() throws Exception {
        JDBCConfiguration config = new JDBCConfiguration();
        config.setDialect("PostgreSQL");
        ConnectionPoolConfiguration cp = new ConnectionPoolConfiguration();
        cp.setDriver("org.postgresql.Driver");
        cp.setUrl("jdbc:postgresql:gttest");
        cp.setUsername("test");
        cp.setPassword("toast");
        cp.setMinConnections(1);
        cp.setMaxConnections(10);
        cp.setValidationQuery("select 1");
        cp.setMaxOpenPreparedStatements(50);
        config.setConnectionPool(cp);
       
        File file = new File("./target/dbcp-jdbc.xml");
        if(file.exists()) {
            assertTrue(file.delete());
View Full Code Here

            DataSource ds = null;
            if (config.getJNDISource() != null) {
                InitialContext context = new InitialContext();
                ds = (DataSource) context.lookup(config.getJNDISource());
            } else if(config.getConnectionPool() != null){
                ConnectionPoolConfiguration cp = config.getConnectionPool();
   
                BasicDataSource bds = new BasicDataSource();
                bds.setDriverClassName(cp.getDriver());
                bds.setUrl(cp.getUrl());
                bds.setUsername(cp.getUsername());
                bds.setPassword(cp.getPassword());
                bds.setPoolPreparedStatements(true);
                bds.setMaxOpenPreparedStatements(cp.getMaxOpenPreparedStatements());
                bds.setMinIdle(cp.getMinConnections());
                bds.setMaxActive(cp.getMaxConnections());
                bds.setMaxWait(cp.getConnectionTimeout() * 1000);
                bds.setValidationQuery(cp.getValidationQuery());
               
                ds = bds;
            }
           
            // verify the datasource works
View Full Code Here

TOP

Related Classes of org.geowebcache.diskquota.jdbc.JDBCConfiguration.ConnectionPoolConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.