public class AnnotationTransactionAttributeSource extends AbstractFallbackTransactionAttributeSource implements Serializable
TransactionAttributeSource
interface for working with transaction metadata in JDK 1.5+ annotation format.
This class reads Spring's JDK 1.5+ Transactional
annotation and
exposes corresponding transaction attributes to Spring's transaction infrastructure.
Also supports JTA 1.2's Transactional
and EJB3's
TransactionAttribute
annotation (if present).
This class may also serve as base class for a custom TransactionAttributeSource,
or get customized through TransactionAnnotationParser
strategies.
Transactional
,
TransactionAnnotationParser
,
SpringTransactionAnnotationParser
,
Ejb3TransactionAnnotationParser
,
TransactionAspectSupport.setTransactionAttributeSource(org.springframework.transaction.interceptor.TransactionAttributeSource)
,
TransactionProxyFactoryBean.setTransactionAttributeSource(org.springframework.transaction.interceptor.TransactionAttributeSource)
,
Serialized Formlogger
Constructor and Description |
---|
AnnotationTransactionAttributeSource()
Create a default AnnotationTransactionAttributeSource, supporting
public methods that carry the
Transactional annotation
or the EJB3 TransactionAttribute annotation. |
AnnotationTransactionAttributeSource(boolean publicMethodsOnly)
Create a custom AnnotationTransactionAttributeSource, supporting
public methods that carry the
Transactional annotation
or the EJB3 TransactionAttribute annotation. |
AnnotationTransactionAttributeSource(Set<TransactionAnnotationParser> annotationParsers)
Create a custom AnnotationTransactionAttributeSource.
|
AnnotationTransactionAttributeSource(TransactionAnnotationParser... annotationParsers)
Create a custom AnnotationTransactionAttributeSource.
|
AnnotationTransactionAttributeSource(TransactionAnnotationParser annotationParser)
Create a custom AnnotationTransactionAttributeSource.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
allowPublicMethodsOnly()
By default, only public methods can be made transactional.
|
protected TransactionAttribute |
determineTransactionAttribute(AnnotatedElement ae)
Determine the transaction attribute for the given method or class.
|
boolean |
equals(Object other) |
protected TransactionAttribute |
findTransactionAttribute(Class<?> clazz)
Subclasses need to implement this to return the transaction attribute
for the given class, if any.
|
protected TransactionAttribute |
findTransactionAttribute(Method method)
Subclasses need to implement this to return the transaction attribute
for the given method, if any.
|
int |
hashCode() |
computeTransactionAttribute, getCacheKey, getTransactionAttribute
public AnnotationTransactionAttributeSource()
Transactional
annotation
or the EJB3 TransactionAttribute
annotation.public AnnotationTransactionAttributeSource(boolean publicMethodsOnly)
Transactional
annotation
or the EJB3 TransactionAttribute
annotation.publicMethodsOnly
- whether to support public methods that carry
the Transactional
annotation only (typically for use
with proxy-based AOP), or protected/private methods as well
(typically used with AspectJ class weaving)public AnnotationTransactionAttributeSource(TransactionAnnotationParser annotationParser)
annotationParser
- the TransactionAnnotationParser to usepublic AnnotationTransactionAttributeSource(TransactionAnnotationParser... annotationParsers)
annotationParsers
- the TransactionAnnotationParsers to usepublic AnnotationTransactionAttributeSource(Set<TransactionAnnotationParser> annotationParsers)
annotationParsers
- the TransactionAnnotationParsers to useprotected TransactionAttribute findTransactionAttribute(Method method)
AbstractFallbackTransactionAttributeSource
findTransactionAttribute
in class AbstractFallbackTransactionAttributeSource
method
- the method to retrieve the attribute fornull
if none)protected TransactionAttribute findTransactionAttribute(Class<?> clazz)
AbstractFallbackTransactionAttributeSource
findTransactionAttribute
in class AbstractFallbackTransactionAttributeSource
clazz
- the class to retrieve the attribute fornull
if none)protected TransactionAttribute determineTransactionAttribute(AnnotatedElement ae)
This implementation delegates to configured
TransactionAnnotationParsers
for parsing known annotations into Spring's metadata attribute class.
Returns null
if it's not transactional.
Can be overridden to support custom annotations that carry transaction metadata.
ae
- the annotated method or classnull
if none was foundprotected boolean allowPublicMethodsOnly()
allowPublicMethodsOnly
in class AbstractFallbackTransactionAttributeSource