public class TransactionImpl extends Object implements Transaction
Transaction
.
This is not thread-safe.Modifier and Type | Field and Description |
---|---|
protected boolean |
rollbackOnly
Whether the transaction is only for roll-back.
|
protected Boolean |
serializeRead
Whether to serialise (lock) any read objects in this transaction.
|
TRANSACTION_ISOLATION_OPTION
Constructor and Description |
---|
TransactionImpl(ExecutionContext ec,
PropertyStore properties)
Constructor for a transaction for the specified ExecutionContext.
|
Modifier and Type | Method and Description |
---|---|
void |
addTransactionEventListener(TransactionEventListener listener)
Adds a transaction listener.
|
void |
begin()
Method to begin the transaction.
|
void |
bindTransactionEventListener(TransactionEventListener listener)
Listeners that are never cleared, and invoked for all transactions
|
void |
close()
Method to inform the transaction that it is closed.
|
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.
|
long |
getBeginTime()
Accessor for the time (millisecs) from System.currentTimeMillis when the transaction started.
|
boolean |
getIsActive()
Similar to "isActive" except that it just returns the "active" flag whereas the isActive() method can also embody rejoining to underlying transactions.
|
boolean |
getNontransactionalRead()
Accessor for the nontransactionalRead flag for this transaction.
|
boolean |
getNontransactionalWrite()
Accessor for the nontransactionalWrite flag for this transaction.
|
boolean |
getNontransactionalWriteAutoCommit()
Accessor for whether non-tx writes are auto-commit.
|
boolean |
getOptimistic()
Accessor for the Optimistic setting
|
Map<String,Object> |
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.
|
Boolean |
getSerializeRead()
Accessor for the setting for whether to serialize read objects (lock them).
|
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, DataNucleus 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() |
protected void |
internalRollback()
Internal rollback.
|
boolean |
isActive()
Accessor for whether the transaction is active.
|
boolean |
isCommitting()
Accessor for whether the transaction is comitting.
|
void |
preFlush()
Method to notify of preFlush.
|
void |
releaseSavepoint(String name)
Method to deregister the current position as a savepoint with the provided name (assuming the datastore supports it).
|
void |
removeTransactionEventListener(TransactionEventListener listener)
Removes the specified listener.
|
void |
rollback()
Method to rollback the transaction.
|
void |
rollbackToSavepoint(String name)
Method to rollback the transaction to the specified savepoint (assuming the datastore supports it).
|
void |
setNontransactionalRead(boolean nontransactionalRead)
Mutator for the setting of nontransactional read.
|
void |
setNontransactionalWrite(boolean nontransactionalWrite)
Mutator for the setting of nontransactional write.
|
void |
setNontransactionalWriteAutoCommit(boolean autoCommit)
Mutator for whether non-tx writes are auto-commit (false implies delayed til next transaction commit).
|
void |
setOptimistic(boolean optimistic)
Mutator for the optimistic transaction setting.
|
void |
setOption(String option,
boolean value) |
void |
setOption(String option,
int value) |
void |
setOption(String option,
Object value) |
void |
setOption(String option,
String value) |
void |
setProperties(PropertyStore properties) |
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 |
setSavepoint(String name)
Method to register the current position as a savepoint with the provided name (assuming the datastore supports it).
|
void |
setSerializeRead(Boolean serializeRead)
Mutator for whether to serialize (lock) any read objects in this transaction.
|
void |
setSynchronization(Synchronization sync)
Mutator for the synchronization object to be notified on transaction completion.
|
protected boolean rollbackOnly
protected Boolean serializeRead
public TransactionImpl(ExecutionContext ec, PropertyStore properties)
ec
- ExecutionContextproperties
- Properties to use with the transactionpublic long getBeginTime()
Transaction
getBeginTime
in interface Transaction
public void close()
Transaction
close
in interface Transaction
public void begin()
begin
in interface Transaction
protected void internalBegin()
public void preFlush()
preFlush
in interface Transaction
public void flush()
flush
in interface Transaction
public void end()
end
in interface Transaction
public void commit()
commit
in interface Transaction
protected void internalPreCommit()
protected void internalCommit()
public void rollback()
rollback
in interface Transaction
protected void internalPreRollback()
protected void internalRollback()
protected void internalPostCommit()
public boolean isActive()
isActive
in interface Transaction
public boolean getIsActive()
getIsActive
in interface Transaction
public boolean isCommitting()
isCommitting
in interface Transaction
public boolean getNontransactionalRead()
getNontransactionalRead
in interface Transaction
public boolean getNontransactionalWrite()
getNontransactionalWrite
in interface Transaction
public boolean getNontransactionalWriteAutoCommit()
getNontransactionalWriteAutoCommit
in interface Transaction
public boolean getOptimistic()
getOptimistic
in interface Transaction
public boolean getRestoreValues()
getRestoreValues
in interface Transaction
public boolean getRetainValues()
getRetainValues
in interface Transaction
public boolean getRollbackOnly()
getRollbackOnly
in interface Transaction
public Synchronization getSynchronization()
getSynchronization
in interface Transaction
public void setNontransactionalRead(boolean nontransactionalRead)
setNontransactionalRead
in interface Transaction
nontransactionalRead
- Whether to allow nontransactional read operationspublic void setNontransactionalWrite(boolean nontransactionalWrite)
setNontransactionalWrite
in interface Transaction
nontransactionalWrite
- Whether to allow nontransactional write operationspublic void setNontransactionalWriteAutoCommit(boolean autoCommit)
setNontransactionalWriteAutoCommit
in interface Transaction
autoCommit
- Whether auto-commit of non-tx writespublic void setOptimistic(boolean optimistic)
setOptimistic
in interface Transaction
optimistic
- The optimistic transaction setting.public void setRestoreValues(boolean restoreValues)
setRestoreValues
in interface Transaction
restoreValues
- Whether to restore values at commitpublic void setRetainValues(boolean retainValues)
setRetainValues
in interface Transaction
retainValues
- Whether to retain values at commitpublic void setRollbackOnly()
setRollbackOnly
in interface Transaction
public void setSavepoint(String name)
Transaction
setSavepoint
in interface Transaction
name
- Savepoint namepublic void releaseSavepoint(String name)
Transaction
releaseSavepoint
in interface Transaction
name
- Savepoint namepublic void rollbackToSavepoint(String name)
Transaction
rollbackToSavepoint
in interface Transaction
name
- Savepoint namepublic void setSynchronization(Synchronization sync)
setSynchronization
in interface Transaction
sync
- The synchronization object to be notified on transaction completionpublic void addTransactionEventListener(TransactionEventListener listener)
Transaction
addTransactionEventListener
in interface Transaction
listener
- The listener to addpublic void removeTransactionEventListener(TransactionEventListener listener)
Transaction
removeTransactionEventListener
in interface Transaction
listener
- Listener to removepublic void bindTransactionEventListener(TransactionEventListener listener)
Transaction
bindTransactionEventListener
in interface Transaction
listener
- listener to bindpublic Boolean getSerializeRead()
Transaction
getSerializeRead
in interface Transaction
public void setSerializeRead(Boolean serializeRead)
Transaction
setSerializeRead
in interface Transaction
serializeRead
- Whether to serialise (lock) any read objectspublic Map<String,Object> getOptions()
Transaction
getOptions
in interface Transaction
public void setOption(String option, int value)
setOption
in interface Transaction
public void setOption(String option, boolean value)
setOption
in interface Transaction
public void setOption(String option, String value)
setOption
in interface Transaction
public void setOption(String option, Object value)
setOption
in interface Transaction
public void setProperties(PropertyStore properties)
Copyright © 2019. All rights reserved.