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 2008/06/07 10:14:34 UTC

svn commit: r664296 - in /ibatis/trunk/cs/V3/src: Apache.Ibatis.DataMapper.SqlClient.Test.2005/ Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/ Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/ Apache.Ibatis.DataMapper.SqlClient.Test....

Author: gbayon
Date: Sat Jun  7 01:14:33 2008
New Revision: 664296

URL: http://svn.apache.org/viewvc?rev=664296&view=rev
Log:
Allow cache model, reflection optimizer, namespace statement setting via code (Xml setting will override code configuration), see class ConfigurationSetting + cosmetic change

Added:
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/NVelocityDynamicEngine.cs
      - copied, changed from r663710, ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/NVelocitySqlSource.cs
Removed:
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/NVelocitySqlSource.cs
Modified:
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Apache.Ibatis.DataMapper.SqlClient.Test.2005.csproj
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/VelocityTest.cs
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Modules/AliasModule.cs
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ConfigurationSetting.cs
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/DefaultModelBuilder.cs
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatement.cs
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Cache/Memory/MemoryCacheControler.cs
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/IModelStore.cs

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Apache.Ibatis.DataMapper.SqlClient.Test.2005.csproj
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Apache.Ibatis.DataMapper.SqlClient.Test.2005.csproj?rev=664296&r1=664295&r2=664296&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Apache.Ibatis.DataMapper.SqlClient.Test.2005.csproj (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Apache.Ibatis.DataMapper.SqlClient.Test.2005.csproj Sat Jun  7 01:14:33 2008
@@ -45,7 +45,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Domain\JsonInterpreter.cs" />
-    <Compile Include="Domain\NVelocitySqlSource.cs" />
+    <Compile Include="Domain\NVelocityDynamicEngine.cs" />
     <Compile Include="Domain\SimpleSqlSource.cs" />
     <Compile Include="Domain\SqlSourceWithInlineParameter.cs" />
     <Compile Include="Domain\SqlSourceWithParameter.cs" />

Copied: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/NVelocityDynamicEngine.cs (from r663710, ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/NVelocitySqlSource.cs)
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/NVelocityDynamicEngine.cs?p2=ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/NVelocityDynamicEngine.cs&p1=ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/NVelocitySqlSource.cs&r1=663710&r2=664296&rev=664296&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/NVelocitySqlSource.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/NVelocityDynamicEngine.cs Sat Jun  7 01:14:33 2008
@@ -14,21 +14,21 @@
 {
     /// <summary>
     /// NVelocity implemantation of <see cref="ISqlSource"/>
-    /// which parse sql string
+    /// which parse sql string using Velocity language
     /// </summary>
     /// <remarks>
     /// See http://www.castleproject.org/others/nvelocity/index.html
     /// </remarks>
-    public class NVelocitySqlSource : ISqlSource
+    public class NVelocityDynamicEngine : ISqlSource
     {
         private readonly VelocityEngine velocityEngine = null;
         private const string VELOCITY_DIRECTIVE = "$";
         private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 
         /// <summary>
-        /// Initializes a new instance of the <see cref="NVelocitySqlSource"/> class.
+        /// Initializes a new instance of the <see cref="NVelocityDynamicEngine"/> class.
         /// </summary>
-        public NVelocitySqlSource()
+        public NVelocityDynamicEngine()
         {
             velocityEngine = new VelocityEngine();
             velocityEngine.Init();

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/VelocityTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/VelocityTest.cs?rev=664296&r1=664295&r2=664296&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/VelocityTest.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/VelocityTest.cs Sat Jun  7 01:14:33 2008
@@ -28,7 +28,7 @@
             IResource resource = ResourceLoaderRegistry.GetResource(uri);
 
             ConfigurationSetting setting = new ConfigurationSetting();
-            setting.DynamicSqlEngine = new NVelocitySqlSource();
+            setting.DynamicSqlEngine = new NVelocityDynamicEngine();
 
             IConfigurationEngine engine = new DefaultConfigurationEngine(setting);
             engine.RegisterInterpreter(new XmlConfigurationInterpreter(resource));

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Modules/AliasModule.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Modules/AliasModule.cs?rev=664296&r1=664295&r2=664296&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Modules/AliasModule.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Modules/AliasModule.cs Sat Jun  7 01:14:33 2008
@@ -14,7 +14,7 @@
             RegisterAlias<SimpleSqlSource>();
             RegisterAlias<SqlSourceWithParameter>();
             RegisterAlias<SqlSourceWithInlineParameter>();
-            RegisterAlias<NVelocitySqlSource>();
+            RegisterAlias<NVelocityDynamicEngine>();
 
         }
     }

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ConfigurationSetting.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ConfigurationSetting.cs?rev=664296&r1=664295&r2=664296&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ConfigurationSetting.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ConfigurationSetting.cs Sat Jun  7 01:14:33 2008
@@ -48,6 +48,10 @@
         private bool validateMapperConfigFile = false;
         private ISqlSource dynamicSqlEngine = null;
 
+        private bool useStatementNamespaces = false;
+        private bool isCacheModelsEnabled = false;
+        private bool useReflectionOptimizer = true;
+
         /// <summary>
         /// Gets or sets the dynamic SQL engine.
         /// </summary>
@@ -138,5 +142,41 @@
         {
             get { return properties; }
         }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether the DataMapper use statement namespaces.
+        /// </summary>
+        /// <value>
+        /// 	<c>true</c> if [use statement namespaces]; otherwise, <c>false</c>.
+        /// </value>
+        public bool UseStatementNamespaces
+        {
+            get { return useStatementNamespaces; }
+            set { useStatementNamespaces = value; }
+        }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether cache model use is enabled.
+        /// </summary>
+        /// <value>
+        /// 	<c>true</c> if cache model use is enabled; otherwise, <c>false</c>.
+        /// </value>
+        public bool IsCacheModelsEnabled
+        {
+            get { return isCacheModelsEnabled; }
+            set { isCacheModelsEnabled = value; }
+        }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether the DataMapper use reflection optimizer.
+        /// </summary>
+        /// <value>
+        /// 	<c>true</c> if the DataMapper use reflection optimizer; otherwise, <c>false</c>.
+        /// </value>
+        public bool UseReflectionOptimizer
+        {
+            get { return useReflectionOptimizer; }
+            set { useReflectionOptimizer = value; }
+        }
     }
 }

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/DefaultModelBuilder.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/DefaultModelBuilder.cs?rev=664296&r1=664295&r2=664296&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/DefaultModelBuilder.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/DefaultModelBuilder.cs Sat Jun  7 01:14:33 2008
@@ -110,9 +110,7 @@
             ISetAccessorFactory setAccessorFactory = null;
             ISessionFactory sessionFactory = null;
             ISessionStore sessionStore = null;
