PDA

View Full Version : NameMatchTransactionAttributeSource configuration error


floyd
08-15-2007, 03:27 AM
Hi all again,

I get a error and I found it's about my NameMatchTransactionAttributeSource configuration. My configuration as following:


<object id="TransactionInterceptor" type="Spring.Transaction.Interceptor.TransactionIntercep tor, Spring.Data">
<property name="TransactionManager" ref="HibernateTransactionManager"/>
<property name="TransactionAttributeSource" ref="NameMatchTransactionAttributeSource"/>
</object>

<object id="MethodMapTransactionAttributeSource" type="Spring.Transaction.Interceptor.MethodMapTransactio nAttributeSource, Spring.Data">
<property name="MethodMap">
<dictionary>
<entry key="XYZ.Service.CategoryService.AcquireNewCategoryDraf t, XYZ" value="PROPAGATION_REQUIRED, -Exception"/>
</dictionary>
</property>
</object>

<object id="MatchAlwaysTransactionAttributeSource" type="Spring.Transaction.Interceptor.MatchAlwaysTransact ionAttributeSource, Spring.Data" />

<object id="NameMatchTransactionAttributeSource" type="Spring.Transaction.Interceptor.NameMatchTransactio nAttributeSource, Spring.Data">
<property name="NameMap">
<dictionary>
<entry key="Acquire*" value="PROPAGATION_REQUIRED, -Exception"/>
<entry key="Get*" value="PROPAGATION_REQUIRED"/>
</dictionary>
</property>
</object>



As above, I could not find any documentation about how to setting NameMatchTransactionAttributeSource, but I found that NameMatchTransactionAttributeSource need to be injected NameMap and consult to SpringFramework in Java, can be used with wildcard within.

Switching to the other two TransactionAttributeSource configurations were okay but MethodMap one is too trvial and MatchAlway one is to general.

Did I misuse?

Mark Pollack
08-17-2007, 04:24 PM
Hi Floyd,

I will update the documentation to include descriptions of the various ITransactionAttributeSource implementations, i.e. MatchAlwaysTransactionAttributeSource, NameMatchTransactionAttributeSource, and MethodMapTransactionAttributeSource.

You are using NameMatchTransactionAttributeSource correctly. You may also include a wildcard before the name as well as also before and after. That is "Work*", "*Work", and "*Work*" are supported. Certainly the MatchAlways one is too general, but can you elaborate more what is you issue with MethodMap? It is quite common to implicitly use NameMatch by specifying the key value pairs inside the TransactionAttributes property of TransactionProxyFactoryObject.

(BTW, I've just come across a bug MethodMapTransactionAttribute, turns out that MethodInfo of say "DoWork" from an inteface IService is not considered equal (in the .Equals sense) to the method "DoWork" in the implementation class.)

Cheers,
Mark