| java.lang.Object org.springframework.transaction.interceptor.TransactionAspectSupport
All known Subclasses: org.springframework.transaction.interceptor.TransactionInterceptor,
TransactionAspectSupport | abstract public class TransactionAspectSupport implements InitializingBean(Code) | | Base class for transactional aspects, such as the AOP Alliance
TransactionInterceptor or an AspectJ aspect.
This enables the underlying Spring transaction infrastructure to be used
easily to implement an aspect for any aspect system.
Subclasses are responsible for calling methods in this class in the
correct order.
If no transaction name has been specified in the
TransactionAttribute , the exposed name will be the
fully-qualified class name + "." + method name
(by default).
Uses the Strategy design pattern. A
PlatformTransactionManager implementation will perform the
actual transaction management, and a TransactionAttributeSource
is used for determining transaction definitions.
A transaction aspect is serializable if it's
PlatformTransactionManager and
TransactionAttributeSource are serializable.
author: Rod Johnson author: Juergen Hoeller since: 1.1 See Also: TransactionAspectSupport.setTransactionManager See Also: TransactionAspectSupport.setTransactionAttributes See Also: TransactionAspectSupport.setTransactionAttributeSource |
Inner Class :protected class TransactionInfo | |
Field Summary | |
final protected Log | logger |
logger | final protected Log logger(Code) | | |
afterPropertiesSet | public void afterPropertiesSet()(Code) | | Check that required properties were set.
|
cleanupTransactionInfo | protected void cleanupTransactionInfo(TransactionInfo txInfo)(Code) | | Reset the TransactionInfo ThreadLocal.
Call this in all cases: exception or normal return!
Parameters: txInfo - information about the current transaction (may be null ) |
commitTransactionAfterReturning | protected void commitTransactionAfterReturning(TransactionInfo txInfo)(Code) | | Execute after successful completion of call, but not after an exception was handled.
Do nothing if we didn't create a transaction.
Parameters: txInfo - information about the current transaction |
completeTransactionAfterThrowing | protected void completeTransactionAfterThrowing(TransactionInfo txInfo, Throwable ex)(Code) | | Handle a throwable, completing the transaction.
We may commit or roll back, depending on the configuration.
Parameters: txInfo - information about the current transaction Parameters: ex - throwable encountered |
createTransactionIfNecessary | protected TransactionInfo createTransactionIfNecessary(Method method, Class targetClass)(Code) | | Create a transaction if necessary, based on the given method and class.
Performs a default TransactionAttribute lookup for the given method.
Parameters: method - method about to execute Parameters: targetClass - class the method is on a TransactionInfo object, whether or not a transaction was created.The hasTransaction() method on TransactionInfo can be used to tell if therewas a transaction created. See Also: TransactionAspectSupport.getTransactionAttributeSource() |
createTransactionIfNecessary | protected TransactionInfo createTransactionIfNecessary(TransactionAttribute txAttr, String joinpointIdentification)(Code) | | Create a transaction if necessary based on the given TransactionAttribute.
Allows callers to perform custom TransactionAttribute lookups through
the TransactionAttributeSource.
Parameters: txAttr - the TransactionAttribute (may be null ) Parameters: joinpointIdentification - the fully qualified method name(used for monitoring and logging purposes) a TransactionInfo object, whether or not a transaction was created.The hasTransaction() method on TransactionInfo can be used totell if there was a transaction created. See Also: TransactionAspectSupport.getTransactionAttributeSource() |
currentTransactionInfo | protected static TransactionInfo currentTransactionInfo() throws NoTransactionException(Code) | | Subclasses can use this to return the current TransactionInfo.
Only subclasses that cannot handle all operations in one method,
such as an AspectJ aspect involving distinct before and after advice,
need to use this mechanism to get at the current TransactionInfo.
An around advice such as an AOP Alliance MethodInterceptor can hold a
reference to the TransactionInfo throughout the aspect method.
A TransactionInfo will be returned even if no transaction was created.
The TransactionInfo.hasTransaction() method can be used to query this.
To find out about specific transaction characteristics, consider using
TransactionSynchronizationManager's isSynchronizationActive()
and/or isActualTransactionActive() methods.
TransactionInfo bound to this thread, or null if none See Also: TransactionInfo.hasTransaction See Also: org.springframework.transaction.support.TransactionSynchronizationManager.isSynchronizationActive See Also: org.springframework.transaction.support.TransactionSynchronizationManager.isActualTransactionActive |
currentTransactionStatus | public static TransactionStatus currentTransactionStatus() throws NoTransactionException(Code) | | Return the transaction status of the current method invocation.
Mainly intended for code that wants to set the current transaction
rollback-only but not throw an application exception.
throws: NoTransactionException - if the transaction info cannot be found,because the method was invoked outside an AOP invocation context |
methodIdentification | protected String methodIdentification(Method method)(Code) | | Convenience method to return a String representation of this Method
for use in logging. Can be overridden in subclasses to provide a
different identifier for the given method.
Parameters: method - the method we're interested in log message identifying this method See Also: org.springframework.util.ClassUtils.getQualifiedMethodName |
prepareTransactionInfo | protected TransactionInfo prepareTransactionInfo(TransactionAttribute txAttr, String joinpointIdentification, TransactionStatus status)(Code) | | Prepare a TransactionInfo for the given attribute and status object.
Parameters: txAttr - the TransactionAttribute (may be null ) Parameters: joinpointIdentification - the fully qualified method name(used for monitoring and logging purposes) Parameters: status - the TransactionStatus for the current transaction the prepared TransactionInfo object |
setTransactionManager | public void setTransactionManager(PlatformTransactionManager transactionManager)(Code) | | Set the transaction manager. This will perform actual
transaction management: This class is just a way of invoking it.
|
|
|