类 MethodMapTransactionAttributeSource
- java.lang.Object
- org.springframework.transaction.interceptor.MethodMapTransactionAttributeSource
public class MethodMapTransactionAttributeSource extends Object implements TransactionAttributeSource, BeanClassLoaderAware, InitializingBean
SimpleTransactionAttributeSource
implementation 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()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
addTransactionalMethod(Class<?> clazz, String mappedName, TransactionAttribute attr)
Add an attribute for a transactional method.void
addTransactionalMethod(Method method, 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 the given method, ornull
if the method is non-transactional.int
hashCode()
protected void
initMethodMap(Map<String,TransactionAttribute> methodMap)
Initialize the specified"methodMap"
, if any.protected boolean
isMatch(String methodName, String mappedName)
Return if the given method name matches the mapped name.void
setBeanClassLoader(ClassLoader beanClassLoader)
Callback that supplies the beanclass loader
to a bean instance.void
setMethodMap(Map<String,TransactionAttribute> methodMap)
Set a name/attribute map, consisting of "FQCN.method" method names (e.g.String
toString()
从接口继承的方法 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") andTransactionAttribute
instances (or Strings to be converted toTransactionAttribute
instances).Intended for configuration via setter injection, typically within a Spring bean factory. Relies on
afterPropertiesSet()
being called afterwards.- 参数:
methodMap
- saidMap
from method name to attribute value- 另请参阅:
TransactionAttribute
,TransactionAttributeEditor
setBeanClassLoader
public void setBeanClassLoader(ClassLoader beanClassLoader)
从接口复制的说明:BeanClassLoaderAware
Callback that supplies the beanclass loader
to a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean's
InitializingBean.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 toTransactionAttribute
instances- 另请参阅:
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)
从接口复制的说明:TransactionAttributeSource
Return the transaction attribute for the given method, ornull
if 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
null
if none found