Subordinate.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / TransactionBridge / Microsoft / Transactions / Wsat / StateMachines / Subordinate.cs / 1 / Subordinate.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

// This file contains the the implementations of the various states used by the 
// Subordinate state machine, which handles incoming activation and registration events
// for transactions with DTC as superior and no WS-AT coordinator. 
// 
// This is a somewhat special state machine, in that it has no "active" states
 
using System;
using System.Diagnostics;

using Microsoft.Transactions.Bridge; 
using Microsoft.Transactions.Wsat.Messaging;
 
using Microsoft.Transactions.Wsat.InputOutput; 
using Microsoft.Transactions.Wsat.Protocol;
 
using Fault = Microsoft.Transactions.Wsat.Messaging.Fault;

namespace Microsoft.Transactions.Wsat.StateMachines
{ 
    //=============================================================================
    // SubordinateInitializing 
    // 
    // A CreateCoordinationContext message was received
    // DTC already knew about the transaction, so we can't be superior to DTC 
    // We will therefore be subordinate to DTC for the transaction
    //=============================================================================
    class SubordinateInitializing : InactiveState
    { 
        public SubordinateInitializing(ProtocolState state) : base(state) { }
 
        public override void OnEvent(InternalEnlistSubordinateTransactionEvent e) 
        {
            ParticipantEnlistment participant = e.Participant; 

            state.TransactionManagerSend.Register(participant, e);
            participant.StateMachine.ChangeState(state.States.SubordinateRegistering);
        } 
    }
 
    //============================================================================== 
    // SubordinateRegistering
    // 
    // We asked the TM to create a new subordinate enlistment
    //=============================================================================
    class SubordinateRegistering : InactiveState
    { 
        public SubordinateRegistering(ProtocolState state) : base(state) { }
 
        public override void OnEvent(TmSubordinateRegisterResponseEvent e) 
        {
            ParticipantEnlistment participant = e.Participant; 
            Status status = e.Status;

            if (status == Status.Success)
            { 
                participant.OnSubordinateRegistered();
                participant.StateMachine.ChangeState(state.States.SubordinateActive); 
            } 
            else
            { 
                if (status == Status.TransactionNotFound &&
                    !state.TransactionManager.Settings.NetworkInboundAccess)
                {
                    participant.ContextManager.Fault = this.state.Faults.SubordinateRegistrationNetAccessDisabled; 
                }
                else 
                { 
                    participant.ContextManager.Fault = this.state.Faults.SubordinateTMRegistrationFailed(status);
                } 

                participant.StateMachine.ChangeState(state.States.SubordinateFinished);
            }
        } 
    }
 
    //============================================================================== 
    // SubordinateActive
    // 
    // A dummy subordinate was created for the enlistment
    // We await news from the transaction manager
    //==============================================================================
    class SubordinateActive : InactiveState 
    {
        public SubordinateActive(ProtocolState state) : base(state) { } 
 
        public override void OnEvent(TmPrepareEvent e)
        { 
            ParticipantEnlistment participant = e.Participant;

            participant.SetCallback(e.Callback, e.CallbackState);
            state.TransactionManagerSend.ReadOnly(participant); 

            participant.StateMachine.ChangeState(state.States.SubordinateFinished); 
        } 

        public override void OnEvent(TmRollbackEvent e) 
        {
            ParticipantEnlistment participant = e.Participant;

            participant.SetCallback(e.Callback, e.CallbackState); 
            state.TransactionManagerSend.Aborted(participant);
 
            participant.StateMachine.ChangeState(state.States.SubordinateFinished); 
        }
    } 

    //=============================================================================
    // SubordinateFinished
    // 
    // The subordinate enlistment has ended
    //============================================================================== 
    class SubordinateFinished : TerminalState 
    {
        public SubordinateFinished(ProtocolState state) : base(state) { } 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK