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/28 19:18:00 UTC
svn commit: r672555 - in /ibatis/trunk/cs/V3/src: Apache.Ibatis.Common/
Apache.Ibatis.Common/Resources/
Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/
Apache.Ibatis.DataMapper/Configuration/
Apache.Ibatis.DataMapper/Configuration/Interpreters/C...
Author: gbayon
Date: Sat Jun 28 10:17:59 2008
New Revision: 672555
URL: http://svn.apache.org/viewvc?rev=672555&view=rev
Log:
fix IBATISNET-276
Added:
ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/FileResourceLoadEventArgs.cs
Modified:
ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Apache.Ibatis.Common.2005.csproj
ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/ResourceLoaderRegistry.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/DefaultConfigurationEngineTest.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/DefaultConfigurationEngine.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/IConfigurationEngine.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/AbstractInterpreter.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/IConfigurationInterpreter.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/CachingStatement.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatement.cs
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/MappedStatement.cs
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Apache.Ibatis.Common.2005.csproj
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Apache.Ibatis.Common.2005.csproj?rev=672555&r1=672554&r2=672555&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Apache.Ibatis.Common.2005.csproj (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Apache.Ibatis.Common.2005.csproj Sat Jun 28 10:17:59 2008
@@ -206,6 +206,7 @@
<Compile Include="Logging\LogSetting.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Resources\FileResourceLoadEventArgs.cs" />
<Compile Include="Resources\StaticContentResource.cs" />
<Compile Include="Transaction\IsolationLevel.cs">
<SubType>Code</SubType>
Added: ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/FileResourceLoadEventArgs.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/FileResourceLoadEventArgs.cs?rev=672555&view=auto
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/FileResourceLoadEventArgs.cs (added)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/FileResourceLoadEventArgs.cs Sat Jun 28 10:17:59 2008
@@ -0,0 +1,48 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 476843 $
+ * $LastChangedDate: 2008-06-08 20:20:44 +0200 (dim., 08 juin 2008) $
+ * $LastChangedBy: gbayon $
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2008/2005 - The Apache Software 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 System.IO;
+
+namespace Apache.Ibatis.Common.Resources
+{
+ /// <summary>
+ /// Event generated when processing a <see cref="FileResource"/>
+ /// </summary>
+ public class FileResourceLoadEventArgs : EventArgs
+ {
+ private FileInfo fileInfo = null;
+
+ /// <summary>
+ /// Gets or sets the <see cref="FileInfo"/>.
+ /// </summary>
+ /// <value>The file info.</value>
+ public FileInfo FileInfo
+ {
+ get { return fileInfo; }
+ set { fileInfo = value; }
+ }
+}
+}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/ResourceLoaderRegistry.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/ResourceLoaderRegistry.cs?rev=672555&r1=672554&r2=672555&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/ResourceLoaderRegistry.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.Common/Resources/ResourceLoaderRegistry.cs Sat Jun 28 10:17:59 2008
@@ -23,6 +23,7 @@
********************************************************************************/
#endregion
+using System;
using System.Collections.Generic;
using Apache.Ibatis.Common.Contracts;
@@ -37,6 +38,11 @@
private static readonly object syncLock = new object();
/// <summary>
+ /// Event launch on processing file resource
+ /// </summary>
+ public static event EventHandler<FileResourceLoadEventArgs> LoadFileResource = delegate { };
+
+ /// <summary>
/// Registers standard and user-configured resource handlers.
/// </summary>
static ResourceLoaderRegistry()
@@ -69,7 +75,24 @@
CustomUriBuilder builder = new CustomUriBuilder(resource, Resources.DefaultBasePath);
IResourceLoader loader = resourceLoaders[builder.Uri.Scheme];
- return loader.Create(builder.Uri);
+ IResource res = loader.Create(builder.Uri);
+
+ if (loader is FileResourceLoader)
+ {
+ FileResourceLoadEventArgs evnt = new FileResourceLoadEventArgs();
+ evnt.FileInfo = res.FileInfo;
+
+ LoadFileResource(loader, evnt);
+ }
+ return res;
+ }
+
+ /// <summary>
+ /// Resets the event handler.
+ /// </summary>
+ public static void ResetEventHandler()
+ {
+ LoadFileResource = delegate { };
}
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/DefaultConfigurationEngineTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/DefaultConfigurationEngineTest.cs?rev=672555&r1=672554&r2=672555&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/DefaultConfigurationEngineTest.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/DefaultConfigurationEngineTest.cs Sat Jun 28 10:17:59 2008
@@ -9,12 +9,15 @@
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using Apache.Ibatis.DataMapper.SqlClient.Test.Domain;
+using System.Collections.Generic;
namespace Apache.Ibatis.DataMapper.SqlClient.Test.Fixtures
{
[TestFixture]
public class DefaultConfigurationEngineTest
{
+ private List<string> fileNames = new List<string>();
+
private class AccountModule : Module
{
public override void Load()
@@ -24,6 +27,30 @@
}
}
+ [Test]
+ public void Event_FileReourceLoad_should_be_launch()
+ {
+ string resource = "SqlMap_Test_Configure.config";
+
+ IConfigurationEngine engine = new DefaultConfigurationEngine();
+ engine.FileResourceLoad += FileResourceEventHandler;
+
+ engine.RegisterInterpreter(new XmlConfigurationInterpreter(resource));
+ engine.BuildMapperFactory();
+
+ Assert.That(fileNames.Count, Is.EqualTo(6));
+ Assert.Contains(resource, fileNames);
+ Assert.Contains("database.config", fileNames);
+ Assert.Contains("providers.config", fileNames);
+ Assert.Contains("Mapping1.xml", fileNames);
+ Assert.Contains("Mapping3.xml", fileNames);
+ Assert.Contains("Mapping4.xml", fileNames);
+ }
+
+ private void FileResourceEventHandler(object sender, FileResourceLoadEventArgs evnt)
+ {
+ fileNames.Add(evnt.FileInfo.Name);
+ }
[Test]
public void ResultMap_configuration_via_code_should_override_file_configuration()
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/DefaultConfigurationEngine.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/DefaultConfigurationEngine.cs?rev=672555&r1=672554&r2=672555&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/DefaultConfigurationEngine.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/DefaultConfigurationEngine.cs Sat Jun 28 10:17:59 2008
@@ -24,12 +24,14 @@
********************************************************************************/
#endregion
+using System;
using System.Collections.Generic;
using System.Reflection;
using Apache.Ibatis.Common.Configuration;
using Apache.Ibatis.Common.Contracts;
using Apache.Ibatis.Common.Exceptions;
using Apache.Ibatis.Common.Logging;
+using Apache.Ibatis.Common.Resources;
using Apache.Ibatis.DataMapper.Configuration.Interpreters.Config;
using Apache.Ibatis.DataMapper.Model;
using Apache.Ibatis.DataMapper.Configuration.Module;
@@ -55,6 +57,11 @@
private IModelStore modelStore = null;
private IConfigurationInterpreter interpreter = null;
+ /// <summary>
+ /// Event launch on processing file resource
+ /// </summary>
+ public event EventHandler<FileResourceLoadEventArgs> FileResourceLoad = delegate { };
+
private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
#region constructors
@@ -67,6 +74,9 @@
configurationStore = new DefaultConfigurationStore();
configurationSetting = new ConfigurationSetting();
modules = new List<IModule>();
+
+ ResourceLoaderRegistry.ResetEventHandler();
+ ResourceLoaderRegistry.LoadFileResource += FileResourceEventHandler;
}
/// <summary>
@@ -298,5 +308,9 @@
return statement;
}
+ private void FileResourceEventHandler(object sender, FileResourceLoadEventArgs evnt)
+ {
+ FileResourceLoad(sender, evnt);
+ }
}
}
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/IConfigurationEngine.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/IConfigurationEngine.cs?rev=672555&r1=672554&r2=672555&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/IConfigurationEngine.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/IConfigurationEngine.cs Sat Jun 28 10:17:59 2008
@@ -24,6 +24,8 @@
********************************************************************************/
#endregion
+using System;
+using Apache.Ibatis.Common.Resources;
using Apache.Ibatis.DataMapper.Configuration.Interpreters.Config;
using Apache.Ibatis.DataMapper.Configuration.Module;
using Apache.Ibatis.DataMapper.Model;
@@ -38,6 +40,11 @@
public interface IConfigurationEngine
{
/// <summary>
+ /// Event launch on processing file resource
+ /// </summary>
+ event EventHandler<FileResourceLoadEventArgs> FileResourceLoad;
+
+ /// <summary>
/// Gets the model store.
/// </summary>
/// <value>The model store.</value>
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/AbstractInterpreter.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/AbstractInterpreter.cs?rev=672555&r1=672554&r2=672555&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/AbstractInterpreter.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/AbstractInterpreter.cs Sat Jun 28 10:17:59 2008
@@ -23,7 +23,7 @@
********************************************************************************/
#endregion
-using Apache.Ibatis.Common.Configuration;
+using System;
using Apache.Ibatis.Common.Resources;
using Apache.Ibatis.Common.Contracts;
@@ -35,7 +35,7 @@
/// </summary>
public abstract class AbstractInterpreter : IConfigurationInterpreter
{
- private IResource resource = null;
+ private readonly IResource resource = null;
/// <summary>
/// Exposes the reference to <see cref="IResource"/>
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/IConfigurationInterpreter.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/IConfigurationInterpreter.cs?rev=672555&r1=672554&r2=672555&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/IConfigurationInterpreter.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Interpreters/Config/IConfigurationInterpreter.cs Sat Jun 28 10:17:59 2008
@@ -23,8 +23,8 @@
********************************************************************************/
#endregion
+using System;
using Apache.Ibatis.Common.Resources;
-using Apache.Ibatis.Common.Configuration;
namespace Apache.Ibatis.DataMapper.Configuration.Interpreters.Config
{
@@ -34,6 +34,7 @@
/// </summary>
public interface IConfigurationInterpreter
{
+
/// <summary>
/// Exposes the reference to <see cref="IResource"/>
/// which the interpreter is likely to hold
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/CachingStatement.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/CachingStatement.cs?rev=672555&r1=672554&r2=672555&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/CachingStatement.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/CachingStatement.cs Sat Jun 28 10:17:59 2008
@@ -25,6 +25,7 @@
#region Using
+using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
@@ -32,7 +33,6 @@
using Apache.Ibatis.DataMapper.Data;
using Apache.Ibatis.DataMapper.Model;
using Apache.Ibatis.DataMapper.Model.Cache;
-using Apache.Ibatis.DataMapper.Model.Cache.Decorators;
using Apache.Ibatis.DataMapper.Model.Events;
using Apache.Ibatis.DataMapper.Model.Statements;
using Apache.Ibatis.DataMapper.Scope;
@@ -51,9 +51,9 @@
private readonly MappedStatement mappedStatement =null;
/// <summary>
- /// Event launch on exceute query
+ /// Event launch on Execute query
/// </summary>
- public event ExecuteEventHandler Execute = delegate { };
+ public event EventHandler<ExecuteEventArgs> Execute = delegate { };
/// <summary>
/// Constructor
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatement.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatement.cs?rev=672555&r1=672554&r2=672555&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatement.cs (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/MappedStatements/IMappedStatement.cs Sat Jun 28 10:17:59 2008
@@ -25,6 +25,8 @@
#endregion
#region Imports
+
+using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
@@ -36,10 +38,6 @@
namespace Apache.Ibatis.DataMapper.MappedStatements
{
- /// <summary>
- ///
- /// </summary>
- public delegate void ExecuteEventHandler(object sender, ExecuteEventArgs e);
/// <summary>
/// Summary description for IMappedStatement.
@@ -52,7 +50,7 @@
/// <summary>
/// Event launch on exceute query
/// </summary>
- event ExecuteEventHandler Execute;
+ event EventHandler<ExecuteEventArgs> Execute;
#endregion
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=672555&r1=672554&r2=672555&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 28 10:17:59 2008
@@ -62,7 +62,7 @@
/// <summary>
/// Event launch on execute query
/// </summary>
- public event ExecuteEventHandler Execute = delegate {};
+ public event EventHandler<ExecuteEventArgs> Execute = delegate { };
#region Fields
private readonly IStatement statement = null;