Beispiel #1
0
        /// <summary>
        /// Creates the transaction if necessary.
        /// </summary>
        /// <param name="sourceAttr">The source transaction attribute.</param>
        /// <param name="joinpointIdentification">The joinpoint identification.</param>
        /// <returns>Transaction Info for declarative transaction management.</returns>
        protected TransactionInfo CreateTransactionIfNecessary(ITransactionAttribute sourceAttr, string joinpointIdentification)
        {
            ITransactionAttribute txAttr = sourceAttr;

            // If no name specified, apply method identification as transaction name.
            if (txAttr != null && txAttr.Name == null)
            {
                txAttr = new DelegatingTransactionAttributeWithName(txAttr, joinpointIdentification);
            }

            TransactionInfo transactionInfo = new TransactionInfo(txAttr, joinpointIdentification);

            if (txAttr != null)
            {
                // We need a transaction for this method
                #region Instrumentation

                if (log.IsDebugEnabled)
                {
                    log.Debug("Getting transaction for " + transactionInfo.JoinpointIdentification);
                }

                #endregion
                // The transaction manager will flag an error if an incompatible tx already exists
                transactionInfo.TransactionStatus = _transactionManager.GetTransaction(txAttr);
            }
            else
            {
                // The TransactionInfo.HasTransaction property will return
                // false. We created it only to preserve the integrity of
                // the ThreadLocal stack maintained in this class.
                if (log.IsDebugEnabled)
                {
                    log.Debug("Skipping transactional joinpoint [" + joinpointIdentification +
                              "] because no transaction manager has been configured");
                }
            }

            // We always bind the TransactionInfo to the thread, even if we didn't create
            // a new transaction here. This guarantees that the TransactionInfo stack
            // will be managed correctly even if no transaction was created by this aspect.
            transactionInfo.BindToThread( );
            return(transactionInfo);
        }
        /// <summary>
        /// Creates the transaction if necessary.
        /// </summary>
        /// <param name="sourceAttr">The source transaction attribute.</param>
        /// <param name="joinpointIdentification">The joinpoint identification.</param>
        /// <returns>Transaction Info for declarative transaction management.</returns>
        protected TransactionInfo CreateTransactionIfNecessary(ITransactionAttribute sourceAttr, string joinpointIdentification)
        {
            ITransactionAttribute txAttr = sourceAttr;

            // If no name specified, apply method identification as transaction name.
            if (txAttr != null && txAttr.Name == null)
            {
                txAttr = new DelegatingTransactionAttributeWithName(txAttr, joinpointIdentification);
            }

            TransactionInfo transactionInfo = new TransactionInfo(txAttr, joinpointIdentification);
            if ( txAttr != null )
            {
                // We need a transaction for this method
                #region Instrumentation

                if (log.IsDebugEnabled)
                {
                    log.Debug("Getting transaction for " + transactionInfo.JoinpointIdentification);
                }

                #endregion
                // The transaction manager will flag an error if an incompatible tx already exists
                transactionInfo.TransactionStatus = _transactionManager.GetTransaction(txAttr);
            }
            else
            {
                // The TransactionInfo.HasTransaction property will return
                // false. We created it only to preserve the integrity of
                // the ThreadLocal stack maintained in this class.
                if (log.IsDebugEnabled)
                {
                    log.Debug("Skipping transactional joinpoint [" + joinpointIdentification +
                              "] because no transaction manager has been configured");
                }
            }

            // We always bind the TransactionInfo to the thread, even if we didn't create
            // a new transaction here. This guarantees that the TransactionInfo stack
            // will be managed correctly even if no transaction was created by this aspect.
            transactionInfo.BindToThread( );
            return transactionInfo;
        }