org.apache.ojb.broker.accesslayer
Class ConnectionFactoryAbstractImpl

java.lang.Object
  extended byorg.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl
All Implemented Interfaces:
ConnectionFactory
Direct Known Subclasses:
ConnectionFactoryDBCPImpl, ConnectionFactoryNotPooledImpl, ConnectionFactoryPooledImpl

public abstract class ConnectionFactoryAbstractImpl
extends java.lang.Object
implements ConnectionFactory

Abstract base class to simplify implementation of ConnectionFactory's.

Version:
$Id: ConnectionFactoryAbstractImpl.java,v 1.7 2003/08/13 18:53:35 arminw Exp $
Author:
Armin Waibel

Constructor Summary
ConnectionFactoryAbstractImpl()
           
 
Method Summary
abstract  java.sql.Connection getConnectionFromPool(JdbcConnectionDescriptor jcd)
          Implement this method.
protected  java.lang.String getDbURL(JdbcConnectionDescriptor jcd)
           
protected  void initializeJdbcConnection(java.sql.Connection con, JdbcConnectionDescriptor jcd)
          Initialize the connection with the specified properties in OJB configuration files and platform depended properties.
 java.sql.Connection lookupConnection(JdbcConnectionDescriptor jcd)
          Lookup a connection from the connection factory implementation.
protected  java.sql.Connection newConnectionFromDataSource(JdbcConnectionDescriptor jcd)
           
protected  java.sql.Connection newConnectionFromDriverManager(JdbcConnectionDescriptor jcd)
          Returns a new created connection
 void releaseAllResources()
          Override this method to do cleanup in your implenetation.
 void releaseConnection(JdbcConnectionDescriptor jcd, java.sql.Connection con)
          Release connection - CAUTION: Release every connection after use to avoid abandoned connections.
abstract  void returnConnectionToPool(JdbcConnectionDescriptor jcd, java.sql.Connection con)
          Implement this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionFactoryAbstractImpl

public ConnectionFactoryAbstractImpl()
Method Detail

getConnectionFromPool

public abstract java.sql.Connection getConnectionFromPool(JdbcConnectionDescriptor jcd)
                                                   throws LookupException
Implement this method. This method was called to obtain a jdbc-connection from the pool.
Note: This method was not called, if jdbc-connection-descriptor use datasources - OJB only pool connections from DriverManager.

Throws:
LookupException

returnConnectionToPool

public abstract void returnConnectionToPool(JdbcConnectionDescriptor jcd,
                                            java.sql.Connection con)
                                     throws LookupException
Implement this method. Was called to return a connection to pool.
Note: This method was not called, if the jdbc-connection-descriptor uses datasources - OJB only pool connections from DriverManager.

Throws:
LookupException

releaseConnection

public void releaseConnection(JdbcConnectionDescriptor jcd,
                              java.sql.Connection con)
Description copied from interface: ConnectionFactory
Release connection - CAUTION: Release every connection after use to avoid abandoned connections. Depending on the used implementation connection will be closed, returned to pool, ...

Specified by:
releaseConnection in interface ConnectionFactory

lookupConnection

public java.sql.Connection lookupConnection(JdbcConnectionDescriptor jcd)
                                     throws LookupException
Description copied from interface: ConnectionFactory
Lookup a connection from the connection factory implementation.

Specified by:
lookupConnection in interface ConnectionFactory
Throws:
LookupException

initializeJdbcConnection

protected void initializeJdbcConnection(java.sql.Connection con,
                                        JdbcConnectionDescriptor jcd)
                                 throws LookupException
Initialize the connection with the specified properties in OJB configuration files and platform depended properties. Invoke this method after a NEW connection was created.

Throws:
LookupException
See Also:
PlatformFactory, Platform

releaseAllResources

public void releaseAllResources()
Override this method to do cleanup in your implenetation. Do a super.releaseAllResources() in your method implementation to free resources used by this class.

Specified by:
releaseAllResources in interface ConnectionFactory

newConnectionFromDataSource

protected java.sql.Connection newConnectionFromDataSource(JdbcConnectionDescriptor jcd)
                                                   throws LookupException
Parameters:
jcd -
Returns:
an instance of Connection from the named Datasource
Throws:
LookupException - if we can't get a connection from the datasource either due to a naming exception, a failed sanity check, or a SQLException.

newConnectionFromDriverManager

protected java.sql.Connection newConnectionFromDriverManager(JdbcConnectionDescriptor jcd)
                                                      throws LookupException
Returns a new created connection

Parameters:
jcd - the connection descriptor
Returns:
an instance of Connection from the drivermanager
Throws:
LookupException

getDbURL

protected java.lang.String getDbURL(JdbcConnectionDescriptor jcd)


Authors: Thomas Mahler and others. (C) 2000 - 2003 Apache Software Foundation
All rights reserved. Published under the Apache License.
http://db.apache.org/ojb
Version: 1.0.rc5, 2003-12-14