|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.transaction.interceptor.TransactionAspectSupport
org.alfresco.util.transaction.SpringAwareUserTransaction
public class SpringAwareUserTransaction
A UserTransaction
that will allow the thread using it to participate
in transactions that are normally only begun and committed by the SpringFramework
transaction aware components.
Client code can use this class directly, but should be very careful to handle the exception
conditions with the appropriate finally
blocks and rollback
code.
It is recommended that clients use this class indirectly via an instance of the
RetryingTransactionHelper
.
This class is thread-safe in that it will detect multithreaded access and throw exceptions. Therefore do not use on multiple threads. Instances should be used only for the duration of the required user transaction and then discarded. Any attempt to reuse an instance will result in failure.
Nested user transaction are allowed.
Logging:
To dump exceptions during commits, turn debugging on for this class.
To log leaked transactions i.e. a begin() is not matched by a commit() or rollback(),
add .trace to the usual classname-based debug category and set to WARN log
level. This will log the first detection of a leaked transaction and automatically enable
transaction call stack logging for subsequent leaked transactions. To enforce
call stack logging from the start set the .trace log level to DEBUG. Call stack
logging will hamper performance but is useful when it appears that something is eating
connections or holding onto resources - usually a sign that client code hasn't handled all
possible exception conditions.
PlatformTransactionManager
,
DefaultTransactionDefinition
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.springframework.transaction.interceptor.TransactionAspectSupport |
---|
org.springframework.transaction.interceptor.TransactionAspectSupport.TransactionInfo |
Field Summary |
---|
Fields inherited from interface org.springframework.transaction.TransactionDefinition |
---|
ISOLATION_DEFAULT, ISOLATION_READ_COMMITTED, ISOLATION_READ_UNCOMMITTED, ISOLATION_REPEATABLE_READ, ISOLATION_SERIALIZABLE, PROPAGATION_MANDATORY, PROPAGATION_NESTED, PROPAGATION_NEVER, PROPAGATION_NOT_SUPPORTED, PROPAGATION_REQUIRED, PROPAGATION_REQUIRES_NEW, PROPAGATION_SUPPORTS, TIMEOUT_DEFAULT |
Constructor Summary | |
---|---|
SpringAwareUserTransaction(org.springframework.transaction.PlatformTransactionManager transactionManager,
boolean readOnly,
int isolationLevel,
int propagationBehaviour,
int timeout)
Creates a user transaction that defaults to TransactionDefinition.PROPAGATION_REQUIRED . |
Method Summary | |
---|---|
void |
begin()
|
void |
commit()
|
protected void |
completeTransactionAfterThrowing(org.springframework.transaction.interceptor.TransactionAspectSupport.TransactionInfo txInfo,
java.lang.Throwable ex)
|
protected void |
finalize()
|
int |
getIsolationLevel()
|
java.lang.String |
getName()
|
int |
getPropagationBehavior()
|
java.lang.String |
getQualifier()
Return a qualifier value associated with this transaction attribute. |
int |
getStatus()
This status is a combination of the internal status, as recorded during explicit operations, and the status provided by the Spring support. |
int |
getTimeout()
|
org.springframework.transaction.interceptor.TransactionAttribute |
getTransactionAttribute(java.lang.reflect.Method method,
java.lang.Class targetClass)
This class carries all the information required to fullfil requests about the transaction attributes. |
boolean |
isReadOnly()
|
protected java.lang.String |
methodIdentification(java.lang.reflect.Method method)
|
void |
rollback()
|
boolean |
rollbackOn(java.lang.Throwable ex)
The UserTransaction must rollback regardless of the error. |
void |
setRollbackOnly()
|
void |
setTransactionTimeout(int timeout)
Implementation required for UserTransaction . |
java.lang.String |
toString()
|
Methods inherited from class org.springframework.transaction.interceptor.TransactionAspectSupport |
---|
afterPropertiesSet, cleanupTransactionInfo, commitTransactionAfterReturning, createTransactionIfNecessary, createTransactionIfNecessary, currentTransactionInfo, currentTransactionStatus, determineTransactionManager, getBeanFactory, getTransactionAttributeSource, getTransactionManager, getTransactionManagerBeanName, methodIdentification, prepareTransactionInfo, setBeanFactory, setTransactionAttributes, setTransactionAttributeSource, setTransactionAttributeSources, setTransactionManager, setTransactionManagerBeanName |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SpringAwareUserTransaction(org.springframework.transaction.PlatformTransactionManager transactionManager, boolean readOnly, int isolationLevel, int propagationBehaviour, int timeout)
TransactionDefinition.PROPAGATION_REQUIRED
.
transactionManager
- the transaction manager to usereadOnly
- true to force a read-only transactionisolationLevel
- one of the
TransactionDefinition.ISOLATION_XXX
constantspropagationBehaviour
- one of the
TransactionDefinition.PROPAGATION__XXX
constantstimeout
- the transaction timeout in seconds.TransactionDefinition.getTimeout()
Method Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public org.springframework.transaction.interceptor.TransactionAttribute getTransactionAttribute(java.lang.reflect.Method method, java.lang.Class targetClass)
getTransactionAttribute
in interface org.springframework.transaction.interceptor.TransactionAttributeSource
this
instancepublic java.lang.String getQualifier()
getQualifier
in interface org.springframework.transaction.interceptor.TransactionAttribute
public boolean rollbackOn(java.lang.Throwable ex)
UserTransaction
must rollback regardless of the error. The
rollback
behaviour is implemented by simulating a caught
exception. As this method will always return true
, the rollback
behaviour will be to rollback the transaction or mark it for rollback.
rollbackOn
in interface org.springframework.transaction.interceptor.TransactionAttribute
public java.lang.String getName()
getName
in interface org.springframework.transaction.TransactionDefinition
SpringAwareUserTransaction.NAME
public boolean isReadOnly()
isReadOnly
in interface org.springframework.transaction.TransactionDefinition
public int getIsolationLevel()
getIsolationLevel
in interface org.springframework.transaction.TransactionDefinition
public int getPropagationBehavior()
getPropagationBehavior
in interface org.springframework.transaction.TransactionDefinition
public int getTimeout()
getTimeout
in interface org.springframework.transaction.TransactionDefinition
public void setTransactionTimeout(int timeout) throws javax.transaction.SystemException
UserTransaction
.
setTransactionTimeout
in interface javax.transaction.UserTransaction
javax.transaction.SystemException
public int getStatus() throws javax.transaction.SystemException
getStatus
in interface javax.transaction.UserTransaction
javax.transaction.SystemException
Status
public void setRollbackOnly() throws java.lang.IllegalStateException, javax.transaction.SystemException
setRollbackOnly
in interface javax.transaction.UserTransaction
java.lang.IllegalStateException
javax.transaction.SystemException
public void begin() throws javax.transaction.NotSupportedException, javax.transaction.SystemException
begin
in interface javax.transaction.UserTransaction
javax.transaction.NotSupportedException
- if an attempt is made to reuse this instance
javax.transaction.SystemException
public void commit() throws javax.transaction.RollbackException, javax.transaction.HeuristicMixedException, javax.transaction.HeuristicRollbackException, java.lang.SecurityException, java.lang.IllegalStateException, javax.transaction.SystemException
commit
in interface javax.transaction.UserTransaction
java.lang.IllegalStateException
- if a transaction was not started
javax.transaction.RollbackException
javax.transaction.HeuristicMixedException
javax.transaction.HeuristicRollbackException
java.lang.SecurityException
javax.transaction.SystemException
public void rollback() throws java.lang.IllegalStateException, java.lang.SecurityException, javax.transaction.SystemException
rollback
in interface javax.transaction.UserTransaction
java.lang.IllegalStateException
java.lang.SecurityException
javax.transaction.SystemException
protected void completeTransactionAfterThrowing(org.springframework.transaction.interceptor.TransactionAspectSupport.TransactionInfo txInfo, java.lang.Throwable ex)
completeTransactionAfterThrowing
in class org.springframework.transaction.interceptor.TransactionAspectSupport
protected java.lang.String methodIdentification(java.lang.reflect.Method method)
methodIdentification
in class org.springframework.transaction.interceptor.TransactionAspectSupport
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |