jodd.db.jtx
Class DbJtxResourceManager

java.lang.Object
  extended by jodd.db.jtx.DbJtxResourceManager
All Implemented Interfaces:
JtxResourceManager<DbSession>

public class DbJtxResourceManager
extends java.lang.Object
implements JtxResourceManager<DbSession>

Database JtxResourceManager manages life-cycle of DbSession resources. Also acts as an adapter of resource object (of any type) and JTX engine.

Transaction resources may be of any type. The only thing what is important is that resource must be aware of its transactional state - is it in no-transactional mode (i.e. auto-commit), or under the transaction.


Field Summary
protected  ConnectionProvider connectionProvider
           
 
Constructor Summary
DbJtxResourceManager(ConnectionProvider connectionProvider)
          Creates resource manager.
 
Method Summary
 DbSession beginTransaction(JtxTransactionMode txMode)
          Creates new resource and begins new transaction if specified so by propagation behavior.
 void close()
          Closes manager and free its resources.
 void commitTransaction(DbSession resource)
          Commits resource and closes it if committing was successful.
 java.lang.Class<DbSession> getResourceType()
          Returns associated resource type.
 void rollbackTransaction(DbSession resource)
          Rollback resource and closes it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectionProvider

protected final ConnectionProvider connectionProvider
Constructor Detail

DbJtxResourceManager

public DbJtxResourceManager(ConnectionProvider connectionProvider)
Creates resource manager.

Method Detail

getResourceType

public java.lang.Class<DbSession> getResourceType()
Returns associated resource type.

Specified by:
getResourceType in interface JtxResourceManager<DbSession>

beginTransaction

public DbSession beginTransaction(JtxTransactionMode txMode)
Creates new resource and begins new transaction if specified so by propagation behavior.

Specified by:
beginTransaction in interface JtxResourceManager<DbSession>

commitTransaction

public void commitTransaction(DbSession resource)
Commits resource and closes it if committing was successful.

Specified by:
commitTransaction in interface JtxResourceManager<DbSession>

rollbackTransaction

public void rollbackTransaction(DbSession resource)
Rollback resource and closes it. Resource is closed no matter if rolling back fails.

Specified by:
rollbackTransaction in interface JtxResourceManager<DbSession>

close

public void close()
Closes manager and free its resources.

Specified by:
close in interface JtxResourceManager<DbSession>


Copyright ©2008 Jodd Team