org.datanucleus
Class TransactionImpl

java.lang.Object
  extended by org.datanucleus.TransactionImpl
All Implemented Interfaces:
Transaction
Direct Known Subclasses:
JTAJCATransactionImpl, JTATransactionImpl

public class TransactionImpl
extends java.lang.Object
implements Transaction

Implementation of a transaction for a datastore. Transaction

Version:
$Revision: 1.34 $

Field Summary
protected static Localiser LOCALISER
          Localisation of messages.
protected  boolean nontransactionalRead
          Whether non-tx read is enabled.
protected  boolean nontransactionalWrite
          Whether non-tx write is enabled.
protected  boolean optimistic
          Whether the transaction is optimistic
protected  boolean restoreValues
          Whether restoreValues is enabled.
protected  boolean retainValues
          Whether retainValues is enabled.
protected  boolean rollbackOnly
          Whether the transaction is marked for rollback.
 
Method Summary
 void addTransactionEventListener(TransactionEventListener listener)
           
 void begin()
          Method to begin the transaction.
 void commit()
          Method to commit the transaction.
 void end()
          Method to allow the transaction to flush any resources.
 void flush()
          Method to flush the transaction.
 boolean getNontransactionalRead()
          Accessor for the nontransactionalRead flag for this transaction.
 boolean getNontransactionalWrite()
          Accessor for the nontransactionalWrite flag for this transaction.
 boolean getOptimistic()
          Accessor for the Optimistic setting
 java.util.Map getOptions()
          Obtain all settings for this Transaction
 boolean getRestoreValues()
          Accessor for the restoreValues flag for this transaction.
 boolean getRetainValues()
          Accessor for the retainValues flag for this transaction.
 boolean getRollbackOnly()
          Accessor for the "rollback only" flag.
 javax.transaction.Synchronization getSynchronization()
          Accessor for the synchronization object to be notified on transaction completion.
protected  void internalBegin()
          Method to begin the transaction.
protected  void internalCommit()
          Internal commit, JPOX invokes it's own transaction manager implementation, if an external transaction manager is not used.
protected  void internalPostCommit()
          Method to perform any post-commit operations like calling the users "afterCompletion" and general clean up after the commit.
protected  void internalPreCommit()
          Method to perform any pre-commit operations like flushing to the datastore, calling the users "beforeCompletion", and general preparation for the commit.
protected  void internalPreRollback()
          Call om.preRollback() and listeners.
protected  void internalRollback()
          Internal rollback, JPOX invokes it's own transaction manager implementation, if an external transaction manager is not used.
 boolean isActive()
          Accessor for whether the transaction is active.
 boolean isCommitting()
          Accessor for whether the transaction is comitting.
 void removeTransactionEventListener(TransactionEventListener listener)
           
 void rollback()
          Method to rollback the transaction.
 void setNontransactionalRead(boolean nontransactionalRead)
          Mutator for the setting of nontransactional read.
 void setNontransactionalWrite(boolean nontransactionalWrite)
          Mutator for the setting of nontransactional write.
 void setOptimistic(boolean optimistic)
          Mutator for the optimistic transaction setting.
 void setOption(java.lang.String option, boolean value)
           
 void setOption(java.lang.String option, int value)
           
 void setOption(java.lang.String option, java.lang.String value)
           
 void setRestoreValues(boolean restoreValues)
          Mutator for the setting of restore values.
 void setRetainValues(boolean retainValues)
          Mutator for the setting of retain values.
 void setRollbackOnly()
          Mutator for the "rollback only" flag.
 void setSynchronization(javax.transaction.Synchronization sync)
          Mutator for the synchronization object to be notified on transaction completion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Localisation of messages.


retainValues

protected boolean retainValues
Whether retainValues is enabled.


restoreValues

protected boolean restoreValues
Whether restoreValues is enabled.


optimistic

protected boolean optimistic
Whether the transaction is optimistic


nontransactionalRead

protected boolean nontransactionalRead
Whether non-tx read is enabled.


nontransactionalWrite

protected boolean nontransactionalWrite
Whether non-tx write is enabled.


rollbackOnly

protected boolean rollbackOnly
Whether the transaction is marked for rollback. JDO 2.0 section 13.4.5

Method Detail

begin

public void begin()
Method to begin the transaction.

Specified by:
begin in interface Transaction

internalBegin

protected void internalBegin()
Method to begin the transaction.


flush

public void flush()
Method to flush the transaction.

Specified by:
flush in interface Transaction

end

public void end()
Method to allow the transaction to flush any resources.

Specified by:
end in interface Transaction

commit

public void commit()
Method to commit the transaction.

Specified by:
commit in interface Transaction

internalPreCommit

protected void internalPreCommit()
Method to perform any pre-commit operations like flushing to the datastore, calling the users "beforeCompletion", and general preparation for the commit.


internalCommit

protected void internalCommit()
Internal commit, JPOX invokes it's own transaction manager implementation, if an external transaction manager is not used.


rollback

public void rollback()
Method to rollback the transaction.

Specified by:
rollback in interface Transaction

internalPreRollback

protected void internalPreRollback()
Call om.preRollback() and listeners.


internalRollback

protected void internalRollback()
Internal rollback, JPOX invokes it's own transaction manager implementation, if an external transaction manager is not used.


internalPostCommit

protected void internalPostCommit()
Method to perform any post-commit operations like calling the users "afterCompletion" and general clean up after the commit.


isActive

public boolean isActive()
Accessor for whether the transaction is active.

Specified by:
isActive in interface Transaction
Returns:
Whether the transaction is active.

isCommitting

public boolean isCommitting()
Accessor for whether the transaction is comitting.

Specified by:
isCommitting in interface Transaction
Returns:
Whether the transaction is committing.

getNontransactionalRead

public boolean getNontransactionalRead()
Accessor for the nontransactionalRead flag for this transaction.

Specified by:
getNontransactionalRead in interface Transaction
Returns:
Whether nontransactionalRead is set.

getNontransactionalWrite

public boolean getNontransactionalWrite()
Accessor for the nontransactionalWrite flag for this transaction.

Specified by:
getNontransactionalWrite in interface Transaction
Returns:
Whether nontransactionalWrite is set.

getOptimistic

public boolean getOptimistic()
Accessor for the Optimistic setting

Specified by:
getOptimistic in interface Transaction
Returns:
Whether optimistic transactions are in operation.

getRestoreValues

public boolean getRestoreValues()
Accessor for the restoreValues flag for this transaction.

Specified by:
getRestoreValues in interface Transaction
Returns:
Whether restoreValues is set.

getRetainValues

public boolean getRetainValues()
Accessor for the retainValues flag for this transaction.

Specified by:
getRetainValues in interface Transaction
Returns:
Whether retainValues is set.

getRollbackOnly

public boolean getRollbackOnly()
Accessor for the "rollback only" flag.

Specified by:
getRollbackOnly in interface Transaction
Returns:
The rollback only flag
Since:
1.1

getSynchronization

public javax.transaction.Synchronization getSynchronization()
Accessor for the synchronization object to be notified on transaction completion.

Specified by:
getSynchronization in interface Transaction
Returns:
The synchronization instance ot be notified on transaction completion.

setNontransactionalRead

public void setNontransactionalRead(boolean nontransactionalRead)
Mutator for the setting of nontransactional read.

Specified by:
setNontransactionalRead in interface Transaction
Parameters:
nontransactionalRead - Whether to allow nontransactional read operations

setNontransactionalWrite

public void setNontransactionalWrite(boolean nontransactionalWrite)
Mutator for the setting of nontransactional write.

Specified by:
setNontransactionalWrite in interface Transaction
Parameters:
nontransactionalWrite - Whether to allow nontransactional write operations

setOptimistic

public void setOptimistic(boolean optimistic)
Mutator for the optimistic transaction setting.

Specified by:
setOptimistic in interface Transaction
Parameters:
optimistic - The optimistic transaction setting.

setRestoreValues

public void setRestoreValues(boolean restoreValues)
Mutator for the setting of restore values.

Specified by:
setRestoreValues in interface Transaction
Parameters:
restoreValues - Whether to restore values at commit

setRetainValues

public void setRetainValues(boolean retainValues)
Mutator for the setting of retain values.

Specified by:
setRetainValues in interface Transaction
Parameters:
retainValues - Whether to retain values at commit

setRollbackOnly

public void setRollbackOnly()
Mutator for the "rollback only" flag. Sets the transaction as for rollback only.

Specified by:
setRollbackOnly in interface Transaction
Since:
1.1

setSynchronization

public void setSynchronization(javax.transaction.Synchronization sync)
Mutator for the synchronization object to be notified on transaction completion.

Specified by:
setSynchronization in interface Transaction
Parameters:
sync - The synchronization object to be notified on transaction completion

addTransactionEventListener

public void addTransactionEventListener(TransactionEventListener listener)
Specified by:
addTransactionEventListener in interface Transaction

removeTransactionEventListener

public void removeTransactionEventListener(TransactionEventListener listener)
Specified by:
removeTransactionEventListener in interface Transaction

getOptions

public java.util.Map getOptions()
Description copied from interface: Transaction
Obtain all settings for this Transaction

Specified by:
getOptions in interface Transaction
Returns:
a map with settings

setOption

public void setOption(java.lang.String option,
                      int value)
Specified by:
setOption in interface Transaction

setOption

public void setOption(java.lang.String option,
                      boolean value)
Specified by:
setOption in interface Transaction

setOption

public void setOption(java.lang.String option,
                      java.lang.String value)
Specified by:
setOption in interface Transaction


Copyright © 2009. All Rights Reserved.