Example usage for org.hibernate.internal.util.config ConfigurationHelper getBoolean

List of usage examples for org.hibernate.internal.util.config ConfigurationHelper getBoolean

Introduction

In this page you can find the example usage for org.hibernate.internal.util.config ConfigurationHelper getBoolean.

Prototype

public static boolean getBoolean(String name, Map values) 

Source Link

Document

Get the config value as a boolean (default of false)

Usage

From source file:com.jolbox.bonecp.provider.BoneCPConnectionProvider.java

License:Apache License

/**
 * Pool configuration./*w w  w .  j a  v a2 s  . co m*/
 * @param props
 * @throws HibernateException
 */
public void configure(Properties props) throws HibernateException {
    try {
        this.config = new BoneCPConfig(props);

        // old hibernate config
        String url = props.getProperty(CONFIG_CONNECTION_URL);
        String username = props.getProperty(CONFIG_CONNECTION_USERNAME);
        String password = props.getProperty(CONFIG_CONNECTION_PASSWORD);
        String driver = props.getProperty(CONFIG_CONNECTION_DRIVER_CLASS);
        if (url == null) {
            url = props.getProperty(CONFIG_CONNECTION_URL_ALTERNATE);
        }
        if (username == null) {
            username = props.getProperty(CONFIG_CONNECTION_USERNAME_ALTERNATE);
        }
        if (password == null) {
            password = props.getProperty(CONFIG_CONNECTION_PASSWORD_ALTERNATE);
        }
        if (driver == null) {
            driver = props.getProperty(CONFIG_CONNECTION_DRIVER_CLASS_ALTERNATE);
        }

        if (url != null) {
            this.config.setJdbcUrl(url);
        }
        if (username != null) {
            this.config.setUsername(username);
        }
        if (password != null) {
            this.config.setPassword(password);
        }

        // Remember Isolation level
        this.isolation = ConfigurationHelper.getInteger(AvailableSettings.ISOLATION, props);
        this.autocommit = ConfigurationHelper.getBoolean(AvailableSettings.AUTOCOMMIT, props);

        logger.debug(this.config.toString());

        if (driver != null && !driver.trim().equals("")) {
            loadClass(driver);
        }
        if (this.config.getConnectionHookClassName() != null) {
            Object hookClass = loadClass(this.config.getConnectionHookClassName()).newInstance();
            this.config.setConnectionHook((ConnectionHook) hookClass);
        }
        // create the connection pool
        this.pool = createPool(this.config);
    } catch (Exception e) {
        throw new HibernateException(e);
    }
}