TransactionAttribute.cs :  » Inversion-of-Control-Dependency-Injection » Spring.net » Spring » Transaction » Interceptor » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Inversion of Control Dependency Injection » Spring.net 
Spring.net » Spring » Transaction » Interceptor » TransactionAttribute.cs
#region License

/*
 * Copyright  2002-2005 the original author or authors.
 * 
 * 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 Imports

using System;
using System.Data;
using Spring.Transaction.Support;


#endregion

namespace Spring.Transaction.Interceptor{
  /// <summary>
  /// .NET Attribute for describing transactional behavior of methods in a class. 
  /// </summary>
  /// <remarks>This attribute type is generally directly comparable
  /// to Spring's <see cref="RuleBasedTransactionAttribute"/> class and
  /// in fact <see cref="AttributesTransactionAttributeSource"/> will
    /// directly convert the data to a <see cref="RuleBasedTransactionAttribute"/>
    /// so that Spring's transaction support code does not have to know about
    /// attributes. If no rules are relevant to the exception it will be treaded
    /// like DefaultTransactionAttribute, (rolling back on all exceptions).
  /// <para>
    /// The default property values are TransactionPropagation.Required, IsolationLevel.ReadCommitted,
    /// DefaultTransactionDefinition.TIMEOUT_DEFAULT (can be changed, by default is the default
    /// value of the underlying transaction subsystem)
    /// ReadOnly = false, and Type.EmtptyTypes specified for Rollbackfor and NoRollbackFor exception
    /// types.
    /// </para>
    /// </remarks>
  /// <author>Mark Pollack (.NET)</author>
  [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, 
         Inherited = true)]
    [Serializable]
  public class TransactionAttribute : Attribute
  {
    #region Fields
        private TransactionPropagation _transactionPropagation = TransactionPropagation.Required;
        private IsolationLevel _isolationLevel = IsolationLevel.ReadCommitted;
        private int _timeout = DefaultTransactionDefinition.TIMEOUT_DEFAULT;
        private bool _readOnly = false;
        private Type[] _rollbackTypes = Type.EmptyTypes;
        private Type[] _noRollbackTypes = Type.EmptyTypes;
#if NET_2_0
      private System.Transactions.EnterpriseServicesInteropOption _esInteropOption =
            System.Transactions.EnterpriseServicesInteropOption.Automatic;
#endif  

    #endregion

    #region Constructor (s)
    /// <summary>
    /// Initializes a new instance of the <see cref="TransactionAttribute"/> class.
        /// </summary>
    public TransactionAttribute()
    {

    }

        /// <summary>
        /// Initializes a new instance of the <see cref="TransactionAttribute"/> class.
        /// </summary>
        /// <param name="transactionPropagation">The transaction propagation.</param>
        public TransactionAttribute(TransactionPropagation transactionPropagation) : this()
        {
            _transactionPropagation = transactionPropagation;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="TransactionAttribute"/> class.
        /// </summary>
        /// <param name="transactionPropagation">The transaction propagation.</param>
        /// <param name="isolationLevel">The isolation level.</param>
        public TransactionAttribute(TransactionPropagation transactionPropagation,
                                    IsolationLevel isolationLevel) : this(transactionPropagation)
        {
            _isolationLevel = isolationLevel;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="TransactionAttribute"/> class.
        /// </summary>
        /// <param name="isolationLevel">The isolation level.</param>
        public TransactionAttribute(IsolationLevel isolationLevel)
        {
            _isolationLevel = isolationLevel;
        }

    #endregion

    #region Properties

        /// <summary>
        /// Gets the transaction propagation.
        /// </summary>
        /// <remarks>Defaults to TransactionPropagation.Required</remarks>
        /// <value>The transaction propagation.</value>
      public TransactionPropagation TransactionPropagation
      {
          get { return _transactionPropagation; }
      }

        /// <summary>
        /// Gets the isolation level.
        /// </summary>
        /// <remarks>Defaults to IsolationLevel.Unspecified</remarks>
        /// <value>The isolation level.</value>
      public IsolationLevel IsolationLevel
      {
          get { return _isolationLevel; }
      }

        /// <summary>
        /// Gets or sets the timeout.
        /// </summary>
        /// <remarks>Defaults to the default timeout of the underlying transaction system.</remarks>
        /// <value>The timeout.</value>
      public int Timeout
      {
          get { return _timeout; }
          set { _timeout = value; }
      }

        /// <summary>
        /// Gets or sets a value indicating whether the transaction is readonly.
        /// </summary>
        /// <remarks>Defaults to false</remarks>
        /// <value><c>true</c> if read-only; otherwise, <c>false</c>.</value>
      public bool ReadOnly
      {
          get { return _readOnly; }
          set { _readOnly = value; }
      }

        /// <summary>
        /// Gets or sets the zero or more exception types which
        /// indicating which exception types must cause a transaction
        /// rollback.
        /// </summary>
        /// <remarks>This is the preferred way to construct a rollback rule,
        /// matching the exception class and subclasses.</remarks>
        /// <value>The rollback types.</value>
      public Type[] RollbackFor
      {
          get { return _rollbackTypes; }
          set { _rollbackTypes = value; }
      }

        /// <summary>
        /// Gets or sets zero or more exceptions types which
        /// indicationg which exception type must <c>not</c>
        /// cause a transaction rollback.
        /// </summary>
        /// <remarks>This is the preferred way to construct a rollback rule,
        /// matching the exception type.</remarks>
        /// <value>The no rollback for.</value>
      public Type[] NoRollbackFor
      {
          get { return _noRollbackTypes; }
          set { _noRollbackTypes = value; }
      }

       
#if NET_2_0
        /// <summary>
        /// Gets or sets the enterprise services interop option.
        /// </summary>
        /// <value>The enterprise services interop option.</value>
      public System.Transactions.EnterpriseServicesInteropOption EnterpriseServicesInteropOption
      {
          get { return _esInteropOption;}
            set { _esInteropOption = value; }
      }
#endif

      #endregion

    #region Methods

    #endregion

  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.