com.sun.enterprise.transaction
Class JavaEETransactionImpl

java.lang.Object
  extended by java.util.TimerTask
      extended by com.sun.enterprise.transaction.JavaEETransactionImpl
All Implemented Interfaces:
JavaEETransaction, java.lang.Runnable, Transaction

public final class JavaEETransactionImpl
extends java.util.TimerTask
implements JavaEETransaction

This class implements the JTA Transaction API for the J2EE RI. It is a wrapper over the JTS Transaction object that provides optimized local transaction support when a transaction uses zero/one non-XA resource, and delegates to JTS otherwise. This object can be in two states: local tx (jtsTx==null) or global (JTS) tx. If jtsTx!=null, all calls are delegated to jtsTx. Time out capability is added to the local transactions. This class extends the TimerTask. When the transaction needs to be timedout, this schedules with the timer. At the commit and rollback time, task will be cancelled. If the transaction is timedout, run() method will be called and transaction will be marked for rollback.


Method Summary
 void addExtendedEntityManagerMapping(javax.persistence.EntityManagerFactory emf, javax.persistence.EntityManager em)
           
 void addTxEntityManagerMapping(javax.persistence.EntityManagerFactory emf, javax.persistence.EntityManager em)
           
 int cancelTimerTask()
           
 void commit()
           
 boolean delistResource(XAResource xaRes, int flag)
           
 boolean enlistResource(XAResource xaRes)
           
 boolean equals(java.lang.Object other)
           
 java.lang.Object getActiveTxCache()
           
 java.util.Set getAllParticipatingPools()
          Return all pools registered in the resourceTable.
 java.lang.Object getContainerData()
           
 javax.persistence.EntityManager getExtendedEntityManager(javax.persistence.EntityManagerFactory emf)
           
 TransactionalResource getLAOResource()
           
 TransactionalResource getNonXAResource()
           
 int getRemainingTimeout()
          Return duration in seconds before transaction would timeout.
 java.util.Set getResources(java.lang.Object poolInfo)
           
 long getStartTime()
           
 int getStatus()
           
 java.lang.String getTransactionId()
           
 javax.persistence.EntityManager getTxEntityManager(javax.persistence.EntityManagerFactory emf)
           
 int hashCode()
           
 boolean isLocalTx()
           
 boolean isTimedOut()
           
protected  void onTxCompletion(boolean status)
           
 void registerSynchronization(Synchronization sync)
           
 void removeExtendedEntityManagerMapping(javax.persistence.EntityManagerFactory emf)
           
 void rollback()
           
 void run()
           
 void setActiveTxCache(java.lang.Object cache)
           
 void setContainerData(java.lang.Object data)
           
 void setLAOResource(TransactionalResource h)
           
 void setResources(java.util.Set resources, java.lang.Object poolInfo)
           
 void setRollbackOnly()
           
 java.lang.String toString()
           
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable
Specified by:
run in class java.util.TimerTask

getContainerData

public java.lang.Object getContainerData()
Specified by:
getContainerData in interface JavaEETransaction

setContainerData

public void setContainerData(java.lang.Object data)
Specified by:
setContainerData in interface JavaEETransaction

cancelTimerTask

public int cancelTimerTask()

isTimedOut

public boolean isTimedOut()
Specified by:
isTimedOut in interface JavaEETransaction

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getNonXAResource

public TransactionalResource getNonXAResource()
Specified by:
getNonXAResource in interface JavaEETransaction

getLAOResource

public TransactionalResource getLAOResource()
Specified by:
getLAOResource in interface JavaEETransaction

setLAOResource

public void setLAOResource(TransactionalResource h)
Specified by:
setLAOResource in interface JavaEETransaction

addTxEntityManagerMapping

public void addTxEntityManagerMapping(javax.persistence.EntityManagerFactory emf,
                                      javax.persistence.EntityManager em)
Specified by:
addTxEntityManagerMapping in interface JavaEETransaction

