#region Apache Notice /***************************************************************************** * $Header: $ * $Revision: $ * $Date: $ * * iBATIS.NET Data Mapper * Copyright (C) 2004 - Gilles Bayon * * * 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 #region Using using System.Runtime.Remoting.Messaging; using IBatisNet.Common; #endregion namespace IBatisNet.DataAccess { /// /// Summary description for SessionHolder. /// /// /// See also LocalDataStoreSlot /// public class SessionHolder { #region Constants /// /// Token for SqlMapConfig xml root. /// private const string LOCAL_SESSION = "_IBATIS_LOCAL_DAOSESSION_"; #endregion #region Fields private string _sessionName = string.Empty; #endregion #region Constructor (s) / Destructor /// /// Constructor /// /// The DaoManager name. public SessionHolder(string daoManagerName) { _sessionName = LOCAL_SESSION + daoManagerName; } #endregion #region ISessionContainer Members #region Properties /// /// Get the local session /// public IDalSession LocalSession { get { return CallContext.GetData(_sessionName) as IDalSession; } } #endregion #region Methods /// /// Store the local session. /// Ensure that the session is unique for each thread. /// /// The session to store public void Store(IDalSession session) { CallContext.SetData(_sessionName, session); } /// /// Remove the local session. /// public void Dispose() { CallContext.SetData(_sessionName, null); } #endregion #endregion } }