public class

MethodMapTransactionAttributeSource

extends Object
implements BeanClassLoaderAware InitializingBean TransactionAttributeSource
java.lang.Object
   ↳ org.springframework.transaction.interceptor.MethodMapTransactionAttributeSource

Class Overview

Simple TransactionAttributeSource implementation that allows attributes to be stored per method in a Map.

Summary

Fields
protected final Log logger Logger available to subclasses
Public Constructors
MethodMapTransactionAttributeSource()
Public Methods
void addTransactionalMethod(Method method, TransactionAttribute attr)
Add an attribute for a transactional method.
void addTransactionalMethod(Class<?> clazz, String mappedName, TransactionAttribute attr)
Add an attribute for a transactional method.
void addTransactionalMethod(String name, TransactionAttribute attr)
Add an attribute for a transactional method.
void afterPropertiesSet()
Eagerly initializes the specified "methodMap", if any.
boolean equals(Object other)
TransactionAttribute getTransactionAttribute(Method method, Class<?> targetClass)
Return the transaction attribute for this method.
int hashCode()
void setBeanClassLoader(ClassLoader beanClassLoader)
Callback that supplies the bean class loader to a bean instance.
void setMethodMap(Map<StringTransactionAttribute> methodMap)
Set a name/attribute map, consisting of "FQCN.method" method names (e.g.
String toString()
Protected Methods
void initMethodMap(Map<StringTransactionAttribute> methodMap)
Initialize the specified "methodMap", if any.
boolean isMatch(String methodName, String mappedName)
Return if the given method name matches the mapped name.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.beans.factory.BeanClassLoaderAware
From interface org.springframework.beans.factory.InitializingBean
From interface org.springframework.transaction.interceptor.TransactionAttributeSource

Fields

protected final Log logger

Logger available to subclasses

Public Constructors

public MethodMapTransactionAttributeSource ()

Public Methods

public void addTransactionalMethod (Method method, TransactionAttribute attr)

Add an attribute for a transactional method.

Parameters
method the method
attr attribute associated with the method

public void addTransactionalMethod (Class<?> clazz, String mappedName, TransactionAttribute attr)

Add an attribute for a transactional method. Method names can end or start with "*" for matching multiple methods.

Parameters
clazz target interface or class
mappedName mapped method name
attr attribute associated with the method

public void addTransactionalMethod (String name, TransactionAttribute attr)

Add an attribute for a transactional method.

Method names can end or start with "*" for matching multiple methods.

Parameters
name class and method name, separated by a dot
attr attribute associated with the method
Throws
IllegalArgumentException in case of an invalid name

public void afterPropertiesSet ()

Eagerly initializes the specified "methodMap", if any.

public boolean equals (Object other)

public TransactionAttribute getTransactionAttribute (Method method, Class<?> targetClass)

Return the transaction attribute for this method. Return null if the method is non-transactional.

Parameters
method method
targetClass target class. May be null, in which case the declaring class of the method must be used.
Returns
  • TransactionAttribute the matching transaction attribute, or null if none found

public int hashCode ()

public void setBeanClassLoader (ClassLoader beanClassLoader)

Callback that supplies the bean class loader to a bean instance.

Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean's afterPropertiesSet() method or a custom init-method.

Parameters
beanClassLoader the owning class loader; may be null in which case a default ClassLoader must be used, for example the ClassLoader obtained via getDefaultClassLoader()

public void setMethodMap (Map<StringTransactionAttribute> methodMap)

Set a name/attribute map, consisting of "FQCN.method" method names (e.g. "com.mycompany.mycode.MyClass.myMethod") and TransactionAttribute instances (or Strings to be converted to TransactionAttribute instances).

Intended for configuration via setter injection, typically within a Spring bean factory. Relies on afterPropertiesSet() being called afterwards.

Parameters
methodMap said Map from method name to attribute value

public String toString ()

Protected Methods

protected void initMethodMap (Map<StringTransactionAttribute> methodMap)

Initialize the specified "methodMap", if any.

Parameters
methodMap Map from method names to TransactionAttribute instances

protected boolean isMatch (String methodName, String mappedName)

Return if the given method name matches the mapped name.

The default implementation checks for "xxx*", "*xxx" and "*xxx*" matches, as well as direct equality.

Parameters
methodName the method name of the class
mappedName the name in the descriptor
Returns
  • if the names match