public class GemfireTransactionManager extends AbstractPlatformTransactionManager implements InitializingBean, ResourceTransactionManager
PlatformTransactionManager implementation for a single GemFire
CacheTransactionManager.
Binds one or multiple GemFire regions for the specified Cache to the
thread, potentially allowing for one region per cache model.
This local strategy is an alternative to executing cache operations within JTA transactions. Its advantage is that is able to work in any environment, for example a stand-alone application or a test suite. It is not able to provide XA transactions, for example to share transactions with data access.
To prevent dirty reads, by default, the cache is configured to return copies
rather then direct references for get operations. As a
workaround, one could use explicitly deep copy objects before making changes
to them to avoid unnecessary copying on every fetch.
AbstractPlatformTransactionManager.SuspendedResourcesHolderlogger, SYNCHRONIZATION_ALWAYS, SYNCHRONIZATION_NEVER, SYNCHRONIZATION_ON_ACTUAL_TRANSACTION| Constructor and Description |
|---|
GemfireTransactionManager()
Creates a new GemfireTransactionManager instance.
|
GemfireTransactionManager(Cache cache)
Creates a new GemfireTransactionManager instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected void |
doBegin(Object transaction,
TransactionDefinition definition) |
protected void |
doCleanupAfterCompletion(Object transaction) |
protected void |
doCommit(DefaultTransactionStatus status) |
protected Object |
doGetTransaction() |
protected void |
doRollback(DefaultTransactionStatus status) |
protected void |
doSetRollbackOnly(DefaultTransactionStatus status) |
Cache |
getCache()
Returns the Cache that this instance manages local transactions for.
|
Object |
getResourceFactory() |
boolean |
isCopyOnRead()
Indicates whether copy on read is set or not on the transaction manager.
|
protected boolean |
isExistingTransaction(Object transaction) |
void |
setCache(Cache cache)
Sets the Cache that this instance manages local transactions for.
|
void |
setCopyOnRead(boolean copyOnRead)
Indicates whether the cache returns direct references or copies of the
objects (default) it manages.
|
<K,V> void |
setRegion(Region<K,V> region)
Sets the GemFire Cache
Region (as an alternative in setting in the Cache directly). |
protected boolean |
useSavepointForNestedTransaction() |
commit, determineTimeout, doResume, doSuspend, getDefaultTimeout, getTransaction, getTransactionSynchronization, invokeAfterCompletion, isFailEarlyOnGlobalRollbackOnly, isGlobalRollbackOnParticipationFailure, isNestedTransactionAllowed, isRollbackOnCommitFailure, isValidateExistingTransaction, newTransactionStatus, prepareForCommit, prepareSynchronization, prepareTransactionStatus, registerAfterCompletionWithExistingTransaction, resume, rollback, setDefaultTimeout, setFailEarlyOnGlobalRollbackOnly, setGlobalRollbackOnParticipationFailure, setNestedTransactionAllowed, setRollbackOnCommitFailure, setTransactionSynchronization, setTransactionSynchronizationName, setValidateExistingTransaction, shouldCommitOnGlobalRollbackOnly, suspend, triggerBeforeCommit, triggerBeforeCompletionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcommit, getTransaction, rollbackpublic GemfireTransactionManager()
public GemfireTransactionManager(Cache cache)
cache - a reference to the GemFire Cache associated with Cache transactions.public void afterPropertiesSet()
afterPropertiesSet in interface InitializingBeanprotected Object doGetTransaction() throws TransactionException
doGetTransaction in class AbstractPlatformTransactionManagerTransactionExceptionprotected boolean isExistingTransaction(Object transaction) throws TransactionException
isExistingTransaction in class AbstractPlatformTransactionManagerTransactionExceptionprotected void doBegin(Object transaction, TransactionDefinition definition) throws TransactionException
doBegin in class AbstractPlatformTransactionManagerTransactionExceptionprotected void doCommit(DefaultTransactionStatus status) throws TransactionException
doCommit in class AbstractPlatformTransactionManagerTransactionExceptionprotected void doRollback(DefaultTransactionStatus status) throws TransactionException
doRollback in class AbstractPlatformTransactionManagerTransactionExceptionprotected void doSetRollbackOnly(DefaultTransactionStatus status)
doSetRollbackOnly in class AbstractPlatformTransactionManagerprotected void doCleanupAfterCompletion(Object transaction)
doCleanupAfterCompletion in class AbstractPlatformTransactionManagerprotected final boolean useSavepointForNestedTransaction()
useSavepointForNestedTransaction in class AbstractPlatformTransactionManagerpublic Cache getCache()
public void setCache(Cache cache)
cache - Gemfire cachepublic Object getResourceFactory()
getResourceFactory in interface ResourceTransactionManagerpublic <K,V> void setRegion(Region<K,V> region)
Region (as an alternative in setting in the Cache directly).K - the Region key class type.V - the Region value class type.region - the Gemfire Cache Region directly involved in the Cache transaction.public void setCopyOnRead(boolean copyOnRead)
CopyHelper.copy(Object) in which
case this setting can be set to false. However, unless there
is a measurable performance penalty, the recommendation is to keep this
setting to truecopyOnRead - whether copies (default) rather then direct references
will be returned on fetch operationspublic boolean isCopyOnRead()
setCopyOnRead(boolean)