You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2006/03/13 19:32:07 UTC

svn commit: r385615 - in /ibatis/trunk/cs/mapper: IBatisNet.Common.Test/ IBatisNet.Common.Test/NUnit/CommonTests/Utilities/ IBatisNet.Common/ IBatisNet.Common/Utilities/Objects/

Author: gbayon
Date: Mon Mar 13 10:32:04 2006
New Revision: 385615

URL: http://svn.apache.org/viewcvs?rev=385615&view=rev
Log:
- Added class Timer to do Unit test
- Updated 2005 solution

Added:
    ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/Timer.cs   (with props)
Modified:
    ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.2005.csproj
    ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.csproj
    ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/ObjectFactoryTest.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.2005.csproj
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/EmitObjectFactory.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ObjectFactory.cs

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.2005.csproj
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.2005.csproj?rev=385615&r1=385614&r2=385615&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.2005.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.2005.csproj Mon Mar 13 10:32:04 2006
@@ -103,6 +103,7 @@
     <Compile Include="Domain\Account.cs">
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="Domain\Simple.cs" />
     <Compile Include="NUnit\CommonTests\ConfigWatcher\ConfigWatcherTest.cs">
       <SubType>Code</SubType>
     </Compile>
@@ -130,10 +131,12 @@
     <Compile Include="NUnit\CommonTests\Transaction\TransactionTest.cs">
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="NUnit\CommonTests\Utilities\ObjectFactoryTest.cs" />
     <Compile Include="NUnit\CommonTests\Utilities\PropertyAccessorTest.cs" />
     <Compile Include="NUnit\CommonTests\Utilities\ResourcesTest.cs">
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="NUnit\CommonTests\Utilities\Timer.cs" />
     <Compile Include="NUnit\CommonTests\Utilities\TypeResolverTest.cs" />
     <None Include="bin\Debug\dao_Access_OleDb.config" />
     <None Include="bin\Debug\dao_MSSQL_Odbc.config" />

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.csproj
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.csproj?rev=385615&r1=385614&r2=385615&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.csproj Mon Mar 13 10:32:04 2006
@@ -305,6 +305,11 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "NUnit\CommonTests\Utilities\Timer.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "Scripts\Access\account-init.sql"
                     BuildAction = "Content"
                 />

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/ObjectFactoryTest.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/ObjectFactoryTest.cs?rev=385615&r1=385614&r2=385615&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/ObjectFactoryTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/ObjectFactoryTest.cs Mon Mar 13 10:32:04 2006
@@ -1,6 +1,3 @@
-using System.ComponentModel;
-using System.Runtime.InteropServices;
-using System.Threading;
 using IBatisNet.Common.Test.Domain;
 using IBatisNet.Common.Utilities.Objects;
 using NUnit.Framework;
@@ -47,7 +44,7 @@
 			GC.Collect();
 			GC.WaitForPendingFinalizers();
 
-			HiPerformanceTimer timer = new HiPerformanceTimer();
+			Timer timer = new Timer();
 			timer.Start();
 			for (int i = 0; i < TEST_ITERATIONS; i++)
 			{
@@ -112,43 +109,5 @@
 			}
 		}
 
-		internal class HiPerformanceTimer
-		{
-			[DllImport("Kernel32.dll")]
-			private static extern bool QueryPerformanceCounter(out long lpPerformanceCount);
-
-			[DllImport("Kernel32.dll")]
-			private static extern bool QueryPerformanceFrequency(out long lpFrequency);
-
-			private long startTime, stopTime;
-			private long freq;
-
-			public HiPerformanceTimer()
-			{
-				startTime = 0;
-				stopTime = 0;
-
-				if (QueryPerformanceFrequency(out freq) == false)
-				{
-					throw new Win32Exception();
-				}
-			}
-
-			public void Start()
-			{
-				Thread.Sleep(0);
-				QueryPerformanceCounter(out startTime);
-			}
-
-			public void Stop()
-			{
-				QueryPerformanceCounter(out stopTime);
-			}
-
-			public double Duration
-			{
-				get { return (double) (stopTime - startTime)/(double) freq; }
-			}
-		}
 	}
 }

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs?rev=385615&r1=385614&r2=385615&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs Mon Mar 13 10:32:04 2006
@@ -39,34 +39,46 @@
             const int TEST_ITERATIONS = 1000000;
         	Account account = new Account();
             int test = -1;
