Package org.springframework.transaction.interceptor

# Class NameMatchTransactionAttributeSource

java.lang.Object
org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource

All Implemented Interfaces:
  `Serializable`, `org.springframework.beans.factory.Aware`, `org.springframework.beans.factory.InitializingBean`, `org.springframework.context.EmbeddedValueResolverAware`, `TransactionAttributeSource`

public class NameMatchTransactionAttributeSource extends Object implements TransactionAttributeSource, org.springframework.context.EmbeddedValueResolverAware, org.springframework.beans.factory.InitializingBean, Serializable
Simple `TransactionAttributeSource` implementation that allows attributes to be matched by registered name.

Since:
  21.08.2003
Author:
  Juergen Hoeller
See Also:
  - `isMatch(java.lang.String, java.lang.String)`
  - `MethodMapTransactionAttributeSource`
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`protected static final org.apache.commons.logging.Log`
`logger`
Logger available to subclasses.

## Constructor Summary

Constructors
Constructor
Description
`NameMatchTransactionAttributeSource()`

## Method Summary

Modifier and Type
Method
Description
`void`
`addTransactionalMethod(String methodName, TransactionAttribute attr)`
Add an attribute for a transactional method.
`void`
`afterPropertiesSet()`
`boolean`
`equals(Object other)`
`TransactionAttribute`
`getTransactionAttribute(Method method, Class<?> targetClass)`
Return the transaction attribute for the given method, or `null` if the method is non-transactional.
`int`
`hashCode()`
`protected boolean`
`isMatch(String methodName, String mappedName)`
Determine if the given method name matches the mapped name.
`void`
`setEmbeddedValueResolver(org.springframework.util.StringValueResolver resolver)`
`void`
`setNameMap(Map<String,TransactionAttribute> nameMap)`
Set a name/attribute map, consisting of method names (for example, "myMethod") and `TransactionAttribute` instances.
`void`
`setProperties(Properties transactionAttributes)`
Parse the given properties into a name/attribute map.
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.springframework.transaction.interceptor.TransactionAttributeSource

`hasTransactionAttribute, isCandidateClass`

## Field Details

### logger

protected static final org.apache.commons.logging.Log logger
Logger available to subclasses.

Static for optimal serialization.

## Constructor Details

### NameMatchTransactionAttributeSource

public NameMatchTransactionAttributeSource()

## Method Details

### setNameMap

public void setNameMap(Map<String,TransactionAttribute> nameMap)
Set a name/attribute map, consisting of method names (for example, "myMethod") and `TransactionAttribute` instances.

See Also:
  - `setProperties(java.util.Properties)`
  - `TransactionAttribute`

### setProperties

public void setProperties(Properties transactionAttributes)
Parse the given properties into a name/attribute map.

Expects method names as keys and String attributes definitions as values, parsable into `TransactionAttribute` instances via a `TransactionAttributeEditor`.

See Also:
  - `setNameMap(java.util.Map<java.lang.String, org.springframework.transaction.interceptor.TransactionAttribute>)`
  - `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.

Parameters:
  `methodName` - the name of the method
  `attr` - attribute associated with the method

### setEmbeddedValueResolver

public void setEmbeddedValueResolver(org.springframework.util.StringValueResolver resolver)

Specified by:
  `setEmbeddedValueResolver` in interface `org.springframework.context.EmbeddedValueResolverAware`

### afterPropertiesSet

public void afterPropertiesSet()

Specified by:
  `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`

### getTransactionAttribute

@Nullable public TransactionAttribute getTransactionAttribute(Method method, @Nullable 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 (can be `null`, in which case the declaring class of the method must be used)
Returns:
  the matching transaction attribute, or `null` if none found

### isMatch

protected boolean isMatch(String methodName, String mappedName)
Determine 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.

Parameters:
  `methodName` - the method name of the class
  `mappedName` - the name in the descriptor
Returns:
  `true` if the names match
See Also:
  - `PatternMatchUtils.simpleMatch(String, String)`

### equals

public boolean equals(@Nullable Object other)

Overrides:
  `equals` in class `Object`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`