站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.1.0 API 文档英文版

AnnotationTransactionAttributeSource (Spring Framework API 2.1) - Spring Framework 2.1.0 API 文档英文版


The Spring Framework

org.springframework.transaction.annotation
Class AnnotationTransactionAttributeSource

java.lang.Object
  extended by org.springframework.transaction.interceptor.AbstractFallbackTransactionAttributeSource
      extended by org.springframework.transaction.annotation.AnnotationTransactionAttributeSource
All Implemented Interfaces:
Serializable, TransactionAttributeSource

public class AnnotationTransactionAttributeSource
extends AbstractFallbackTransactionAttributeSource
implements Serializable

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. Can also be used as base class for a custom annotation-based TransactionAttributeSource.

This is a direct alternative to AttributesTransactionAttributeSource, which is able to read in source-level attributes via Commons Attributes.

Since:
1.2
Author:
Colin Sampaleanu, Juergen Hoeller
See Also:
Transactional, findTransactionAttribute(java.util.Collection), TransactionAspectSupport.setTransactionAttributeSource(org.springframework.transaction.interceptor.TransactionAttributeSource), TransactionProxyFactoryBean.setTransactionAttributeSource(org.springframework.transaction.interceptor.TransactionAttributeSource), AttributesTransactionAttributeSource, CommonsAttributes, Serialized Form

Field Summary
 
Fields inherited from class org.springframework.transaction.interceptor.AbstractFallbackTransactionAttributeSource
logger
 
Constructor Summary
AnnotationTransactionAttributeSource()
          Create a default AnnotationTransactionAttributeSource, supporting public methods that carry the Transactional annotation.
AnnotationTransactionAttributeSource(boolean publicMethodsOnly)
          Create a custom AnnotationTransactionAttributeSource.
 
Method Summary
protected  boolean allowPublicMethodsOnly()
          By default, only public methods can be made transactional using Transactional.
 boolean equals(Object other)
           
protected  Collection findAllAttributes(Class clazz)
          Returns all JDK 1.5+ annotations found for the given class.
protected  Collection findAllAttributes(Method method)
          Returns all JDK 1.5+ annotations found for the given method.
protected  TransactionAttribute findTransactionAttribute(Collection atts)
          Return the transaction attribute, given this set of attributes attached to a method or class.
 int hashCode()
           
 
Methods inherited from class org.springframework.transaction.interceptor.AbstractFallbackTransactionAttributeSource
getCacheKey, getTransactionAttribute
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationTransactionAttributeSource

public AnnotationTransactionAttributeSource()
Create a default AnnotationTransactionAttributeSource, supporting public methods that carry the Transactional annotation.


AnnotationTransactionAttributeSource

public AnnotationTransactionAttributeSource(boolean publicMethodsOnly)
Create a custom AnnotationTransactionAttributeSource.

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)
Method Detail

findAllAttributes

protected Collection findAllAttributes(Method method)
Returns all JDK 1.5+ annotations found for the given method.

Specified by:
findAllAttributes in class AbstractFallbackTransactionAttributeSource
Parameters:
method - the method to retrieve attributes for
Returns:
all attributes associated with this method (may be null)

findAllAttributes

protected Collection findAllAttributes(Class clazz)
Returns all JDK 1.5+ annotations found for the given class.

Specified by:
findAllAttributes in class AbstractFallbackTransactionAttributeSource
Parameters:
clazz - class to retrieve attributes for
Returns:
all attributes associated with this class (may be null)

findTransactionAttribute

protected TransactionAttribute findTransactionAttribute(Collection atts)
Return the transaction attribute, given this set of attributes attached to a method or class. Overrides method from parent class.

This implementation converts Spring's Transactional annotation to the Spring metadata classes. Returns null if it's not transactional.

Can be overridden to support custom annotations that carry transaction metadata.

Overrides:
findTransactionAttribute in class AbstractFallbackTransactionAttributeSource
Parameters:
atts - attributes attached to a method or class. May be null, in which case a null TransactionAttribute will be returned.
Returns:
TransactionAttribute the configured transaction attribute, or null if none was found
See Also:
Transactional

allowPublicMethodsOnly

protected boolean allowPublicMethodsOnly()
By default, only public methods can be made transactional using Transactional.

Overrides:
allowPublicMethodsOnly in class AbstractFallbackTransactionAttributeSource

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

The Spring Framework

Copyright © 2002-2007 The Spring Framework.