+			Timer timer = new Timer();
 
 			#region Direct access (fastest)
-			long time = DateTime.Now.Ticks;
+			GC.Collect();
+			GC.WaitForPendingFinalizers();
+
+			timer.Start();
 			for (int i = 0; i < TEST_ITERATIONS; i++)
 			{
 				test = -1;
 				test = account.Id;
 				Assert.AreEqual(0, test);
 			}
-			long directAccessMs = DateTime.Now.Ticks - time;
+			timer.Stop();
+			double directAccessDuration = 1000000 * (timer.Duration / (double)TEST_ITERATIONS);
 			#endregion
 
 			#region IL Property accessor
-        	IPropertyAccessor propertyAccessor = ILPropertyAccessor.CreatePropertyAccessor(typeof(Account), "Id");
-			time = DateTime.Now.Ticks;
-            for (int i = 0; i < TEST_ITERATIONS; i++)
-            {
-                test = -1;
-                test = (int)propertyAccessor.Get(account);
-                Assert.AreEqual(0, test);
-            }
-            long propertyAccessorMs = DateTime.Now.Ticks - time;
-			float propertyAccessorRatio = (float)propertyAccessorMs / directAccessMs;
+			GC.Collect();
+			GC.WaitForPendingFinalizers();
+
+			IPropertyAccessor propertyAccessor = ILPropertyAccessor.CreatePropertyAccessor(typeof(Account), "Id");
+			timer.Start();
+			for (int i = 0; i < TEST_ITERATIONS; i++)
+			{
+				test = -1;
+				test = (int)propertyAccessor.Get(account);
+				Assert.AreEqual(0, test);
+			}
+			timer.Stop();
+			double propertyAccessorDuration = 1000000 * (timer.Duration / (double)TEST_ITERATIONS);
+			double propertyAccessorRatio = propertyAccessorDuration / directAccessDuration;
 			#endregion
 
 			#region IBatisNet.Common.Utilities.Object.ReflectionInfo
+			GC.Collect();
+			GC.WaitForPendingFinalizers();
+
 			ReflectionInfo reflectionInfo = ReflectionInfo.GetInstance(account.GetType());
-			time = DateTime.Now.Ticks;
+			timer.Start();
 			for (int i = 0; i < TEST_ITERATIONS; i++)
 			{
 				test = -1;
@@ -74,13 +86,17 @@
 				test = (int)propertyInfo.GetValue(account, null);
 				Assert.AreEqual(0, test);
 			}
-			long reflectionInfoMs = DateTime.Now.Ticks - time;
-			float reflectionInfoRatio = (float)reflectionInfoMs / directAccessMs;
+			timer.Stop();
+			double reflectionInfoDuration = 1000000 * (timer.Duration / (double)TEST_ITERATIONS);
+			double reflectionInfoRatio = (float)reflectionInfoDuration / directAccessDuration;
 			#endregion
 
 			#region Reflection
+			GC.Collect();
+			GC.WaitForPendingFinalizers();
+
 			Type type = account.GetType();
-			time = DateTime.Now.Ticks;
+			timer.Start();
 			for (int i = 0; i < TEST_ITERATIONS; i++)
 			{
 				test = -1;
@@ -88,13 +104,16 @@
 				test = (int)propertyInfo.GetValue(account, null);
 				Assert.AreEqual(0, test);
 			}
-			long reflectionMs = DateTime.Now.Ticks - time;
-			float reflectionRatio = (float)reflectionMs / directAccessMs;
+			timer.Stop();
+			double reflectionDuration = 1000000 * (timer.Duration / (double)TEST_ITERATIONS);
+			double reflectionRatio = reflectionDuration / directAccessDuration;
 			#endregion
 
 			#region ReflectionInvokeMember (slowest)
-			type = account.GetType();
-			time = DateTime.Now.Ticks;
+			GC.Collect();
+			GC.WaitForPendingFinalizers();
+
+			timer.Start();
 			for (int i = 0; i < TEST_ITERATIONS; i++)
 			{
 				test = -1;
@@ -103,17 +122,18 @@
 					null, account, null);
 				Assert.AreEqual(0, test);
 			}
