Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data/Transaction/Interceptor
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv1203
Modified Files:
MethodMapTransactionAttributeSource.cs
NameMatchTransactionAttributeSource.cs
TransactionAspectSupport.cs
Log Message:
SPRNET-945 - NameMatchTransactionAttributeSource to support conversion of string representation do specify transaction attributes
Index: TransactionAspectSupport.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data/Transaction/Interceptor/TransactionAspectSupport.cs,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** TransactionAspectSupport.cs 7 Dec 2007 08:10:03 -0000 1.14
--- TransactionAspectSupport.cs 27 May 2008 19:06:57 -0000 1.15
***************
*** 284,288 ****
{
NameMatchTransactionAttributeSource attributeSource = new NameMatchTransactionAttributeSource();
! attributeSource.SetProperties( value );
_transactionAttributeSource = attributeSource;
}
--- 284,288 ----
{
NameMatchTransactionAttributeSource attributeSource = new NameMatchTransactionAttributeSource();
! attributeSource.NameProperties = value;
_transactionAttributeSource = attributeSource;
}
Index: MethodMapTransactionAttributeSource.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data/Transaction/Interceptor/MethodMapTransactionAttributeSource.cs,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** MethodMapTransactionAttributeSource.cs 3 Apr 2008 04:48:53 -0000 1.13
--- MethodMapTransactionAttributeSource.cs 27 May 2008 19:06:57 -0000 1.14
***************
*** 26,30 ****
using Common.Logging;
- using Spring.Objects.Factory;
using Spring.Util;
using Spring.Core.TypeResolution;
--- 26,29 ----
***************
*** 65,71 ****
/// <summary>
! /// Set a name/attribute map, consisting of "FQCN.method" method names
! /// (e.g. "com.mycompany.mycode.MyClass.myMethod") and TransactionAttribute
! /// instances.
/// </summary>
/// <remarks>
--- 64,70 ----
/// <summary>
! /// Set a name/attribute map, consisting of "FQCN.method, AssemblyName" method names
! /// (e.g. "MyNameSpace.MyClass.MyMethod, MyAssembly") and ITransactionAttribute
! /// instances (or Strings to be converted to <see cref="ITransactionAttribute"/> instances).
/// </summary>
/// <remarks>
***************
*** 73,80 ****
/// The key values of the supplied <see cref="System.Collections.IDictionary"/>
/// must adhere to the following form:<br/>
! /// <code>FQCN.methodName</code>.
/// </p>
/// <example>
! /// <code>ExampleNamespace.ExampleClass.MyMethod</code>
/// </example>
/// </remarks>
--- 72,79 ----
/// The key values of the supplied <see cref="System.Collections.IDictionary"/>
/// must adhere to the following form:<br/>
! /// <code>FQCN.methodName, Assembly</code>.
/// </p>
/// <example>
! /// <code>MyNameSpace.MyClass.MyMethod, MyAssembly</code>
/// </example>
/// </remarks>
Index: NameMatchTransactionAttributeSource.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data/Transaction/Interceptor/NameMatchTransactionAttributeSource.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** NameMatchTransactionAttributeSource.cs 8 Sep 2006 21:23:39 -0000 1.7
--- NameMatchTransactionAttributeSource.cs 27 May 2008 19:06:57 -0000 1.8
***************
*** 23,26 ****
--- 23,27 ----
using System.Collections.Specialized;
using System.Reflection;
+ using Common.Logging;
using Spring.Util;
***************
*** 37,41 ****
public class NameMatchTransactionAttributeSource : ITransactionAttributeSource
{
! private IDictionary _nameMap;
/// <summary>
--- 38,50 ----
public class NameMatchTransactionAttributeSource : ITransactionAttributeSource
{
! /// <summary>
! /// Logger available to subclasses, static for optimal serialization
! /// </summary>
! protected static readonly ILog log = LogManager.GetLogger(typeof(NameMatchTransactionAttributeSource));
!
! /// <summary>
! /// Keys are method names; values are ITransactionAttributes
! /// </summary>
! private IDictionary nameMap;
/// <summary>
***************
*** 45,61 ****
public NameMatchTransactionAttributeSource()
{
! _nameMap = new Hashtable();
}
/// <summary>
/// Set a name/attribute map, consisting of method names (e.g. "MyMethod") and
! /// <see cref="Spring.Transaction.Interceptor.ITransactionAttribute"/> instances.
/// </summary>
public IDictionary NameMap
{
! set { _nameMap = value; }
}
! /// <summary>
/// Does the supplied <paramref name="methodName"/> match the supplied <paramref name="mappedName"/>?
/// </summary>
--- 54,107 ----
public NameMatchTransactionAttributeSource()
{
! nameMap = new Hashtable();
}
/// <summary>
/// Set a name/attribute map, consisting of method names (e.g. "MyMethod") and
! /// <see cref="Spring.Transaction.Interceptor.ITransactionAttribute"/> instances
! /// (or Strings to be converted to ITransactionAttribute instances).
/// </summary>
public IDictionary NameMap
{
! set
! {
! foreach (DictionaryEntry entry in value)
! {
! string name = entry.Key as string;
! ITransactionAttribute attribute = null;
! if (entry.Value is ITransactionAttribute)
! {
! attribute = entry.Value as ITransactionAttribute;
! }
! else
! {
! TransactionAttributeEditor editor = new TransactionAttributeEditor();
! editor.SetAsText(entry.Value.ToString());
! attribute = editor.Value;
! }
! AddTransactionMethod(name, attribute);
! }
! }
}
! /// <summary>
! /// Parses the given properties into a name/attribute map.
! /// </summary>
! /// <remarks>
! /// Expects method names as keys and string attributes definitions as values,
! /// parsable into <see cref="Spring.Transaction.Interceptor.ITransactionAttribute"/>
! /// instances via
! /// <see cref="Spring.Transaction.Interceptor.TransactionAttributeEditor"/>.
! /// </remarks>
! /// <value>The properties of the transaction.</value>
! public NameValueCollection NameProperties
! {
! set
! {
! SetProperties(value);
! }
! }
!
! /// <summary>
/// Does the supplied <paramref name="methodName"/> match the supplied <paramref name="mappedName"/>?
/// </summary>
***************
*** 85,90 ****
/// </param>
public void AddTransactionMethod( string methodName, ITransactionAttribute attribute )
! {
! _nameMap.Add( methodName, attribute );
}
--- 131,142 ----
/// </param>
public void AddTransactionMethod( string methodName, ITransactionAttribute attribute )
! {
! #region Instrumentation
! if (log.IsDebugEnabled)
! {
! log.Debug("Adding transactional method [" + methodName + "] with attribute [" + attribute + "]");
! }
! #endregion
! nameMap.Add( methodName, attribute );
}
***************
*** 110,114 ****
}
! #region ITransactionAttributeSource Members
/// <summary>
/// Return the <see cref="Spring.Transaction.Interceptor.ITransactionAttribute"/> for this
--- 162,166 ----
}
! #region ITransactionAttributeSource Members
/// <summary>
/// Return the <see cref="Spring.Transaction.Interceptor.ITransactionAttribute"/> for this
***************
*** 127,131 ****
{
string methodName = method.Name;
! ITransactionAttribute attribute = (ITransactionAttribute) _nameMap[methodName];
if ( attribute != null )
{
--- 179,183 ----
{
string methodName = method.Name;
! ITransactionAttribute attribute = (ITransactionAttribute) nameMap[methodName];
if ( attribute != null )
{
***************
*** 135,143 ****
{
string bestNameMatch = null;
! foreach ( string mappedName in _nameMap.Keys )
{
if ( ( IsMatch( methodName, mappedName ) ) && ( bestNameMatch == null || bestNameMatch.Length <= mappedName.Length ) )
{
! attribute = (ITransactionAttribute) _nameMap[mappedName];
bestNameMatch = mappedName;
}
--- 187,195 ----
{
string bestNameMatch = null;
! foreach ( string mappedName in nameMap.Keys )
{
if ( ( IsMatch( methodName, mappedName ) ) && ( bestNameMatch == null || bestNameMatch.Length <= mappedName.Length ) )
{
! attribute = (ITransactionAttribute) nameMap[mappedName];
bestNameMatch = mappedName;
}
|