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 2005/08/21 09:36:47 UTC

svn commit: r234160 - in /ibatis/trunk/cs/mapper: IBatisNet.Common/IBatisNet.Common.csproj IBatisNet.Common/Utilities/Proxy/IProxyGenerator.cs IBatisNet.Common/Utilities/Proxy/ProxyGeneratorFactory.cs IBatisNet.DataMapper/LazyLoadList.cs

Author: gbayon
Date: Sun Aug 21 00:36:35 2005
New Revision: 234160

URL: http://svn.apache.org/viewcvs?rev=234160&view=rev
Log:
- Added a factory to proxy generator

Added:
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Proxy/IProxyGenerator.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Proxy/ProxyGeneratorFactory.cs
Modified:
    ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/LazyLoadList.cs

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj?rev=234160&r1=234159&r2=234160&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj Sun Aug 21 00:36:35 2005
@@ -323,6 +323,16 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "Utilities\Proxy\IProxyGenerator.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "Utilities\Proxy\ProxyGeneratorFactory.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "Utilities\TypesResolver\CachedTypeResolver.cs"
                     SubType = "Code"
                     BuildAction = "Compile"

Added: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Proxy/IProxyGenerator.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Proxy/IProxyGenerator.cs?rev=234160&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Proxy/IProxyGenerator.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Proxy/IProxyGenerator.cs Sun Aug 21 00:36:35 2005
@@ -0,0 +1,12 @@
+using System;
+
+namespace IBatisNet.Common.Utilities.Proxy
+{
+	/// <summary>
+	/// Description résumée de IProxyGenerator.
+	/// </summary>
+	public interface IProxyGenerator
+	{
+
+	}
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Proxy/ProxyGeneratorFactory.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Proxy/ProxyGeneratorFactory.cs?rev=234160&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Proxy/ProxyGeneratorFactory.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Proxy/ProxyGeneratorFactory.cs Sun Aug 21 00:36:35 2005
@@ -0,0 +1,55 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: $
+ * $Date: $
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2004-2005 - Apache Foundation
+ *  
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ ********************************************************************************/
+#endregion
+
+using System;
+using Castle.DynamicProxy;
+using IBatisNet.Common.Logging;
+
+namespace IBatisNet.Common.Utilities.Proxy
+{
+	/// <summary>
+	///  A Factory for getting the ProxyGenerator.
+	/// </summary>
+	[CLSCompliant(false)]
+	public sealed class ProxyGeneratorFactory
+	{
+		private static readonly ILog log = LogManager.GetLogger( typeof( ProxyGeneratorFactory ) );
+
+		private static ProxyGenerator _generator = new CachedProxyGenerator();
+
+		private ProxyGeneratorFactory()
+		{
+			// should not be created.	
+		}
+
+		/// <summary></summary>
+		public static ProxyGenerator GetProxyGenerator()
+		{
+			//TODO: make this read from a configuration file!!!  At this point anybody
+			// could substitue in their own IProxyGenerator and LazyInitializer.
+			return _generator;
+		}
+	}
+}

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/LazyLoadList.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/LazyLoadList.cs?rev=234160&r1=234159&r2=234160&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/LazyLoadList.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/LazyLoadList.cs Sun Aug 21 00:36:35 2005
@@ -57,7 +57,7 @@
 		private object _loadLock = new object();
 		private static ArrayList _passthroughMethods = new ArrayList();
 
-		private static CachedProxyGenerator _proxyGenerator = new CachedProxyGenerator();
+//		private static CachedProxyGenerator _proxyGenerator = new CachedProxyGenerator();
 		private static readonly ILog _logger = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType );
 		#endregion
 
@@ -107,11 +107,13 @@
 
 			if (mappedSatement.Statement.ListClass != null)
 			{
-				proxList = _proxyGenerator.CreateProxy(typeof(IList), handler, mappedSatement.Statement.CreateInstanceOfListClass());
+				proxList = ProxyGeneratorFactory.GetProxyGenerator().CreateProxy(typeof(IList), handler, mappedSatement.Statement.CreateInstanceOfListClass());
+					//_proxyGenerator.CreateProxy(typeof(IList), handler, mappedSatement.Statement.CreateInstanceOfListClass());
 			}
 			else
 			{
-				proxList = _proxyGenerator.CreateProxy(typeof(IList), handler, new ArrayList());
+				proxList = ProxyGeneratorFactory.GetProxyGenerator().CreateProxy(typeof(IList), handler, new ArrayList());
+					//_proxyGenerator.CreateProxy(typeof(IList), handler, new ArrayList());
 			}
 
 			return (IList) proxList;