org.springframework.transaction.interceptor
Class MethodMapTransactionAttributeSource

java.lang.Object
  extended byorg.springframework.transaction.interceptor.MethodMapTransactionAttributeSource
All Implemented Interfaces:
TransactionAttributeSource

public class MethodMapTransactionAttributeSource
extends Object
implements TransactionAttributeSource

Simple implementation of TransactionAttributeSource that allows attributes to be stored per method in a map.

Since:
24-Apr-2003
Author:
Rod Johnson, Juergen Hoeller
See Also:
isMatch(java.lang.String, java.lang.String), NameMatchTransactionAttributeSource

Field Summary
protected  Log logger
           
 
Constructor Summary
MethodMapTransactionAttributeSource()
           
 
Method Summary
 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.
 TransactionAttribute getTransactionAttribute(Method method, Class targetClass)
          Return the transaction attribute for this method.
protected  boolean isMatch(String methodName, String mappedName)
          Return if the given method name matches the mapped name.
 void setMethodMap(Map methodMap)
          Set a name/attribute map, consisting of "FQCN.method" method names (e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Constructor Detail

MethodMapTransactionAttributeSource

public MethodMapTransactionAttributeSource()
Method Detail

setMethodMap

public void setMethodMap(Map 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).

See Also:
TransactionAttribute, TransactionAttributeEditor

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

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*" and "*xxx" matches. Can be overridden in subclasses.

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

getTransactionAttribute

public TransactionAttribute getTransactionAttribute(Method method,
                                                    Class targetClass)
Description copied from interface: TransactionAttributeSource
Return the transaction attribute for this method. Return null if the method is non-transactional.

Specified by:
getTransactionAttribute in interface TransactionAttributeSource
Parameters:
method - method
targetClass - target class. May be null, in which case the declaring class of the method must be used.
Returns:
TransactionAttribute transaction attribute or null.


Copyright (C) 2003-2004 The Spring Framework Project.