org.objectweb.speedo.mapper.rdb
Class JDBCConnectionHolder

java.lang.Object
  extended byorg.objectweb.speedo.mapper.rdb.JDBCConnectionHolder
All Implemented Interfaces:
org.objectweb.perseus.persistence.api.ConnectionHolder

public class JDBCConnectionHolder
extends java.lang.Object
implements org.objectweb.perseus.persistence.api.ConnectionHolder

Is an holder of JDBC connection. It can works in managed or non-managed transactional environnement.

Author:
S.Chassande-Barrioz

Field Summary
protected  java.sql.Connection connection
          The SQL connection held.
protected  org.objectweb.util.monolog.api.Logger logger
           
protected  org.objectweb.jorm.api.PMapper mapper
          the mapper allocating JDBC connections
protected  boolean transactional
          Indicates the access through the connection must be done inside a transaction.
protected  boolean txManagedExternaly
          Indicates if the transaction demarcations must tbe done by the ConnectionHolder or there are already done by an environment (an Application Server for example).
protected  org.objectweb.perseus.persistence.api.WorkingSet workingSet
          The workingSet attached to this connection holder
 
Constructor Summary
JDBCConnectionHolder(org.objectweb.jorm.api.PMapper mapper, org.objectweb.util.monolog.api.Logger logger)
           
 
Method Summary
 void begin()
          If there is no connection already allocated, the transaction being will be during the next connection request (getConnectionFor...(...)
protected  void beginLocalTransaction()
          Primitive method demarcating the begining of a local transaction on the current connection.
 void bindWorkingSet(org.objectweb.perseus.persistence.api.WorkingSet workingSet)
           
 void closeCHConnection()
           
 void commitCH()
           
protected  void commitLocalTransaction()
          primitive method demarcating the end of a local transaction by a commit
 java.lang.Object getCHConnectionForRead()
           
 java.lang.Object getCHConnectionForWrite()
           
 org.objectweb.perseus.persistence.api.WorkingSet getWorkingSet()
           
 void releaseCHConnection()
           
 void rollbackCH()
           
protected  void rollbackLocalTransaction()
          primitive method demarcating the end of a local transaction by a rollback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapper

protected org.objectweb.jorm.api.PMapper mapper
the mapper allocating JDBC connections


workingSet

protected org.objectweb.perseus.persistence.api.WorkingSet workingSet
The workingSet attached to this connection holder


connection

protected java.sql.Connection connection
The SQL connection held. Can be null if no connectioin has been used


transactional

protected boolean transactional
Indicates the access through the connection must be done inside a transaction.


txManagedExternaly

protected boolean txManagedExternaly
Indicates if the transaction demarcations must tbe done by the ConnectionHolder or there are already done by an environment (an Application Server for example).


logger

protected org.objectweb.util.monolog.api.Logger logger
Constructor Detail

JDBCConnectionHolder

public JDBCConnectionHolder(org.objectweb.jorm.api.PMapper mapper,
                            org.objectweb.util.monolog.api.Logger logger)
Method Detail

beginLocalTransaction

protected void beginLocalTransaction()
                              throws org.objectweb.perseus.persistence.api.PersistenceException
Primitive method demarcating the begining of a local transaction on the current connection.

Throws:
org.objectweb.perseus.persistence.api.PersistenceException

commitLocalTransaction

protected void commitLocalTransaction()
                               throws org.objectweb.perseus.persistence.api.PersistenceException
primitive method demarcating the end of a local transaction by a commit

Throws:
org.objectweb.perseus.persistence.api.PersistenceException

rollbackLocalTransaction

protected void rollbackLocalTransaction()
                                 throws org.objectweb.perseus.persistence.api.PersistenceException
primitive method demarcating the end of a local transaction by a rollback

Throws:
org.objectweb.perseus.persistence.api.PersistenceException

getWorkingSet

public org.objectweb.perseus.persistence.api.WorkingSet getWorkingSet()
Specified by:
getWorkingSet in interface org.objectweb.perseus.persistence.api.ConnectionHolder

bindWorkingSet

public void bindWorkingSet(org.objectweb.perseus.persistence.api.WorkingSet workingSet)
Specified by:
bindWorkingSet in interface org.objectweb.perseus.persistence.api.ConnectionHolder

getCHConnectionForRead

public java.lang.Object getCHConnectionForRead()
                                        throws org.objectweb.perseus.persistence.api.PersistenceException
Specified by:
getCHConnectionForRead in interface org.objectweb.perseus.persistence.api.ConnectionHolder
Throws:
org.objectweb.perseus.persistence.api.PersistenceException

getCHConnectionForWrite

public java.lang.Object getCHConnectionForWrite()
                                         throws org.objectweb.perseus.persistence.api.PersistenceException
Specified by:
getCHConnectionForWrite in interface org.objectweb.perseus.persistence.api.ConnectionHolder
Throws:
org.objectweb.perseus.persistence.api.PersistenceException

begin

public void begin()
           throws org.objectweb.perseus.persistence.api.PersistenceException
If there is no connection already allocated, the transaction being will be during the next connection request (getConnectionFor...(...)

Specified by:
begin in interface org.objectweb.perseus.persistence.api.ConnectionHolder
Throws:
org.objectweb.perseus.persistence.api.PersistenceException

commitCH

public void commitCH()
              throws org.objectweb.perseus.persistence.api.PersistenceException
Specified by:
commitCH in interface org.objectweb.perseus.persistence.api.ConnectionHolder
Throws:
org.objectweb.perseus.persistence.api.PersistenceException

rollbackCH

public void rollbackCH()
                throws org.objectweb.perseus.persistence.api.PersistenceException
Specified by:
rollbackCH in interface org.objectweb.perseus.persistence.api.ConnectionHolder
Throws:
org.objectweb.perseus.persistence.api.PersistenceException

releaseCHConnection

public void releaseCHConnection()
                         throws org.objectweb.perseus.persistence.api.PersistenceException
Specified by:
releaseCHConnection in interface org.objectweb.perseus.persistence.api.ConnectionHolder
Throws:
org.objectweb.perseus.persistence.api.PersistenceException

closeCHConnection

public void closeCHConnection()
                       throws org.objectweb.perseus.persistence.api.PersistenceException
Specified by:
closeCHConnection in interface org.objectweb.perseus.persistence.api.ConnectionHolder
Throws:
org.objectweb.perseus.persistence.api.PersistenceException