com.jolbox.bonecp.provider
Class BoneCPConnectionProvider

java.lang.Object
  extended by com.jolbox.bonecp.provider.BoneCPConnectionProvider
All Implemented Interfaces:
Serializable, org.hibernate.service.jdbc.connections.spi.ConnectionProvider, org.hibernate.service.Service, org.hibernate.service.spi.Configurable, org.hibernate.service.spi.Stoppable, org.hibernate.service.spi.Wrapped

public class BoneCPConnectionProvider
extends Object
implements org.hibernate.service.jdbc.connections.spi.ConnectionProvider, org.hibernate.service.spi.Configurable, org.hibernate.service.spi.Stoppable

Hibernate Connection Provider.

Author:
wallacew
See Also:
Serialized Form

Field Summary
protected static String CONFIG_CONNECTION_DRIVER_CLASS
          Config key.
protected static String CONFIG_CONNECTION_DRIVER_CLASS_ALTERNATE
          Config key.
protected static String CONFIG_CONNECTION_PASSWORD
          Config key.
protected static String CONFIG_CONNECTION_PASSWORD_ALTERNATE
          Config key.
protected static String CONFIG_CONNECTION_URL
          Config key.
protected static String CONFIG_CONNECTION_URL_ALTERNATE
          Config key.
protected static String CONFIG_CONNECTION_USERNAME
          Config key.
protected static String CONFIG_CONNECTION_USERNAME_ALTERNATE
          Config key.
 
Constructor Summary
BoneCPConnectionProvider()
           
 
Method Summary
 void close()
          alias for stop.
 void closeConnection(Connection conn)
          
 void configure(Map configurationValues)
           
 void configure(Properties props)
          Pool configuration.
protected  BoneCP createPool(BoneCPConfig config)
          Creates the given connection pool with the given configuration.
 ClassLoader getClassLoader()
          Returns the classloader to use when attempting to load the jdbc driver (if a value is given).
protected  BoneCPConfig getConfig()
          Returns the configuration object being used.
 Connection getConnection()
          
 boolean isUnwrappableAs(Class unwrapType)
           
protected  Class<?> loadClass(String clazz)
          Loads the given class, respecting the given classloader.
 void setClassLoader(ClassLoader classLoader)
          Specifies the classloader to use when attempting to load the jdbc driver (if a value is given).
 void stop()
           
 boolean supportsAggressiveRelease()
          
<T> T
unwrap(Class<T> unwrapType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_CONNECTION_DRIVER_CLASS

protected static final String CONFIG_CONNECTION_DRIVER_CLASS
Config key.

See Also:
Constant Field Values

CONFIG_CONNECTION_PASSWORD

protected static final String CONFIG_CONNECTION_PASSWORD
Config key.

See Also:
Constant Field Values

CONFIG_CONNECTION_USERNAME

protected static final String CONFIG_CONNECTION_USERNAME
Config key.

See Also:
Constant Field Values

CONFIG_CONNECTION_URL

protected static final String CONFIG_CONNECTION_URL
Config key.

See Also:
Constant Field Values

CONFIG_CONNECTION_DRIVER_CLASS_ALTERNATE

protected static final String CONFIG_CONNECTION_DRIVER_CLASS_ALTERNATE
Config key.

See Also:
Constant Field Values

CONFIG_CONNECTION_PASSWORD_ALTERNATE

protected static final String CONFIG_CONNECTION_PASSWORD_ALTERNATE
Config key.

See Also:
Constant Field Values

CONFIG_CONNECTION_USERNAME_ALTERNATE

protected static final String CONFIG_CONNECTION_USERNAME_ALTERNATE
Config key.

See Also:
Constant Field Values

CONFIG_CONNECTION_URL_ALTERNATE

protected static final String CONFIG_CONNECTION_URL_ALTERNATE
Config key.

See Also:
Constant Field Values
Constructor Detail

BoneCPConnectionProvider

public BoneCPConnectionProvider()
Method Detail

closeConnection

public void closeConnection(Connection conn)
                     throws SQLException

Specified by:
closeConnection in interface org.hibernate.service.jdbc.connections.spi.ConnectionProvider
Throws:
SQLException
See Also:
ConnectionProvider.closeConnection(java.sql.Connection)

configure

public void configure(Properties props)
               throws org.hibernate.HibernateException
Pool configuration.

Parameters:
props -
Throws:
org.hibernate.HibernateException

loadClass

protected Class<?> loadClass(String clazz)
                      throws ClassNotFoundException
Loads the given class, respecting the given classloader.

Parameters:
clazz - class to load
Returns:
Loaded class
Throws:
ClassNotFoundException

createPool

protected BoneCP createPool(BoneCPConfig config)
Creates the given connection pool with the given configuration. Extracted here to make unit mocking easier.

Parameters:
config - configuration object.
Returns:
BoneCP connection pool handle.

getConnection

public Connection getConnection()
                         throws SQLException

Specified by:
getConnection in interface org.hibernate.service.jdbc.connections.spi.ConnectionProvider
Throws:
SQLException
See Also:
ConnectionProvider.getConnection()

supportsAggressiveRelease

public boolean supportsAggressiveRelease()

Specified by:
supportsAggressiveRelease in interface org.hibernate.service.jdbc.connections.spi.ConnectionProvider
See Also:
ConnectionProvider.supportsAggressiveRelease()

getConfig

protected BoneCPConfig getConfig()
Returns the configuration object being used.

Returns:
configuration object

getClassLoader

public ClassLoader getClassLoader()
Returns the classloader to use when attempting to load the jdbc driver (if a value is given).

Returns:
the classLoader currently set.

setClassLoader

public void setClassLoader(ClassLoader classLoader)
Specifies the classloader to use when attempting to load the jdbc driver (if a value is given). Set to null to use the default loader.

Parameters:
classLoader - the classLoader to set

isUnwrappableAs

public boolean isUnwrappableAs(Class unwrapType)
Specified by:
isUnwrappableAs in interface org.hibernate.service.spi.Wrapped

unwrap

public <T> T unwrap(Class<T> unwrapType)
Specified by:
unwrap in interface org.hibernate.service.spi.Wrapped

configure

public void configure(Map configurationValues)
Specified by:
configure in interface org.hibernate.service.spi.Configurable

stop

public void stop()
Specified by:
stop in interface org.hibernate.service.spi.Stoppable

close

public void close()
alias for stop.



Copyright © 2009-2012 JolBox. All Rights Reserved.