-			long reflectionInvokeMemberMs = DateTime.Now.Ticks - time;
-			float reflectionInvokeMemberRatio = (float)reflectionInvokeMemberMs / directAccessMs;
+			timer.Stop();
+			double reflectionInvokeMemberDuration = 1000000 * (timer.Duration / (double)TEST_ITERATIONS);
+			double reflectionInvokeMemberRatio = reflectionInvokeMemberDuration / directAccessDuration;
 			#endregion
 
 			// Print results
 			Console.WriteLine("{0} property gets on integer...", TEST_ITERATIONS);
-			Console.WriteLine("Direct access: \t\t{0} ms", directAccessMs);
-			Console.WriteLine("IPropertyAccessor: \t\t{0} ms Ratio: {1}", propertyAccessorMs, propertyAccessorRatio);
-			Console.WriteLine("IBatisNet ReflectionInfo: \t{0} ms Ratio: {1}", reflectionInfoMs, reflectionInfoRatio);
-			Console.WriteLine("ReflectionInvokeMember: \t{0} ms Ratio: {1}", reflectionInvokeMemberMs, reflectionInvokeMemberRatio);
-			Console.WriteLine("Reflection: \t\t\t{0} ms Ratio: {1}", reflectionMs, reflectionRatio);
+			Console.WriteLine("Direct access: \t\t{0} ", directAccessDuration.ToString("F3"));
+			Console.WriteLine("IPropertyAccessor: \t\t{0} Ratio: {1}", propertyAccessorDuration.ToString("F3"), propertyAccessorRatio.ToString("F3"));
+			Console.WriteLine("IBatisNet ReflectionInfo: \t{0} Ratio: {1}", reflectionInfoDuration.ToString("F3"), reflectionInfoRatio.ToString("F3"));
+			Console.WriteLine("ReflectionInvokeMember: \t{0} Ratio: {1}", reflectionInvokeMemberDuration.ToString("F3"), reflectionInvokeMemberRatio.ToString("F3"));
+			Console.WriteLine("Reflection: \t\t\t{0} Ratio: {1}", reflectionDuration.ToString("F3"), reflectionRatio.ToString("F3"));
         }
         
 		/// <summary>
@@ -125,72 +145,91 @@
             const int TEST_ITERATIONS = 1000000;
             Account account = new Account();
             int value = 123;
+            Timer timer = new Timer();
 
 			#region Direct access (fastest)
-			long start = DateTime.Now.Ticks;
+			GC.Collect();
+			GC.WaitForPendingFinalizers();
+
+            timer.Start();
 			for (int i = 0; i < TEST_ITERATIONS; i++)
 			{
 				account.Id = value;
 			}
-			long directAccessMs = DateTime.Now.Ticks - start;
+            timer.Stop();
+            double directAccessDuration = 1000000 * (timer.Duration / (double)TEST_ITERATIONS);
 			#endregion
 
 			#region Property accessor
+			GC.Collect();
+			GC.WaitForPendingFinalizers();
+
             IPropertyAccessor propertyAccessor = ILPropertyAccessor.CreatePropertyAccessor(typeof(Account), "Id");
-            start = DateTime.Now.Ticks;
+            timer.Start();
             for (int i = 0; i < TEST_ITERATIONS; i++)
             {
                 propertyAccessor.Set(account, value);
             }
-            long propertyAccessorMs = DateTime.Now.Ticks - start;
-			float propertyAccessorRatio = (float)propertyAccessorMs / directAccessMs;
+            timer.Stop();
+            double propertyAccessorDuration = 1000000 * (timer.Duration / (double)TEST_ITERATIONS);
+            double propertyAccessorRatio = propertyAccessorDuration / directAccessDuration;
 			#endregion
 
 			#region IBatisNet.Common.Utilities.Object.ReflectionInfo
+			GC.Collect();
+			GC.WaitForPendingFinalizers();
+
 			Type type = account.GetType();
 			ReflectionInfo reflectionInfo = ReflectionInfo.GetInstance(type);
