public class MethodMapTransactionAttributeSource extends java.lang.Object implements TransactionAttributeSource, BeanClassLoaderAware, InitializingBean
TransactionAttributeSource
implementation that
allows attributes to be stored per method in a Map
.isMatch(java.lang.String, java.lang.String)
,
NameMatchTransactionAttributeSource
Modifier and Type | Field and Description |
---|---|
protected Log |
logger
Logger available to subclasses
|
Constructor and Description |
---|
MethodMapTransactionAttributeSource() |
Modifier and Type | Method and Description |
---|---|
void |
addTransactionalMethod(java.lang.Class<?> clazz,
java.lang.String mappedName,
TransactionAttribute attr)
Add an attribute for a transactional method.
|
void |
addTransactionalMethod(java.lang.reflect.Method method,
TransactionAttribute attr)
Add an attribute for a transactional method.
|
void |
addTransactionalMethod(java.lang.String name,
TransactionAttribute attr)
Add an attribute for a transactional method.
|
void |
afterPropertiesSet()
Eagerly initializes the specified
"methodMap" , if any. |
boolean |
equals(java.lang.Object other) |
TransactionAttribute |
getTransactionAttribute(java.lang.reflect.Method method,
java.lang.Class<?> targetClass)
Return the transaction attribute for the given method,
or
null if the method is non-transactional. |
int |
hashCode() |
protected void |
initMethodMap(java.util.Map<java.lang.String,TransactionAttribute> methodMap)
Initialize the specified
"methodMap" , if any. |
protected boolean |
isMatch(java.lang.String methodName,
java.lang.String mappedName)
Return if the given method name matches the mapped name.
|
void |
setBeanClassLoader(java.lang.ClassLoader beanClassLoader)
Callback that supplies the bean
class loader to
a bean instance. |
void |
setMethodMap(java.util.Map<java.lang.String,TransactionAttribute> methodMap)
Set a name/attribute map, consisting of "FQCN.method" method names
(e.g.
|
java.lang.String |
toString() |
protected final Log logger
public void setMethodMap(java.util.Map<java.lang.String,TransactionAttribute> methodMap)
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.
methodMap
- said Map
from method name to attribute valueTransactionAttribute
,
TransactionAttributeEditor
public void setBeanClassLoader(java.lang.ClassLoader beanClassLoader)
BeanClassLoaderAware
class 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
in interface BeanClassLoaderAware
beanClassLoader
- the owning class loaderpublic void afterPropertiesSet()
"methodMap"
, if any.afterPropertiesSet
in interface InitializingBean
initMethodMap(java.util.Map)
protected void initMethodMap(@Nullable java.util.Map<java.lang.String,TransactionAttribute> methodMap)
"methodMap"
, if any.methodMap
- Map from method names to TransactionAttribute
instancessetMethodMap(java.util.Map<java.lang.String, org.springframework.transaction.interceptor.TransactionAttribute>)
public void addTransactionalMethod(java.lang.String name, TransactionAttribute attr)
Method names can end or start with "*" for matching multiple methods.
name
- class and method name, separated by a dotattr
- attribute associated with the methodjava.lang.IllegalArgumentException
- in case of an invalid namepublic void addTransactionalMethod(java.lang.Class<?> clazz, java.lang.String mappedName, TransactionAttribute attr)
clazz
- target interface or classmappedName
- mapped method nameattr
- attribute associated with the methodpublic void addTransactionalMethod(java.lang.reflect.Method method, TransactionAttribute attr)
method
- the methodattr
- attribute associated with the methodprotected boolean isMatch(java.lang.String methodName, java.lang.String mappedName)
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 descriptorPatternMatchUtils.simpleMatch(String, String)
@Nullable public TransactionAttribute getTransactionAttribute(java.lang.reflect.Method method, @Nullable java.lang.Class<?> targetClass)
TransactionAttributeSource
null
if the method is non-transactional.getTransactionAttribute
in interface TransactionAttributeSource
method
- the method to introspecttargetClass
- the target class (may be null
,
in which case the declaring class of the method must be used)null
if none foundpublic boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object