public class AnnotationTransactionAttributeSource extends AbstractFallbackTransactionAttributeSource implements java.io.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(java.util.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(java.lang.reflect.AnnotatedElement element)
Determine the transaction attribute for the given method or class.
|
boolean |
equals(java.lang.Object other) |
protected TransactionAttribute |
findTransactionAttribute(java.lang.Class<?> clazz)
Subclasses need to implement this to return the transaction attribute for the
given class, if any.
|
protected TransactionAttribute |
findTransactionAttribute(java.lang.reflect.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(java.util.Set<TransactionAnnotationParser> annotationParsers)
annotationParsers
- the TransactionAnnotationParsers to useprotected TransactionAttribute findTransactionAttribute(java.lang.Class<?> clazz)
AbstractFallbackTransactionAttributeSource
findTransactionAttribute
in class AbstractFallbackTransactionAttributeSource
clazz
- the class to retrieve the attribute fornull
if noneprotected TransactionAttribute findTransactionAttribute(java.lang.reflect.Method method)
AbstractFallbackTransactionAttributeSource
findTransactionAttribute
in class AbstractFallbackTransactionAttributeSource
method
- the method to retrieve the attribute fornull
if noneprotected TransactionAttribute determineTransactionAttribute(java.lang.reflect.AnnotatedElement element)
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.
element
- the annotated method or classnull
if none was foundprotected boolean allowPublicMethodsOnly()
allowPublicMethodsOnly
in class AbstractFallbackTransactionAttributeSource
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object