java.lang.Object | |
↳ | org.springframework.transaction.interceptor.TransactionAspectSupport |
Known Direct Subclasses |
Base class for transactional aspects, such as the 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 its PlatformTransactionManager
and TransactionAttributeSource
are serializable.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
TransactionAspectSupport.TransactionInfo | Opaque object used to hold Transaction information. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
logger |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Check that required properties were set.
| |||||||||||
Return the transaction status of the current method invocation.
| |||||||||||
Return the transaction attribute source.
| |||||||||||
Return the transaction manager, if specified.
| |||||||||||
Set the BeanFactory to use for retrieving PlatformTransactionManager beans.
| |||||||||||
Set the transaction attribute source which is used to find transaction
attributes.
| |||||||||||
Set multiple transaction attribute sources which are used to find transaction
attributes.
| |||||||||||
Set properties with method names as keys and transaction attribute
descriptors (parsed via TransactionAttributeEditor) as values:
e.g.
| |||||||||||
Specify the target transaction manager.
| |||||||||||
Specify the name of the default transaction manager bean.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Reset the TransactionInfo ThreadLocal.
| |||||||||||
Execute after successful completion of call, but not after an exception was handled.
| |||||||||||
Handle a throwable, completing the transaction.
| |||||||||||
Create a transaction if necessary based on the given TransactionAttribute.
| |||||||||||
Create a transaction if necessary, based on the given method and class.
| |||||||||||
Subclasses can use this to return the current TransactionInfo.
| |||||||||||
Determine the specific transaction manager to use for the given transaction.
| |||||||||||
Return the BeanFactory to use for retrieving PlatformTransactionManager beans.
| |||||||||||
Return the name of the default transaction manager bean.
| |||||||||||
Convenience method to return a String representation of this Method
for use in logging.
| |||||||||||
This method is deprecated.
in favor of
methodIdentification(Method, Class)
| |||||||||||
Prepare a TransactionInfo for the given attribute and status object.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.BeanFactoryAware
| |||||||||||
From interface
org.springframework.beans.factory.InitializingBean
|
Check that required properties were set.
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.
NoTransactionException | if the transaction info cannot be found, because the method was invoked outside an AOP invocation context |
---|
Return the transaction attribute source.
Return the transaction manager, if specified.
Set the BeanFactory to use for retrieving PlatformTransactionManager beans.
beanFactory | owning BeanFactory (never null ).
The bean can immediately call methods on the factory. |
---|
Set the transaction attribute source which is used to find transaction attributes. If specifying a String property value, a PropertyEditor will create a MethodMapTransactionAttributeSource from the value.
Set multiple transaction attribute sources which are used to find transaction attributes. Will build a CompositeTransactionAttributeSource for the given sources.
Set properties with method names as keys and transaction attribute descriptors (parsed via TransactionAttributeEditor) as values: e.g. key = "myMethod", value = "PROPAGATION_REQUIRED,readOnly".
Note: Method names are always applied to the target class, no matter if defined in an interface or the class itself.
Internally, a NameMatchTransactionAttributeSource will be created from the given properties.
Specify the target transaction manager.
Specify the name of the default transaction manager bean.
Reset the TransactionInfo ThreadLocal.
Call this in all cases: exception or normal return!
txInfo | information about the current transaction (may be null )
|
---|
Execute after successful completion of call, but not after an exception was handled. Do nothing if we didn't create a transaction.
txInfo | information about the current transaction |
---|
Handle a throwable, completing the transaction. We may commit or roll back, depending on the configuration.
txInfo | information about the current transaction |
---|---|
ex | throwable encountered |
Create a transaction if necessary based on the given TransactionAttribute.
Allows callers to perform custom TransactionAttribute lookups through the TransactionAttributeSource.
txAttr | the TransactionAttribute (may be null ) |
---|---|
joinpointIdentification | the fully qualified method name (used for monitoring and logging purposes) |
hasTransaction()
method on TransactionInfo can be used to
tell if there was a transaction created.Create a transaction if necessary, based on the given method and class.
Performs a default TransactionAttribute lookup for the given method.
method | method about to execute |
---|---|
targetClass | class the method is on |
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.
null
if noneNoTransactionException |
---|
Determine the specific transaction manager to use for the given transaction.
Return the BeanFactory to use for retrieving PlatformTransactionManager beans.
Return the name of the default transaction manager bean.
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.
method | the method we're interested in |
---|---|
targetClass | class the method is on |
This method is deprecated.
in favor of methodIdentification(Method, Class)
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.
method | the method we're interested in |
---|
Prepare a TransactionInfo for the given attribute and status object.
txAttr | the TransactionAttribute (may be null ) |
---|---|
joinpointIdentification | the fully qualified method name (used for monitoring and logging purposes) |
status | the TransactionStatus for the current transaction |