org.apache.ojb.broker.accesslayer
Class ConnectionManagerImpl

java.lang.Object
  extended by org.apache.ojb.broker.accesslayer.ConnectionManagerImpl
All Implemented Interfaces:
ConnectionManagerIF

public class ConnectionManagerImpl
extends Object
implements ConnectionManagerIF

Manages Connection ressources.

Version:
$Id: ConnectionManagerImpl.java,v 1.1 2007-08-24 22:17:30 ewestfal Exp $
Author:
Thomas Mahler
See Also:
ConnectionManagerIF

Constructor Summary
ConnectionManagerImpl(PersistenceBroker broker)
           
 
Method Summary
 void clearBatch()
          Clear batch (if the batch mode where used).
 void executeBatch()
          Execute batch (if the batch mode where used).
 void executeBatchIfNecessary()
          Execute batch if the number of statements in it exceeded the limit (if the batch mode where used).
 Connection getConnection()
          Returns the underlying connection, requested from ConnectionFactory.
 JdbcConnectionDescriptor getConnectionDescriptor()
          Returns the associated JdbcConnectionDescriptor
 Platform getSupportedPlatform()
          Returns the supported Platform determined by the JdbcConnectionDescriptor.
 ConnectionFactory getUnderlyingConnectionFactory()
          Returns the underlying used ConnectionFactory implementation.
 boolean isAlive(Connection conn)
          Check if underlying connection was alive.
 boolean isBatchMode()
           
 boolean isInLocalTransaction()
          Hold connection is in local transaction.
 void localBegin()
          Start transaction on the underlying connection.
 void localCommit()
          Call commit on the underlying connection.
 void localRollback()
          Call rollback on the underlying connection.
 void releaseConnection()
          Release connection to the ConnectionFactory, make sure that you call the method in either case, it's the only way to free the connection.
protected  void restoreAutoCommitState()
          Reset autoCommit state.
 void setBatchMode(boolean mode)
          Sets the batch mode on or off - this switch only works if you set attribute batch-mode in jdbc-connection-descriptor true and your database support batch mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionManagerImpl

public ConnectionManagerImpl(PersistenceBroker broker)
Method Detail

getConnectionDescriptor

public JdbcConnectionDescriptor getConnectionDescriptor()
Returns the associated JdbcConnectionDescriptor

Specified by:
getConnectionDescriptor in interface ConnectionManagerIF

getSupportedPlatform

public Platform getSupportedPlatform()
Description copied from interface: ConnectionManagerIF
Returns the supported Platform determined by the JdbcConnectionDescriptor.

Specified by:
getSupportedPlatform in interface ConnectionManagerIF
See Also:
ConnectionManagerIF.getConnectionDescriptor()

getConnection

public Connection getConnection()
                         throws LookupException
Returns the underlying connection, requested from ConnectionFactory.

PB#beginTransaction() opens a single jdbc connection via PB#serviceConnectionManager().localBegin(). If you call PB#serviceConnectionManager().getConnection() later it returns the already opened connection. The PB instance will release the used connection during PB#commitTransaction() or PB#abortTransaction() or PB#close().

NOTE: Never call Connection.close() on the connection requested from the ConnectionManager. Cleanup of used connection is done by OJB itself. If you need to release a used connection call releaseConnection().

Specified by:
getConnection in interface ConnectionManagerIF
Throws:
LookupException

localBegin

public void localBegin()
Start transaction on the underlying connection.

Specified by:
localBegin in interface ConnectionManagerIF

localCommit

public void localCommit()
Call commit on the underlying connection.

Specified by:
localCommit in interface ConnectionManagerIF

localRollback

public void localRollback()
Call rollback on the underlying connection.

Specified by:
localRollback in interface ConnectionManagerIF

restoreAutoCommitState

protected void restoreAutoCommitState()
Reset autoCommit state.


isAlive

public boolean isAlive(Connection conn)
Check if underlying connection was alive.

Specified by:
isAlive in interface ConnectionManagerIF

isInLocalTransaction

public boolean isInLocalTransaction()
Description copied from interface: ConnectionManagerIF
Hold connection is in local transaction.

Specified by:
isInLocalTransaction in interface ConnectionManagerIF

releaseConnection

public void releaseConnection()
Release connection to the ConnectionFactory, make sure that you call the method in either case, it's the only way to free the connection.

Specified by:
releaseConnection in interface ConnectionManagerIF

getUnderlyingConnectionFactory

public ConnectionFactory getUnderlyingConnectionFactory()
Returns the underlying used ConnectionFactory implementation.


setBatchMode

public void setBatchMode(boolean mode)
Sets the batch mode on or off - this switch only works if you set attribute batch-mode in jdbc-connection-descriptor true and your database support batch mode.

Specified by:
setBatchMode in interface ConnectionManagerIF
Parameters:
mode - the batch mode

isBatchMode

public boolean isBatchMode()
Specified by:
isBatchMode in interface ConnectionManagerIF
Returns:
the batch mode.

executeBatch

public void executeBatch()
                  throws OJBBatchUpdateException
Execute batch (if the batch mode where used).

Specified by:
executeBatch in interface ConnectionManagerIF
Throws:
OJBBatchUpdateException

executeBatchIfNecessary

public void executeBatchIfNecessary()
                             throws OJBBatchUpdateException
Execute batch if the number of statements in it exceeded the limit (if the batch mode where used).

Specified by:
executeBatchIfNecessary in interface ConnectionManagerIF
Throws:
OJBBatchUpdateException

clearBatch

public void clearBatch()
Clear batch (if the batch mode where used).

Specified by:
clearBatch in interface ConnectionManagerIF


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.