-			start = DateTime.Now.Ticks;
+            timer.Start();
 			for (int i = 0; i < TEST_ITERATIONS; i++)
 			{
 				PropertyInfo propertyInfo = reflectionInfo.GetSetter("Id");
 				propertyInfo.SetValue(account, value, null);
 			}
-			long reflectionInfoMs = DateTime.Now.Ticks - start;
-			float reflectionInfoRatio = (float)reflectionInfoMs / directAccessMs;
+            timer.Stop();
+            double reflectionInfoDuration = 1000000 * (timer.Duration / (double)TEST_ITERATIONS);
+            double reflectionInfoRatio = reflectionInfoDuration / directAccessDuration;
 			#endregion
 
 			#region Reflection
-			type = account.GetType();
-			start = DateTime.Now.Ticks;
+			GC.Collect();
+			GC.WaitForPendingFinalizers();
+
+            timer.Start();
 			for (int i = 0; i < TEST_ITERATIONS; i++)
 			{
 				PropertyInfo propertyInfo = type.GetProperty("Id", BindingFlags.Public | BindingFlags.SetProperty | BindingFlags.Instance);
 				propertyInfo.SetValue(account, value, null);
 			}
-			long reflectionMs = DateTime.Now.Ticks - start;
-			float reflectionRatio = (float)reflectionMs / directAccessMs;
+            timer.Stop();
+            double reflectionDuration = 1000000 * (timer.Duration / (double)TEST_ITERATIONS);
+            double reflectionRatio = reflectionDuration / directAccessDuration;
 			#endregion
 
 			#region ReflectionInvokeMember (slowest)
-            type = account.GetType();
-            start = DateTime.Now.Ticks;
+			GC.Collect();
+			GC.WaitForPendingFinalizers();
+
+            timer.Start();
             for (int i = 0; i < TEST_ITERATIONS; i++)
             {
                 type.InvokeMember("Id",
                     BindingFlags.Public | BindingFlags.SetProperty | BindingFlags.Instance,
                     null, account, new object[] { value });
             }
-            long reflectionInvokeMemberMs = DateTime.Now.Ticks - start;
-			float reflectionInvokeMemberRatio = (float)reflectionInvokeMemberMs / directAccessMs;
+            timer.Stop();
+            double reflectionInvokeMemberDuration = 1000000 * (timer.Duration / (double)TEST_ITERATIONS);
+            double reflectionInvokeMemberRatio = reflectionInvokeMemberDuration / directAccessDuration;
 			#endregion
             
 			// Print results
 			Console.WriteLine("{0} property sets on integer...", TEST_ITERATIONS);
-			Console.WriteLine("Direct access: \t\t{0} ms", directAccessMs);
-			Console.WriteLine("IPropertyAccessor: \t\t{0} ms Ratio: {1}", propertyAccessorMs, propertyAccessorRatio);
-			Console.WriteLine("IBatisNet ReflectionInfo: \t{0} ms Ratio: {1}", reflectionInfoMs, reflectionInfoRatio);
-			Console.WriteLine("ReflectionInvokeMember: \t{0} ms Ratio: {1}", reflectionInvokeMemberMs, reflectionInvokeMemberRatio);
-			Console.WriteLine("Reflection: \t\t\t{0} ms Ratio: {1}", reflectionMs, reflectionRatio);
+            Console.WriteLine("Direct access: \t\t{0} ", directAccessDuration.ToString("F3"));
+            Console.WriteLine("IPropertyAccessor: \t\t{0} Ratio: {1}", propertyAccessorDuration.ToString("F3"), propertyAccessorRatio.ToString("F3"));
+            Console.WriteLine("IBatisNet ReflectionInfo: \t{0} Ratio: {1}", reflectionInfoDuration.ToString("F3"), reflectionInfoRatio.ToString("F3"));
+            Console.WriteLine("ReflectionInvokeMember: \t{0} Ratio: {1}", reflectionInvokeMemberDuration.ToString("F3"), reflectionInvokeMemberRatio.ToString("F3"));
+            Console.WriteLine("Reflection: \t\t\t{0} Ratio: {1}", reflectionDuration.ToString("F3"), reflectionRatio.ToString("F3"));
         }
        
 		/// <summary>

