org.springframework.transaction.interceptor

Class MethodMapTransactionAttributeSource

  • java.lang.Object
    • org.springframework.transaction.interceptor.MethodMapTransactionAttributeSource
    • Field Detail

      • logger

        protected final Log logger
        Logger available to subclasses.
    • Constructor Detail

      • MethodMapTransactionAttributeSource

        public MethodMapTransactionAttributeSource()
    • Method Detail

      • setMethodMap

        public void setMethodMap(java.util.Map<java.lang.String,TransactionAttribute> methodMap)
        Set a name/attribute map, consisting of "FQCN.method" method names (e.g. "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:
        TransactionAttribute, TransactionAttributeEditor
      • addTransactionalMethod

        public void addTransactionalMethod(java.lang.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:
        java.lang.IllegalArgumentException - in case of an invalid name
      • addTransactionalMethod

        public void addTransactionalMethod(java.lang.Class<?> clazz,
                                           java.lang.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(java.lang.reflect.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(java.lang.String methodName,
                                  java.lang.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:
        PatternMatchUtils.simpleMatch(String, String)
      • getTransactionAttribute

        @Nullable
        public TransactionAttribute getTransactionAttribute(java.lang.reflect.Method method,
                                                                      @Nullable
                                                                      java.lang.Class<?> targetClass)
        Description copied from interface: TransactionAttributeSource
        Return the transaction attribute for the given method, or null if the method is non-transactional.
        Specified by:
        getTransactionAttribute in interface TransactionAttributeSource
        Parameters:
        method - the method to introspect
        targetClass - the target class (may be null, in which case the declaring class of the method must be used)
        Returns:
        the TransactionAttribute the matching transaction attribute, or null if none found
      • equals

        public boolean equals(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object