#region Apache Notice
/*****************************************************************************
* $Header: $
* $Revision: 513043 $
* $Date$
*
* 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.Data;
using Apache.Ibatis.Common.Contracts;
namespace Apache.Ibatis.DataMapper.Session.Transaction
{
///
/// Default implementation of the interface.
/// Defines the methods to manage transaction boundaries.
///
public class DefaultTransactionManager : ITransactionManager
{
private readonly ITransactionFactory transactionFactory = null;
///
/// Initializes a new instance of the class.
///
/// The transaction factory.
public DefaultTransactionManager(ITransactionFactory transactionFactory)
{
Contract.Require.That(transactionFactory, Is.Not.Null).When("retrieving transactionFactory session in DefaultTransactionManager constructor.");
this.transactionFactory = transactionFactory;
}
#region ITransactionManager Members
///
/// Begin a transaction and return the associated ITransaction instance
///
///
///
public ITransaction BeginTransaction(ISession session)
{
return BeginTransaction(session, IsolationLevel.Unspecified);
}
///
/// Begin a transaction with the specified isolation level and return
/// the associated ITransaction instance
///
///
///
///
public ITransaction BeginTransaction(ISession session, IsolationLevel isolationLevel)
{
ITransaction transaction = transactionFactory.Create(session);
transaction.Begin(isolationLevel);
return transaction;
}
#endregion
}
}