Added: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/Timer.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/Timer.cs?rev=385615&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/Timer.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/Timer.cs Mon Mar 13 10:32:04 2006
@@ -0,0 +1,46 @@
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Threading;
+
+namespace IBatisNet.Common.Test.NUnit.CommonTests.Utilities
+{
+    public class Timer
+    {
+            [DllImport("Kernel32.dll")]
+			private static extern bool QueryPerformanceCounter(out long lpPerformanceCount);
+
+			[DllImport("Kernel32.dll")]
+			private static extern bool QueryPerformanceFrequency(out long lpFrequency);
+
+			private long startTime, stopTime;
+			private long freq;
+
+			public Timer()
+			{
+				startTime = 0;
+				stopTime = 0;
+
+				if (QueryPerformanceFrequency(out freq) == false)
+				{
+					throw new Win32Exception();
+				}
+			}
+
+			public void Start()
+			{
+				Thread.Sleep(0);
+				QueryPerformanceCounter(out startTime);
+			}
+
+			public void Stop()
+			{
+				QueryPerformanceCounter(out stopTime);
+			}
+
+			public double Duration
+			{
+				get { return (double) (stopTime - startTime)/(double) freq; }
+			}
+    }
+}

Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/Timer.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/Timer.cs
------------------------------------------------------------------------------
    svn:keywords = Id LastChangedDate LastChangedBy

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.2005.csproj
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.2005.csproj?rev=385615&r1=385614&r2=385615&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.2005.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.2005.csproj Mon Mar 13 10:32:04 2006
@@ -192,8 +192,15 @@
     <Compile Include="Utilities\HashCodeProvider.cs">
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="Utilities\Objects\ActivatorFactory.cs" />
+    <Compile Include="Utilities\Objects\ActivatorObjectFactory.cs" />
+    <Compile Include="Utilities\Objects\EmitObjectFactory.cs" />
+    <Compile Include="Utilities\Objects\FactoryBuilder.cs" />
+    <Compile Include="Utilities\Objects\IFactory.cs" />
     <Compile Include="Utilities\Objects\ILPropertyAccessor.cs" />
+    <Compile Include="Utilities\Objects\IObjectFactory.cs" />
     <Compile Include="Utilities\Objects\IPropertyAccessor.cs" />
+    <Compile Include="Utilities\Objects\ObjectFactory.cs" />
     <Compile Include="Utilities\Objects\ObjectProbe.cs">
       <SubType>Code</SubType>
     </Compile>

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/EmitObjectFactory.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/EmitObjectFactory.cs?rev=385615&r1=385614&r2=385615&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/EmitObjectFactory.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/EmitObjectFactory.cs Mon Mar 13 10:32:04 2006
@@ -32,10 +32,12 @@
 	/// <summary>
 	/// A factory that can create objects via IL code
 	/// </summary>
-	public class EmitObjectFactory : IObjectFactory
+	public sealed class EmitObjectFactory : IObjectFactory
 	{
 		private IDictionary _cachedfactories = new HybridDictionary();
 		private FactoryBuilder _factoryBuilder = null;
+		private object _padlock = new object();
+
 
 		/// <summary>
 		/// 
@@ -55,10 +57,17 @@
 		public IFactory CreateFactory(Type typeToCreate)
 		{
 			IFactory factory = (IFactory) _cachedfactories[typeToCreate];
-			if (null == factory)
+			if (factory == null)
 			{
-				factory = _factoryBuilder.CreateFactory(typeToCreate);
-				_cachedfactories[typeToCreate] = factory;
+				lock (_padlock)
+				{
+					factory = (IFactory) _cachedfactories[typeToCreate];
+					if (factory == null) // double-check
+					{
+						factory = _factoryBuilder.CreateFactory(typeToCreate);
+						_cachedfactories[typeToCreate] = factory;
+					}
+				}
 			}
 			return factory;
 		}

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ObjectFactory.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ObjectFactory.cs?rev=385615&r1=385614&r2=385615&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ObjectFactory.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ObjectFactory.cs Mon Mar 13 10:32:04 2006
@@ -28,7 +28,7 @@
 namespace IBatisNet.Common.Utilities.Objects
 {
 	/// <summary>
-	/// Description résumée de ObjectFactory.
+	/// A factory to create objects 
 	/// </summary>
 	public class ObjectFactory : IObjectFactory
 	{