-
-            LoadSetting(store);
-
+            
             if (configurationSetting != null)
             {
                 objectFactory = configurationSetting.ObjectFactory;
@@ -122,7 +120,13 @@
                 sessionFactory = configurationSetting.SessionFactory;
                 sessionStore = configurationSetting.SessionStore;
                 dynamicSqlEngine = configurationSetting.DynamicSqlEngine;
+                isCacheModelsEnabled = configurationSetting.IsCacheModelsEnabled;
+                useStatementNamespaces = configurationSetting.UseStatementNamespaces;
+                useReflectionOptimizer = configurationSetting.UseReflectionOptimizer;
             }
+            
+            // Xml setting override code setting
+            LoadSetting(store);
 
             if (objectFactory == null)
             {

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatement.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatement.cs?rev=664296&r1=664295&r2=664296&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatement.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatement.cs Sat Jun  7 01:14:33 2008
@@ -117,7 +117,7 @@
         {
             this.modelStore = modelStore;
             this.statement = statement;
-            preparedCommand = PreparedCommandFactory.GetPreparedCommand(false);
+            preparedCommand = new DefaultPreparedCommand();
             resultStrategy = ResultStrategyFactory.Get(this.statement);
         }
         #endregion

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Cache/Memory/MemoryCacheControler.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Cache/Memory/MemoryCacheControler.cs?rev=664296&r1=664295&r2=664296&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Cache/Memory/MemoryCacheControler.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Cache/Memory/MemoryCacheControler.cs Sat Jun  7 01:14:33 2008
@@ -94,8 +94,8 @@
 					if (reference is StrongReference) 
 					{
 						value = ((StrongReference) reference).Target;
-					} 
-					else if (reference is WeakReference) 
+					}
+                    else if (reference is WeakReference && ((WeakReference)reference).IsAlive) 
 					{
 						value = ((WeakReference) reference).Target;
 					}

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/IModelStore.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/IModelStore.cs?rev=664296&r1=664295&r2=664296&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/IModelStore.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/IModelStore.cs Sat Jun  7 01:14:33 2008
@@ -24,17 +24,12 @@
  ********************************************************************************/
 #endregion
 
-using System.Collections.Generic;
-using Apache.Ibatis.Common.Data;
-using Apache.Ibatis.DataMapper.Configuration;
-using Apache.Ibatis.DataMapper.Model.ResultMapping;
-using Apache.Ibatis.DataMapper.TypeHandlers;
-using Apache.Ibatis.DataMapper.Model.ParameterMapping;
-using Apache.Ibatis.DataMapper.Model.Cache;
+using Apache.Ibatis.DataMapper.Data;
 using Apache.Ibatis.DataMapper.DataExchange;
 using Apache.Ibatis.DataMapper.MappedStatements;
-using Apache.Ibatis.Common.Utilities;
-using Apache.Ibatis.DataMapper.Data;
+using Apache.Ibatis.DataMapper.Model.Cache;
+using Apache.Ibatis.DataMapper.Model.ParameterMapping;
+using Apache.Ibatis.DataMapper.Model.ResultMapping;
 using Apache.Ibatis.DataMapper.Session;
 
 namespace Apache.Ibatis.DataMapper.Model