cuba.wired
Class PrimitiveTransaction

java.lang.Object
  extended by cuba.wired.PrimitiveTransaction
All Implemented Interfaces:
WiredTransactionI, javax.transaction.Transaction

public class PrimitiveTransaction
extends java.lang.Object
implements WiredTransactionI

Author:
Jan Lessner

Field Summary
 
Fields inherited from interface cuba.wired.WiredTransactionI
CLIENT_MANAGED, COMPONENT_MANAGED, CONTAINER_MANAGED
 
Method Summary
 CubaEntityManager allocateEntityManager(ResourceFactoryI factory)
           
 WiredManagedConnection allocateResource(ResourceFactoryI factory)
           
protected  void assertTxActive()
           
 int beginTransaction()
           
 void commit()
           
 int commitTransaction()
           
 boolean delistResource(javax.transaction.xa.XAResource arg0, int arg1)
           
protected  int end(boolean commit)
           
 boolean enlistResource(javax.transaction.xa.XAResource arg0)
           
 int getManagerType()
           
 int getStatus()
           
 void registerStateSynchronization(StateSynchronizationI sync)
          Check if the passed StateSynchronizationI object has already been registered.
 void registerSynchronization(javax.transaction.Synchronization sync)
           
 void releaseResource(ResourceFactoryI factory, WiredManagedConnection con)
           
 void rollback()
           
 int rollbackTransaction()
           
 void separate()
          Markes this transaction manager to work as a separator between the current transaction and potential following ones.
 void setRollbackOnly()
           
protected  void synchronize(boolean commit)
           
protected  void synchronizePhase1()
           
protected  void synchronizePhase2(int tempStatus, int endStatus)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

allocateResource

public WiredManagedConnection allocateResource(ResourceFactoryI factory)
                                        throws java.sql.SQLException
Specified by:
allocateResource in interface WiredTransactionI
Throws:
java.sql.SQLException

allocateEntityManager

public CubaEntityManager allocateEntityManager(ResourceFactoryI factory)
                                        throws ConstructionException
Specified by:
allocateEntityManager in interface WiredTransactionI
Throws:
ConstructionException

releaseResource

public void releaseResource(ResourceFactoryI factory,
                            WiredManagedConnection con)
Specified by:
releaseResource in interface WiredTransactionI

registerStateSynchronization

public void registerStateSynchronization(StateSynchronizationI sync)
                                  throws javax.transaction.SystemException
Check if the passed StateSynchronizationI object has already been registered. If not, run it's StateSynchronizationI.afterBegin() method and add it to the list of Synchronizations which will be informed about the end of the running transaction. The check is a sequential list search and therefore not very efficient. It is recommended to keep from calling this function without need.

Specified by:
registerStateSynchronization in interface WiredTransactionI
Throws:
javax.transaction.SystemException

separate

public void separate()
              throws javax.transaction.SystemException
Description copied from interface: WiredTransactionI
Markes this transaction manager to work as a separator between the current transaction and potential following ones. This function is used to provide propper NotSupported semantic.

Specified by:
separate in interface WiredTransactionI
Throws:
javax.transaction.SystemException

beginTransaction

public int beginTransaction()
                     throws javax.transaction.SystemException
Specified by:
beginTransaction in interface WiredTransactionI
Throws:
javax.transaction.SystemException

assertTxActive

protected void assertTxActive()
                       throws java.lang.IllegalStateException
Throws:
java.lang.IllegalStateException

synchronizePhase1

protected void synchronizePhase1()

synchronizePhase2

protected void synchronizePhase2(int tempStatus,
                                 int endStatus)

synchronize

protected void synchronize(boolean commit)

end

protected int end(boolean commit)
           throws javax.transaction.SystemException
Throws:
javax.transaction.SystemException

commit

public void commit()
            throws javax.transaction.SystemException
Specified by:
commit in interface javax.transaction.Transaction
Throws:
javax.transaction.SystemException

rollback

public void rollback()
              throws javax.transaction.SystemException
Specified by:
rollback in interface javax.transaction.Transaction
Throws:
javax.transaction.SystemException

setRollbackOnly

public void setRollbackOnly()
                     throws javax.transaction.SystemException
Specified by:
setRollbackOnly in interface javax.transaction.Transaction
Throws:
javax.transaction.SystemException

getStatus

public int getStatus()
Specified by:
getStatus in interface javax.transaction.Transaction

getManagerType

public int getManagerType()
Specified by:
getManagerType in interface WiredTransactionI

registerSynchronization

public void registerSynchronization(javax.transaction.Synchronization sync)
                             throws javax.transaction.SystemException
Specified by:
registerSynchronization in interface javax.transaction.Transaction
Throws:
javax.transaction.SystemException

enlistResource

public boolean enlistResource(javax.transaction.xa.XAResource arg0)
                       throws javax.transaction.SystemException
Specified by:
enlistResource in interface javax.transaction.Transaction
Throws:
javax.transaction.SystemException

delistResource

public boolean delistResource(javax.transaction.xa.XAResource arg0,
                              int arg1)
                       throws java.lang.IllegalStateException,
                              javax.transaction.SystemException
Specified by:
delistResource in interface javax.transaction.Transaction
Throws:
java.lang.IllegalStateException
javax.transaction.SystemException

commitTransaction

public int commitTransaction()
                      throws javax.transaction.SystemException
Specified by:
commitTransaction in interface WiredTransactionI
Throws:
javax.transaction.SystemException

rollbackTransaction

public int rollbackTransaction()
                        throws javax.transaction.SystemException
Specified by:
rollbackTransaction in interface WiredTransactionI
Throws:
javax.transaction.SystemException