Author: gbayon
Date: Thu Jun 29 12:57:52 2006
New Revision: 418128

URL: http://svn.apache.org/viewvc?rev=418128&view=rev
Log:
In June 2005, I have removed this code
but after reading
http://forum.springframework.net/showthread.php?t=572
http://piers7.blogspot.com/2005/11/threadstatic-callcontext-and_02.html
and re-inject it

Added:
    ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/
    
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/AbstractSessionStore.cs
   (with props)
    
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/CallContextSessionStore.cs
   (with props)
    ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/ISessionStore.cs   
(with props)
    
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/SessionStoreFactory 
.cs   (with props)
    ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/WebSessionStore.cs 
  (with props)
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/AbstractSessionStore.cs
   (with props)
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/CallContextSessionStore.cs
   (with props)
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/ISessionStore.cs   
(with props)
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/SessionStoreFactory 
.cs   (with props)
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/WebSessionStore.cs 
  (with props)
Modified:
    ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoManager.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataAccess/IBatisNet.DataAccess.2005.csproj
    ibatis/trunk/cs/mapper/IBatisNet.DataAccess/IBatisNet.DataAccess.csproj
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoManager.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoManager.cs?rev=418128&r1=418127&r2=418128&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoManager.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoManager.cs Thu Jun 29 
12:57:52 2006
@@ -36,6 +36,7 @@
 using IBatisNet.DataAccess.Configuration;
 using IBatisNet.DataAccess.Exceptions;
 using IBatisNet.DataAccess.Interfaces;
+using IBatisNet.DataAccess.SessionStore;
 
 #endregion
 
@@ -119,9 +120,9 @@
                private static HybridDictionary _daoImplementationMap = new 
HybridDictionary();
 
                /// <summary>
-               /// Container session unique for each thread. 
+               /// Container session unique for each 'thread'. 
                /// </summary>
-               private SessionHolder _sessionHolder = null;
+               private ISessionStore _sessionHolder = null;
                #endregion
 
                #region Properties
@@ -213,8 +214,8 @@
                /// instances from being created.
                /// </summary>
                private DaoManager() 
