类 NameMatchTransactionAttributeSource
- java.lang.Object
- org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource
- 所有已实现的接口:
Serializable,TransactionAttributeSource
public class NameMatchTransactionAttributeSource extends Object implements TransactionAttributeSource, Serializable
SimpleTransactionAttributeSourceimplementation that allows attributes to be matched by registered name.- 从以下版本开始:
- 21.08.2003
- 作者:
- Juergen Hoeller
- 另请参阅:
isMatch(java.lang.String, java.lang.String),MethodMapTransactionAttributeSource, 序列化表格
构造器概要
构造器 构造器 说明 NameMatchTransactionAttributeSource()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidaddTransactionalMethod(String methodName, TransactionAttribute attr)Add an attribute for a transactional method.booleanequals(Object other)TransactionAttributegetTransactionAttribute(Method method, Class<?> targetClass)Return the transaction attribute for the given method, ornullif the method is non-transactional.inthashCode()protected booleanisMatch(String methodName, String mappedName)Return if the given method name matches the mapped name.voidsetNameMap(Map<String,TransactionAttribute> nameMap)Set a name/attribute map, consisting of method names (e.g.voidsetProperties(Properties transactionAttributes)Parses the given properties into a name/attribute map.StringtoString()从接口继承的方法 org.springframework.transaction.interceptor.TransactionAttributeSource
isCandidateClass
构造器详细资料
NameMatchTransactionAttributeSource
public NameMatchTransactionAttributeSource()
方法详细资料
setNameMap
public void setNameMap(Map<String,TransactionAttribute> nameMap)
Set a name/attribute map, consisting of method names (e.g. "myMethod") and TransactionAttribute instances (or Strings to be converted to TransactionAttribute instances).
setProperties
public void setProperties(Properties transactionAttributes)
Parses the given properties into a name/attribute map. Expects method names as keys and String attributes definitions as values, parsable into TransactionAttribute instances via TransactionAttributeEditor.
addTransactionalMethod
public void addTransactionalMethod(String methodName, TransactionAttribute attr)
Add an attribute for a transactional method.Method names can be exact matches, or of the pattern "xxx*", "*xxx" or "*xxx*" for matching multiple methods.
- 参数:
methodName- the name of the methodattr- attribute associated with the method
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
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. Can be overridden in subclasses.
- 参数:
methodName- the method name of the classmappedName- the name in the descriptor- 返回:
- if the names match
- 另请参阅:
PatternMatchUtils.simpleMatch(String, String)