类 MethodMapTransactionAttributeSource
- java.lang.Object
- org.springframework.transaction.interceptor.MethodMapTransactionAttributeSource
public class MethodMapTransactionAttributeSource extends Object implements TransactionAttributeSource, BeanClassLoaderAware, InitializingBean
SimpleTransactionAttributeSourceimplementation that allows attributes to be stored per method in aMap.- 从以下版本开始:
- 24.04.2003
- 作者:
- Rod Johnson, Juergen Hoeller
- 另请参阅:
isMatch(java.lang.String, java.lang.String),NameMatchTransactionAttributeSource
构造器概要
构造器 构造器 说明 MethodMapTransactionAttributeSource()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidaddTransactionalMethod(Class<?> clazz, String mappedName, TransactionAttribute attr)Add an attribute for a transactional method.voidaddTransactionalMethod(Method method, TransactionAttribute attr)Add an attribute for a transactional method.voidaddTransactionalMethod(String name, TransactionAttribute attr)Add an attribute for a transactional method.voidafterPropertiesSet()Eagerly initializes the specified"methodMap", if any.booleanequals(Object other)TransactionAttributegetTransactionAttribute(Method method, Class<?> targetClass)Return the transaction attribute for the given method, ornullif the method is non-transactional.inthashCode()protected voidinitMethodMap(Map<String,TransactionAttribute> methodMap)Initialize the specified"methodMap", if any.protected booleanisMatch(String methodName, String mappedName)Return if the given method name matches the mapped name.voidsetBeanClassLoader(ClassLoader beanClassLoader)Callback that supplies the beanclass loaderto a bean instance.voidsetMethodMap(Map<String,TransactionAttribute> methodMap)Set a name/attribute map, consisting of "FQCN.method" method names (e.g.StringtoString()从接口继承的方法 org.springframework.transaction.interceptor.TransactionAttributeSource
isCandidateClass
构造器详细资料
MethodMapTransactionAttributeSource
public MethodMapTransactionAttributeSource()
方法详细资料
setMethodMap
public void setMethodMap(Map<String,TransactionAttribute> methodMap)
Set a name/attribute map, consisting of "FQCN.method" method names (e.g. "com.mycompany.mycode.MyClass.myMethod") andTransactionAttributeinstances (or Strings to be converted toTransactionAttributeinstances).Intended for configuration via setter injection, typically within a Spring bean factory. Relies on
afterPropertiesSet()being called afterwards.- 参数:
methodMap- saidMapfrom method name to attribute value- 另请参阅:
TransactionAttribute,TransactionAttributeEditor
setBeanClassLoader
public void setBeanClassLoader(ClassLoader beanClassLoader)
从接口复制的说明:BeanClassLoaderAwareCallback that supplies the beanclass loaderto a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean'sInitializingBean.afterPropertiesSet()method or a custom init-method.- 指定者:
setBeanClassLoader在接口中BeanClassLoaderAware- 参数:
beanClassLoader- the owning class loader
afterPropertiesSet
public void afterPropertiesSet()
Eagerly initializes the specified"methodMap", if any.
initMethodMap
protected void initMethodMap(@Nullable Map<String,TransactionAttribute> methodMap)
Initialize the specified"methodMap", if any.- 参数:
methodMap- a Map from method names toTransactionAttributeinstances- 另请参阅:
setMethodMap(java.util.Map<java.lang.String, org.springframework.transaction.interceptor.TransactionAttribute>)
addTransactionalMethod
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.
- 参数:
name- class and method name, separated by a dotattr- attribute associated with the method- 抛出:
IllegalArgumentException- in case of an invalid name
addTransactionalMethod
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.- 参数:
clazz- target interface or classmappedName- mapped method nameattr- attribute associated with the method
addTransactionalMethod
public void addTransactionalMethod(Method method, TransactionAttribute attr)
Add an attribute for a transactional method.- 参数:
method- the methodattr- attribute associated with the method
isMatch
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.
- 参数:
methodName- the method name of the classmappedName- the name in the descriptor- 返回:
- if the names match
- 另请参阅:
PatternMatchUtils.simpleMatch(String, String)
getTransactionAttribute
@Nullable public TransactionAttribute getTransactionAttribute(Method method, @Nullable Class<?> targetClass)
从接口复制的说明:TransactionAttributeSourceReturn the transaction attribute for the given method, ornullif the method is non-transactional.- 指定者:
getTransactionAttribute在接口中TransactionAttributeSource- 参数:
method- the method to introspecttargetClass- the target class (may benull, in which case the declaring class of the method must be used)- 返回:
- the matching transaction attribute, or
nullif none found