-               { 
-                       _sessionHolder = new SessionHolder(this.Name);
+               {
+            _sessionHolder = SessionStoreFactory.GetSessionStore(this.Name);
                }
                #endregion
 

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/IBatisNet.DataAccess.2005.csproj
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/IBatisNet.DataAccess.2005.csproj?rev=418128&r1=418127&r2=418128&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/IBatisNet.DataAccess.2005.csproj 
(original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/IBatisNet.DataAccess.2005.csproj 
Thu Jun 29 12:57:52 2006
@@ -152,9 +152,11 @@
     <Compile Include="Scope\ErrorContext.cs">
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="SessionHolder.cs">
-      <SubType>Code</SubType>
-    </Compile>
+    <Compile Include="SessionStore\AbstractSessionStore.cs" />
+    <Compile Include="SessionStore\CallContextSessionStore.cs" />
+    <Compile Include="SessionStore\ISessionStore.cs" />
+    <Compile Include="SessionStore\SessionStoreFactory .cs" />
+    <Compile Include="SessionStore\WebSessionStore.cs" />
     <Content Include="ChangeLog.txt" />
     <EmbeddedResource Include="DaoConfig.xsd" />
     <Content Include="licence.txt" />

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/IBatisNet.DataAccess.csproj
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/IBatisNet.DataAccess.csproj?rev=418128&r1=418127&r2=418128&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess/IBatisNet.DataAccess.csproj 
(original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess/IBatisNet.DataAccess.csproj Thu 
Jun 29 12:57:52 2006
@@ -234,6 +234,31 @@
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
+                <File
+                    RelPath = "SessionStore\AbstractSessionStore.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "SessionStore\CallContextSessionStore.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "SessionStore\ISessionStore.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "SessionStore\SessionStoreFactory .cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "SessionStore\WebSessionStore.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
             </Include>
         </Files>
     </CSHARP>

Added: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/AbstractSessionStore.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/AbstractSessionStore.cs?rev=418128&view=auto
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/AbstractSessionStore.cs
 (added)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/AbstractSessionStore.cs
 Thu Jun 29 12:57:52 2006
@@ -0,0 +1,70 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: 378715 $
+ * $Date$
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006 - Apache Fondation
+ *  
+ * 
+ * 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 IBatisNet.Common;
+
+namespace IBatisNet.DataAccess.SessionStore
+{
+       /// <summary>
+       /// 
+       /// </summary>
+       public abstract class AbstractSessionStore  : MarshalByRefObject, 
ISessionStore
+       {
+               const string KEY = "_IBATIS_LOCAL_DAOSESSION_";
+           /// <summary>
+           /// session name
+           /// </summary>
+               protected string sessionName = string.Empty;
+
+               /// <summary>
+               /// Constructor
+               /// </summary>
+               /// <param name="daoManagerName">The DaoManager name.</param>
+               public AbstractSessionStore(string daoManagerName)
+               {
+            sessionName = KEY + daoManagerName;
+               }
+
+               /// <summary>
+               /// Get the local session
+               /// </summary>
+               public abstract IDalSession LocalSession
+               {
+                       get; 
+               }
+
+               /// <summary>
+               /// Store the specified session.
+               /// </summary>
+               /// <param name="session">The session to store</param>
+        public abstract void Store(IDalSession session);
+
+               /// <summary>
+               /// Remove the local session from the storage.
+               /// </summary>
+        public abstract void Dispose();
+       }
+}

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/AbstractSessionStore.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/AbstractSessionStore.cs
------------------------------------------------------------------------------
    svn:keywords = Id LastChangedDate LastChangedBy

Added: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/CallContextSessionStore.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/CallContextSessionStore.cs?rev=418128&view=auto
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/CallContextSessionStore.cs
 (added)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/CallContextSessionStore.cs
 Thu Jun 29 12:57:52 2006
@@ -0,0 +1,70 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: 378715 $
+ * $Date$
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006 - Apache Fondation
+ *  
+ * 
+ * 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.Runtime.Remoting.Messaging;
+using IBatisNet.Common;
+
+namespace IBatisNet.DataAccess.SessionStore
+{
+       /// <summary>
+       /// Provides an implementation of <see cref="ISessionStore"/>
+       /// which relies on <c>CallContext</c>
+       /// </summary>
+       public class CallContextSessionStore : AbstractSessionStore
+       {
+        /// <summary>
+        /// Initializes a new instance of the <see 
cref="CallContextSessionStore"/> class.
+        /// </summary>
+        /// <param name="daoManagerName">The DaoManager name.</param>
+               public CallContextSessionStore(string daoManagerName) : 
base(daoManagerName)
+               {}
+
+               /// <summary>
+               /// Get the local session
+               /// </summary>
+               public override IDalSession LocalSession
+               {
+                       get { return CallContext.GetData(sessionName) as 
IDalSession; }
+               }
+
+               /// <summary>
+               /// Store the specified session.
+               /// </summary>
+               /// <param name="session">The session to store</param>
+
+               public override void Store(IDalSession session)
+               {
+                       CallContext.SetData(sessionName, session);
+               }
+
+               /// <summary>
+               /// Remove the local session.
+               /// </summary>
+               public override void Dispose()
+               {
+                       CallContext.SetData(sessionName, null);
+               }
+       }
+}

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/CallContextSessionStore.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/CallContextSessionStore.cs
------------------------------------------------------------------------------
    svn:keywords = Id LastChangedDate LastChangedBy

Added: ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/ISessionStore.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/ISessionStore.cs?rev=418128&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/ISessionStore.cs 
(added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/ISessionStore.cs 
Thu Jun 29 12:57:52 2006
@@ -0,0 +1,55 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: 378715 $
+ * $Date$
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006 - Apache Fondation
+ *  
+ * 
+ * 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 IBatisNet.Common;
+
+namespace IBatisNet.DataAccess.SessionStore
+{
+
+       /// <summary>
+       /// Provides the contract for implementors who want to store session.
+       /// </summary>
+       public interface ISessionStore
+       {
+               /// <summary>
+               /// Get the local session
+               /// </summary>
+               IDalSession LocalSession
+               {
+                       get; 
+               }
+
+               /// <summary>
+               /// Store the specified session.
+               /// </summary>
+               /// <param name="session">The session to store</param>
+               void Store(IDalSession session);
+
+               /// <summary>
+               /// Remove the local session from the storage.
+               /// </summary>
+               void Dispose();
+       }
+}

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/ISessionStore.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/ISessionStore.cs
------------------------------------------------------------------------------
    svn:keywords = Id LastChangedDate LastChangedBy

Added: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/SessionStoreFactory .cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/SessionStoreFactory%20.cs?rev=418128&view=auto
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/SessionStoreFactory 
.cs (added)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/SessionStoreFactory 
.cs Thu Jun 29 12:57:52 2006
@@ -0,0 +1,61 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: 378715 $
+ * $Date$
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006 - Apache Fondation
+ *  
+ * 
+ * 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.Web;
+
+namespace IBatisNet.DataAccess.SessionStore
+{
+       /// <summary>
+       /// Build a session container for a Windows or Web context.
+       /// When running in the context of a web application the session object 
is 
+       /// stored in HttpContext items and has 'per request' lifetime.
+       /// When running in the context of a windows application the session 
object is 
+       /// stored via CallContext.
+       /// </summary>
+       public class SessionStoreFactory
+       {
+
+               /// <summary>
+               /// Get a session container for a Windows or Web context.
+               /// </summary>
+               /// <param name="daoManagerName">The DaoManager name.</param>
+               /// <returns></returns>
+               static public ISessionStore GetSessionStore(string 
daoManagerName)
+               {
+                       if (System.Web.HttpContext.Current == null)
+                       {
+                               return new 
CallContextSessionStore(daoManagerName);
+                       }
+                       else
+                       {
+                               return new WebSessionStore(daoManagerName);
+                       }
+               }
+
+       }
+}
+

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/SessionStoreFactory .cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/SessionStoreFactory .cs
------------------------------------------------------------------------------
    svn:keywords = Id LastChangedDate LastChangedBy

Added: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/WebSessionStore.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/WebSessionStore.cs?rev=418128&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/WebSessionStore.cs 
(added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/WebSessionStore.cs 
Thu Jun 29 12:57:52 2006
@@ -0,0 +1,91 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: 378715 $
+ * $Date$
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006 - Apache Fondation
+ *  
+ * 
+ * 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.Web;
+using IBatisNet.Common;
+using IBatisNet.Common.Exceptions;
+
+namespace IBatisNet.DataAccess.SessionStore
+{
+
+       /// <summary>
+       /// Provides an implementation of <see cref="ISessionStore"/>
+       /// which relies on <c>HttpContext</c>. Suitable for web projects.
+       /// </summary>
+       public class WebSessionStore : AbstractSessionStore
+       {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="WebSessionStore"/> 
class.
+        /// </summary>
+        /// <param name="daoManagerName">The DaoManager name.</param>
+               public WebSessionStore(string 
daoManagerName):base(daoManagerName)
+               {}
+
+               /// <summary>
+               /// Get the local session
+               /// </summary>
+               public override IDalSession LocalSession
+               {
+                       get
+                       {
+                               HttpContext currentContext = 
ObtainSessionContext();
+
+                               return currentContext.Items[sessionName] as 
IDalSession;
+                       }
+               }
+
+               /// <summary>
+               /// Store the specified session.
+               /// </summary>
+               /// <param name="session">The session to store</param>
+
+               public override void Store(IDalSession session)
+               {
+                       HttpContext currentContext = ObtainSessionContext();
+
+                       currentContext.Items[sessionName] = session;
+               }
+
+               /// <summary>
+               /// Remove the local session.
+               /// </summary>
+               public override void Dispose()
+               {
+                       // Will be remove by the system
+               }
+
+               
+               private static HttpContext ObtainSessionContext()
+               {
+                       HttpContext currentContext = HttpContext.Current;
+       
+                       if (currentContext == null)
+                       {
+                               throw new IBatisNetException("WebSessionStore: 
Could not obtain reference to HttpContext");
+                       }
+                       return currentContext;
+               }
+       }
+}

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/WebSessionStore.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/SessionStore/WebSessionStore.cs
------------------------------------------------------------------------------
    svn:keywords = Id LastChangedDate LastChangedBy

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj?rev=418128&r1=418127&r2=418128&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj 
(original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj 
Thu Jun 29 12:57:52 2006
@@ -549,9 +549,11 @@
     <Compile Include="Scope\RequestScope.cs">
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="SessionHolder.cs">
-      <SubType>Code</SubType>
-    </Compile>
+    <Compile Include="SessionStore\AbstractSessionStore.cs" />
+    <Compile Include="SessionStore\CallContextSessionStore.cs" />
+    <Compile Include="SessionStore\ISessionStore.cs" />
+    <Compile Include="SessionStore\SessionStoreFactory .cs" />
+    <Compile Include="SessionStore\WebSessionStore.cs" />
     <Compile Include="SqlMapper.cs">
       <SubType>Code</SubType>
     </Compile>

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj?rev=418128&r1=418127&r2=418128&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj 
(original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj Thu 
Jun 29 12:57:52 2006
@@ -1088,6 +1088,31 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "SessionStore\AbstractSessionStore.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "SessionStore\CallContextSessionStore.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "SessionStore\ISessionStore.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "SessionStore\SessionStoreFactory .cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "SessionStore\WebSessionStore.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "TypeHandlers\BaseTypeHandler.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
@@ -1198,6 +1223,11 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "TypeHandlers\SByteTypeHandler.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "TypeHandlers\SingleTypeHandler.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
@@ -1214,6 +1244,21 @@
                 />
                 <File
                     RelPath = "TypeHandlers\TypeHandlerFactory.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "TypeHandlers\UInt16TypeHandler.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "TypeHandlers\UInt32TypeHandler.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "TypeHandlers\UInt64TypeHandler.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />

Added: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/AbstractSessionStore.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/AbstractSessionStore.cs?rev=418128&view=auto
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/AbstractSessionStore.cs
 (added)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/AbstractSessionStore.cs
 Thu Jun 29 12:57:52 2006
@@ -0,0 +1,71 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: 378715 $
+ * $Date$
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006 - Apache Fondation
+ *  
+ * 
+ * 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;
+
+namespace IBatisNet.DataMapper.SessionStore
+{
+       /// <summary>
+       /// 
+       /// </summary>
+       public abstract class AbstractSessionStore  : MarshalByRefObject, 
ISessionStore
+       {
+        const string KEY = "_IBATIS_LOCAL_SQLMAP_SESSION_";
+        /// <summary>
+        /// session name
+        /// </summary>     
+               protected string sessionName = string.Empty;
+
+
+        /// <summary>
+        /// Initializes a new instance of the <see 
cref="AbstractSessionStore"/> class.
+        /// </summary>
+        /// <param name="sqlMapperId">The SQL mapper id.</param>
+        public AbstractSessionStore(string sqlMapperId)
+               {
+            sessionName = KEY + sqlMapperId;
+               }
+
+               /// <summary>
+               /// Get the local session
+               /// </summary>
+        public abstract SqlMapSession LocalSession
+               {
+                       get; 
+               }
+
+
+        /// <summary>
+        /// Store the specified session.
+        /// </summary>
+        /// <param name="session">The session to store</param>
+        public abstract void Store(SqlMapSession session);
+
+               /// <summary>
+               /// Remove the local session from the storage.
+               /// </summary>
+        public abstract void Dispose();
+       }
+}

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/AbstractSessionStore.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/AbstractSessionStore.cs
------------------------------------------------------------------------------
    svn:keywords = Id LastChangedDate LastChangedBy

Added: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/CallContextSessionStore.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/CallContextSessionStore.cs?rev=418128&view=auto
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/CallContextSessionStore.cs
 (added)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/CallContextSessionStore.cs
 Thu Jun 29 12:57:52 2006
@@ -0,0 +1,69 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: 378715 $
+ * $Date$
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006 - Apache Fondation
+ *  
+ * 
+ * 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.Runtime.Remoting.Messaging;
+
+namespace IBatisNet.DataMapper.SessionStore
+{
+       /// <summary>
+       /// Provides an implementation of <see cref="ISessionStore"/>
+       /// which relies on <c>CallContext</c>
+       /// </summary>
+       public class CallContextSessionStore : AbstractSessionStore
+       {
+
+        /// <summary>
+        /// Initializes a new instance of the <see 
cref="CallContextSessionStore"/> class.
+        /// </summary>
+        /// <param name="sqlMapperId">The SQL mapper id.</param>
+        public CallContextSessionStore(string sqlMapperId): base(sqlMapperId)
+               {}
+
+               /// <summary>
+               /// Get the local session
+               /// </summary>
+        public override SqlMapSession LocalSession
+               {
+            get { return CallContext.GetData(sessionName) as SqlMapSession; }
+               }
+
+               /// <summary>
+               /// Store the specified session.
+               /// </summary>
+               /// <param name="session">The session to store</param>
+        public override void Store(SqlMapSession session)
+               {
+                       CallContext.SetData(sessionName, session);
+               }
+
+               /// <summary>
+               /// Remove the local session.
+               /// </summary>
+               public override void Dispose()
+               {
+                       CallContext.SetData(sessionName, null);
+               }
+       }
+}

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/CallContextSessionStore.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/CallContextSessionStore.cs
------------------------------------------------------------------------------
    svn:keywords = Id LastChangedDate LastChangedBy

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/ISessionStore.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/ISessionStore.cs?rev=418128&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/ISessionStore.cs 
(added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/ISessionStore.cs 
Thu Jun 29 12:57:52 2006
@@ -0,0 +1,54 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: 378715 $
+ * $Date$
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006 - Apache Fondation
+ *  
+ * 
+ * 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
+
+
+namespace IBatisNet.DataMapper.SessionStore
+{
+
+       /// <summary>
+       /// Provides the contract for implementors who want to store session.
+       /// </summary>
+       public interface ISessionStore
+       {
+               /// <summary>
+               /// Get the local session
+               /// </summary>
+        SqlMapSession LocalSession
+               {
+                       get; 
+               }
+
+               /// <summary>
+               /// Store the specified session.
+               /// </summary>
+               /// <param name="session">The session to store</param>
+        void Store(SqlMapSession session);
+
+               /// <summary>
+               /// Remove the local session from the storage.
+               /// </summary>
+               void Dispose();
+       }
+}

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/ISessionStore.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/ISessionStore.cs
------------------------------------------------------------------------------
    svn:keywords = Id LastChangedDate LastChangedBy

Added: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/SessionStoreFactory .cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/SessionStoreFactory%20.cs?rev=418128&view=auto
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/SessionStoreFactory 
.cs (added)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/SessionStoreFactory 
.cs Thu Jun 29 12:57:52 2006
@@ -0,0 +1,57 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: 378715 $
+ * $Date$
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006 - Apache Fondation
+ *  
+ * 
+ * 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
+
+namespace IBatisNet.DataMapper.SessionStore
+{
+       /// <summary>
+       /// Build a session container for a Windows or Web context.
+       /// When running in the context of a web application the session object 
is 
+       /// stored in HttpContext items and has 'per request' lifetime.
+       /// When running in the context of a windows application the session 
object is 
+       /// stored via CallContext.
+       /// </summary>
+       public class SessionStoreFactory
+       {
+
+        /// <summary>
+        /// Gets the session store.
+        /// </summary>
+        /// <param name="sqlMapperId">The SQL mapper id.</param>
+        /// <returns></returns>
+        static public ISessionStore GetSessionStore(string sqlMapperId)
+               {
+                       if (System.Web.HttpContext.Current == null)
+                       {
+                return new CallContextSessionStore(sqlMapperId);
+                       }
+                       else
+                       {
+                return new WebSessionStore(sqlMapperId);
+                       }
+               }
+
+       }
+}
+

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/SessionStoreFactory .cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/SessionStoreFactory .cs
------------------------------------------------------------------------------
    svn:keywords = Id LastChangedDate LastChangedBy

Added: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/WebSessionStore.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/WebSessionStore.cs?rev=418128&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/WebSessionStore.cs 
(added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/WebSessionStore.cs 
Thu Jun 29 12:57:52 2006
@@ -0,0 +1,91 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: 378715 $
+ * $Date$
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006 - Apache Fondation
+ *  
+ * 
+ * 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.Web;
+using IBatisNet.Common;
+using IBatisNet.Common.Exceptions;
+
+namespace IBatisNet.DataMapper.SessionStore
+{
+
+       /// <summary>
+       /// Provides an implementation of <see cref="ISessionStore"/>
+       /// which relies on <c>HttpContext</c>. Suitable for web projects.
+       /// </summary>
+       public class WebSessionStore : AbstractSessionStore
+       {
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="WebSessionStore"/> 
class.
+        /// </summary>
+        /// <param name="sqlMapperId">The SQL mapper id.</param>
+        public WebSessionStore(string sqlMapperId) : base(sqlMapperId)
+               {}
+
+               /// <summary>
+               /// Get the local session
+               /// </summary>
+        public override SqlMapSession LocalSession
+               {
+                       get
+                       {
+                               HttpContext currentContext = 
ObtainSessionContext();
+
+                return currentContext.Items[sessionName] as SqlMapSession;
+                       }
+               }
+
+               /// <summary>
+               /// Store the specified session.
+               /// </summary>
+               /// <param name="session">The session to store</param>
+        public override void Store(SqlMapSession session)
+               {
+                       HttpContext currentContext = ObtainSessionContext();
+
+                       currentContext.Items[sessionName] = session;
+               }
+
+               /// <summary>
+               /// Remove the local session.
+               /// </summary>
+               public override void Dispose()
+               {
+                       // Will be remove by the system
+               }
+
+               
+               private static HttpContext ObtainSessionContext()
+               {
+                       HttpContext currentContext = HttpContext.Current;
+       
+                       if (currentContext == null)
+                       {
+                               throw new IBatisNetException("WebSessionStore: 
Could not obtain reference to HttpContext");
+                       }
+                       return currentContext;
+               }
+       }
+}

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/WebSessionStore.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SessionStore/WebSessionStore.cs
------------------------------------------------------------------------------
    svn:keywords = Id LastChangedDate LastChangedBy

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs?rev=418128&r1=418127&r2=418128&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs Thu Jun 29 
12:57:52 2006
@@ -46,6 +46,7 @@
 using IBatisNet.DataMapper.DataExchange;
 using IBatisNet.DataMapper.Exceptions;
 using IBatisNet.DataMapper.MappedStatements;
+using IBatisNet.DataMapper.SessionStore;
 using IBatisNet.DataMapper.TypeHandlers;
 
 #endregion
@@ -104,7 +105,7 @@
                /// <summary>
                /// Container session unique for each thread. 
                /// </summary>
-               private SessionHolder _sessionHolder = null;
+        private ISessionStore _sessionHolder = null;
         private IObjectFactory _objectFactory = null;
         private AccessorFactory _accessorFactory = null;
         private DataExchangeFactory _dataExchangeFactory = null;
@@ -201,7 +202,7 @@
 
             _dataExchangeFactory = new 
DataExchangeFactory(_typeHandlerFactory, _objectFactory, accessorFactory);
                        _id = 
HashCodeProvider.GetIdentityHashCode(this).ToString();
-                       _sessionHolder = new SessionHolder(_id);
+            _sessionHolder = SessionStoreFactory.GetSessionStore(_id);
                }
                #endregion
 


Reply via email to