getTxEntityManager

public javax.persistence.EntityManager getTxEntityManager(javax.persistence.EntityManagerFactory emf)
Specified by:
getTxEntityManager in interface JavaEETransaction

onTxCompletion

protected void onTxCompletion(boolean status)

addExtendedEntityManagerMapping

public void addExtendedEntityManagerMapping(javax.persistence.EntityManagerFactory emf,
                                            javax.persistence.EntityManager em)
Specified by:
addExtendedEntityManagerMapping in interface JavaEETransaction

removeExtendedEntityManagerMapping

public void removeExtendedEntityManagerMapping(javax.persistence.EntityManagerFactory emf)
Specified by:
removeExtendedEntityManagerMapping in interface JavaEETransaction

getExtendedEntityManager

public javax.persistence.EntityManager getExtendedEntityManager(javax.persistence.EntityManagerFactory emf)
Specified by:
getExtendedEntityManager in interface JavaEETransaction

isLocalTx

public boolean isLocalTx()
Specified by:
isLocalTx in interface JavaEETransaction

commit

public void commit()
            throws RollbackException,
                   HeuristicMixedException,
                   HeuristicRollbackException,
                   java.lang.SecurityException,
                   java.lang.IllegalStateException,
                   SystemException
Specified by:
commit in interface Transaction
Throws:
RollbackException
HeuristicMixedException
HeuristicRollbackException
java.lang.SecurityException
java.lang.IllegalStateException
SystemException

rollback

public void rollback()
              throws java.lang.IllegalStateException,
                     SystemException
Specified by:
rollback in interface Transaction
Throws:
java.lang.IllegalStateException
SystemException

delistResource

public boolean delistResource(XAResource xaRes,
                              int flag)
                       throws java.lang.IllegalStateException,
                              SystemException
Specified by:
delistResource in interface Transaction
Throws:
java.lang.IllegalStateException
SystemException

enlistResource

public boolean enlistResource(XAResource xaRes)
                       throws RollbackException,
                              java.lang.IllegalStateException,
                              SystemException
Specified by:
enlistResource in interface Transaction
Throws:
RollbackException
java.lang.IllegalStateException
SystemException

getStatus

public int getStatus()
              throws SystemException
Specified by:
getStatus in interface Transaction
Throws:
SystemException

registerSynchronization

public void registerSynchronization(Synchronization sync)
                             throws RollbackException,
                                    java.lang.IllegalStateException,
                                    SystemException
Specified by:
registerSynchronization in interface Transaction
Throws:
RollbackException
java.lang.IllegalStateException
SystemException

setRollbackOnly

public void setRollbackOnly()
                     throws java.lang.IllegalStateException,
                            SystemException
Specified by:
setRollbackOnly in interface Transaction
Throws:
java.lang.IllegalStateException
SystemException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getTransactionId

public java.lang.String getTransactionId()

getStartTime

public long getStartTime()

setResources

public void setResources(java.util.Set resources,
                         java.lang.Object poolInfo)
Specified by:
setResources in interface JavaEETransaction

getResources

public java.util.Set getResources(java.lang.Object poolInfo)
Specified by:
getResources in interface JavaEETransaction

getAllParticipatingPools

public java.util.Set getAllParticipatingPools()
Return all pools registered in the resourceTable. This will cut down the scope of pools on which transactionComplted is called by the PoolManagerImpl. This method will return only those pools that have ever participated in a tx

Specified by:
getAllParticipatingPools in interface JavaEETransaction

setActiveTxCache

public void setActiveTxCache(java.lang.Object cache)

getActiveTxCache

public java.lang.Object getActiveTxCache()

getRemainingTimeout

public int getRemainingTimeout()
Return duration in seconds before transaction would timeout. Returns zero if this transaction has no timeout set. Returns negative value if already timed out.



Copyright © 2012 GlassFish Community. All Rights Reserved.