Class MethodMapTransactionAttributeSource

java.lang.Object
org.springframework.transaction.interceptor.MethodMapTransactionAttributeSource
All Implemented Interfaces:
Aware, BeanClassLoaderAware, InitializingBean, EmbeddedValueResolverAware, TransactionAttributeSource

public class MethodMapTransactionAttributeSource extends Object implements TransactionAttributeSource, EmbeddedValueResolverAware, BeanClassLoaderAware, InitializingBean
Simple TransactionAttributeSource implementation that allows attributes to be stored per method in a Map.
Since:
24.04.2003
Author:
Rod Johnson, Juergen Hoeller
See Also:
  • Field Details

    • logger

      protected final org.apache.commons.logging.Log logger
      Logger available to subclasses.
  • Constructor Details

    • MethodMapTransactionAttributeSource

      public MethodMapTransactionAttributeSource()
  • Method Details

    • setMethodMap

      public void setMethodMap(Map<String, TransactionAttribute> methodMap)
      Set a name/attribute map, consisting of "<fully-qualified class name>.<method-name>" method names (for example, "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
      See Also:
    • setEmbeddedValueResolver

      public void setEmbeddedValueResolver(StringValueResolver resolver)
      Description copied from interface: EmbeddedValueResolverAware
      Set the StringValueResolver to use for resolving embedded definition values.
      Specified by:
      setEmbeddedValueResolver in interface EmbeddedValueResolverAware
    • setBeanClassLoader

      public void setBeanClassLoader(ClassLoader beanClassLoader)
      Description copied from interface: BeanClassLoaderAware
      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 InitializingBean.afterPropertiesSet() method or a custom init-method.

      Specified by:
      setBeanClassLoader in interface BeanClassLoaderAware
      Parameters:
      beanClassLoader - the owning class loader
    • afterPropertiesSet

      public void afterPropertiesSet()
      Eagerly initializes the specified "methodMap", if any.
      Specified by:
      afterPropertiesSet in interface InitializingBean
      See Also:
    • initMethodMap

      protected void initMethodMap(@Nullable Map<String, TransactionAttribute> methodMap)
      Initialize the specified "methodMap", if any.
      Parameters:
      methodMap - a Map from method names to TransactionAttribute instances
      See Also:
    • 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.

      Parameters:
      name - class and method name, separated by a dot
      attr - attribute associated with the method
      Throws:
      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.
      Parameters:
      clazz - target interface or class
      mappedName - mapped method name
      attr - attribute associated with the method
    • addTransactionalMethod

      public void addTransactionalMethod(Method method, TransactionAttribute attr)
      Add an attribute for a transactional method.
      Parameters:
      method - the method
      attr - 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.

      Parameters:
      methodName - the method name of the class
      mappedName - the name in the descriptor
      Returns:
      if the names match
      See Also:
    • getTransactionAttribute

      public