org.objectweb.easybeans.persistence
Class TxEntityManagerLifeCycle

java.lang.Object
  extended by org.objectweb.easybeans.persistence.TxEntityManagerLifeCycle
All Implemented Interfaces:
javax.transaction.Synchronization

public class TxEntityManagerLifeCycle
extends java.lang.Object
implements javax.transaction.Synchronization

This class manages the lifecycle of an entity manager with transaction scoped persistence context. It means that it should be closed when the transaction is committed or rollbacked.

Author:
Florent Benoit

Field Summary
private  javax.persistence.EntityManager entityManager
          Entity manager that is referenced.
private  javax.transaction.Transaction tx
          Tx's association to release.
private  TxEntityManagerHandler txEntityManagerHandler
          Handler that manages tx entity manager (to release the tx).
 
Constructor Summary
TxEntityManagerLifeCycle(javax.persistence.EntityManager entityManager, javax.transaction.Transaction tx, TxEntityManagerHandler txEntityManagerHandler)
           
 
Method Summary
 void afterCompletion(int status)
          This method is called by the transaction manager after the transaction is committed or rolled back.
 void beforeCompletion()
          The beforeCompletion method is called by the transaction manager prior to the start of the two-phase transaction commit process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entityManager

private javax.persistence.EntityManager entityManager
Entity manager that is referenced.


txEntityManagerHandler

private TxEntityManagerHandler txEntityManagerHandler
Handler that manages tx entity manager (to release the tx).


tx

private javax.transaction.Transaction tx
Tx's association to release.

Constructor Detail

TxEntityManagerLifeCycle

public TxEntityManagerLifeCycle(javax.persistence.EntityManager entityManager,
                                javax.transaction.Transaction tx,
                                TxEntityManagerHandler txEntityManagerHandler)
Parameters:
entityManager - Entity manager that is managed (lifecycle).
tx - the transaction that needs to be released in the handler.
txEntityManagerHandler - handler on which release association with TX
Method Detail

beforeCompletion

public void beforeCompletion()
The beforeCompletion method is called by the transaction manager prior to the start of the two-phase transaction commit process. This call is executed with the transaction context of the transaction that is being committed.

Specified by:
beforeCompletion in interface javax.transaction.Synchronization

afterCompletion

public void afterCompletion(int status)
This method is called by the transaction manager after the transaction is committed or rolled back.

Specified by:
afterCompletion in interface javax.transaction.Synchronization
Parameters:
status - The status of the transaction completion.