public class

AnnotationTransactionAttributeSource

extends AbstractFallbackTransactionAttributeSource
implements Serializable
java.lang.Object
   ↳ org.springframework.transaction.interceptor.AbstractFallbackTransactionAttributeSource
     ↳ org.springframework.transaction.annotation.AnnotationTransactionAttributeSource

Class Overview

Implementation of the 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 EJB3's javax.ejb.TransactionAttribute annotation (if present). This class may also serve as base class for a custom TransactionAttributeSource, or get customized through TransactionAnnotationParser strategies.

Summary

[Expand]
Inherited Fields
From class org.springframework.transaction.interceptor.AbstractFallbackTransactionAttributeSource
Public Constructors
AnnotationTransactionAttributeSource()
Create a default AnnotationTransactionAttributeSource, supporting public methods that carry the Transactional annotation or the EJB3 javax.ejb.TransactionAttribute annotation.
AnnotationTransactionAttributeSource(boolean publicMethodsOnly)
Create a custom AnnotationTransactionAttributeSource, supporting public methods that carry the Transactional annotation or the EJB3 javax.ejb.TransactionAttribute annotation.
AnnotationTransactionAttributeSource(TransactionAnnotationParser annotationParser)
Create a custom AnnotationTransactionAttributeSource.
AnnotationTransactionAttributeSource(Set<TransactionAnnotationParser> annotationParsers)
Create a custom AnnotationTransactionAttributeSource.
Protected Methods
boolean allowPublicMethodsOnly()
By default, only public methods can be made transactional.
TransactionAttribute determineTransactionAttribute(AnnotatedElement ae)
Determine the transaction attribute for the given method or class.
TransactionAttribute findTransactionAttribute(Method method)
Subclasses need to implement this to return the transaction attribute for the given method, if any.
TransactionAttribute findTransactionAttribute(Class<?> clazz)
Subclasses need to implement this to return the transaction attribute for the given class, if any.
[Expand]
Inherited Methods
From class org.springframework.transaction.interceptor.AbstractFallbackTransactionAttributeSource
From class java.lang.Object
From interface org.springframework.transaction.interceptor.TransactionAttributeSource

Public Constructors

public AnnotationTransactionAttributeSource ()

Create a default AnnotationTransactionAttributeSource, supporting public methods that carry the Transactional annotation or the EJB3 javax.ejb.TransactionAttribute annotation.

public AnnotationTransactionAttributeSource (boolean publicMethodsOnly)

Create a custom AnnotationTransactionAttributeSource, supporting public methods that carry the Transactional annotation or the EJB3 javax.ejb.TransactionAttribute annotation.

Parameters
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)

Create a custom AnnotationTransactionAttributeSource.

Parameters
annotationParser the TransactionAnnotationParser to use

public AnnotationTransactionAttributeSource (Set<TransactionAnnotationParser> annotationParsers)

Create a custom AnnotationTransactionAttributeSource.

Parameters
annotationParsers the TransactionAnnotationParsers to use

Protected Methods

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.

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.

Parameters
ae the annotated method or class
Returns
  • TransactionAttribute the configured transaction attribute, or null if none was found

protected TransactionAttribute findTransactionAttribute (Method method)

Subclasses need to implement this to return the transaction attribute for the given method, if any.

Parameters
method the method to retrieve the attribute for
Returns
  • all transaction attribute associated with this method (or null if none)

protected TransactionAttribute findTransactionAttribute (Class<?> clazz)

Subclasses need to implement this to return the transaction attribute for the given class, if any.

Parameters
clazz the class to retrieve the attribute for
Returns
  • all transaction attribute associated with this class (or null if none)