You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by rg...@apache.org on 2005/11/01 06:32:49 UTC

svn commit: r329983 - in /ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers: CustomTypeHandler.cs TypeHandlerFactory.cs

Author: rgrabowski
Date: Mon Oct 31 21:32:37 2005
New Revision: 329983

URL: http://svn.apache.org/viewcvs?rev=329983&view=rev
Log:
Notify the user when one of the default type handlers is being replaced:

INFO - Replacing type handler [IBatisNet.DataMapper.TypeHandlers.DateTimeTypeHandler] with [Company.Project.Persistence.Impl.NullDateTimeTypeHandlerCallback].

Modified:
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/CustomTypeHandler.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/CustomTypeHandler.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/CustomTypeHandler.cs?rev=329983&r1=329982&r2=329983&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/CustomTypeHandler.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/CustomTypeHandler.cs Mon Oct 31 21:32:37 2005
@@ -45,6 +45,12 @@
 			_callback = callback;
 		}
 
+		public ITypeHandlerCallback Callback
+		{
+			get { return _callback; }
+			set { /* nop */ }
+		}
+
 		/// <summary>
 		/// Performs processing on a value before it is used to set
 		/// the parameter of a IDbCommand.

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs?rev=329983&r1=329982&r2=329983&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs Mon Oct 31 21:32:37 2005
@@ -28,6 +28,8 @@
 
 using System;
 using System.Collections.Specialized;
+using System.Reflection;
+using IBatisNet.Common.Logging;
 
 #endregion 
 
@@ -40,7 +42,8 @@
 	{
 
 		#region Fields
-
+		
+		private static readonly ILog _logger = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType );
 		private HybridDictionary _typeHandlerMap = new HybridDictionary();
 		private ITypeHandler _unknownTypeHandler = null;
 		private const string NULL = "_NULL_TYPE_";
@@ -185,7 +188,7 @@
 		/// Register (add) a type handler for a type and dbType
 		/// </summary>
 		/// <param name="type">the type</param>
-		/// <param name="dbType">the dbType</param>
+		/// <param name="dbType">the dbType (optional, if dbType is null the handler will be used for all dbTypes)</param>
 		/// <param name="handler">the handler instance</param>
 		public void Register(Type type, string dbType, ITypeHandler handler) 
 		{
@@ -197,6 +200,33 @@
 			}
 			if (dbType==null)
 			{
+				if (_logger.IsInfoEnabled)
+				{
+					// notify the user that they are no longer using one of the built-in type handlers
+					ITypeHandler oldTypeHandler = (ITypeHandler)map[NULL];
+
+					if (oldTypeHandler != null)
+					{
+						// the replacement will always(?) be a CustomTypeHandler
+						CustomTypeHandler customTypeHandler = handler as CustomTypeHandler;
+						
+						string replacement = string.Empty;
+						
+						if (customTypeHandler != null)
+						{
+							// report the underlying type
+							replacement = customTypeHandler.Callback.ToString();
+						}
+						else
+						{
+							replacement = handler.ToString();
+						}
+
+						// should oldTypeHandler be checked if its a CustomTypeHandler and if so report the Callback property ???
+						_logger.Info("Replacing type handler [" + oldTypeHandler.ToString() + "] with [" + replacement + "].");
+					}
+				}
+
 				map[NULL] = handler;
 			}
 			else