com.jolbox.bonecp
Class AbstractConnectionStrategy

java.lang.Object
  extended by com.jolbox.bonecp.AbstractConnectionStrategy
All Implemented Interfaces:
ConnectionStrategy
Direct Known Subclasses:
CachedConnectionStrategy, DefaultConnectionStrategy

public abstract class AbstractConnectionStrategy
extends Object
implements ConnectionStrategy

Parent class for the different pool strategies.

Author:
wallacew

Field Summary
protected  BoneCP pool
          Pool handle
protected  Lock terminationLock
          Prevent repeated termination of all connections when the DB goes down.
 
Constructor Summary
AbstractConnectionStrategy()
           
 
Method Summary
 Connection getConnection()
          Obtains a connection using the configured strategy.
protected abstract  Connection getConnectionInternal()
          Actual call that returns a connection
 ConnectionHandle pollConnection()
          Obtains a connection using the configured strategy without blocking.
protected  void postConnection(ConnectionHandle handle, long statsObtainTime)
          After obtaining a connection, perform additional tasks.
protected  long preConnection()
          Prep for a new connection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jolbox.bonecp.ConnectionStrategy
terminateAllConnections
 

Field Detail

pool

protected BoneCP pool
Pool handle


terminationLock

protected Lock terminationLock
Prevent repeated termination of all connections when the DB goes down.

Constructor Detail

AbstractConnectionStrategy

public AbstractConnectionStrategy()
Method Detail

preConnection

protected long preConnection()
                      throws SQLException
Prep for a new connection

Returns:
if stats are enabled, return the nanoTime when this connection was requested.
Throws:
SQLException

postConnection

protected void postConnection(ConnectionHandle handle,
                              long statsObtainTime)
After obtaining a connection, perform additional tasks.

Parameters:
handle -
statsObtainTime -

getConnection

public Connection getConnection()
                         throws SQLException
Description copied from interface: ConnectionStrategy
Obtains a connection using the configured strategy. Main entry point.

Specified by:
getConnection in interface ConnectionStrategy
Returns:
Connection
Throws:
SQLException - on error

getConnectionInternal

protected abstract Connection getConnectionInternal()
                                             throws SQLException
Actual call that returns a connection

Returns:
Connection
Throws:
SQLException

pollConnection

public ConnectionHandle pollConnection()
Description copied from interface: ConnectionStrategy
Obtains a connection using the configured strategy without blocking.

Specified by:
pollConnection in interface ConnectionStrategy
Returns:
Connection


Copyright © 2009-2012 JolBox. All Rights Reserved.