Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / TransactionBridge / Microsoft / Transactions / Wsat / StateMachines / TransactionContext.cs / 1 / TransactionContext.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- // This file contains the the implementations of the various states used by // the transaction context state machine. // // This state machine exists to solve the rather unpleasant problems associated // with receiving CreateCoordinationContext w/ context messages in various circumstances. // // Most notably, we can't send a CCCR message to anyone before we know that we're // part of the distributed transaction. So if we're subordinate to a foreign TM, we can't // send anyone a CCCR until we have successfully registered for durable 2PC with our superior. // Since there's no such thing as a PPL EnlistPrepare, we have to handle the queueing of // requests ourselves. // // This state machine is driven by either a Coordinator state machine, a Subordinate state machine // or a Completion state machine. When our 'parent' state machine enters a terminal state, its // associated enlistment will send us a TransactionContextTransactionDoneEvent. That event will // make us transition to our own finished state, which will trigger the removal of our context manager // from the global lookup table. using Microsoft.Transactions.Wsat.Messaging; using Microsoft.Transactions.Wsat.Protocol; namespace Microsoft.Transactions.Wsat.StateMachines { class TransactionContextInitializing : InactiveState { public TransactionContextInitializing(ProtocolState state) : base (state) {} // Delivered when we receive a CCC w/ context message // and there's nothing in the transaction context lookup table public override void OnEvent(TransactionContextEnlistTransactionEvent e) { // Add the event to the queue and change states e.ContextManager.Requests.Enqueue(e); e.StateMachine.ChangeState(state.States.TransactionContextInitializingCoordinator); // Forward the event to a new coordinator state machine // It will eventually call us back when it decides that we're ready to answer CoordinatorEnlistment coordinator = new CoordinatorEnlistment(state, e.ContextManager, e.Body.CurrentContext, e.Body.IssuedToken); CreateCoordinationContext body = e.Body; MsgEnlistTransactionEvent newEvent = new MsgEnlistTransactionEvent(coordinator, ref body, e.Result); coordinator.StateMachine.Enqueue(newEvent); } // Delivered by the completion state machine public override void OnEvent(TransactionContextCreatedEvent e) { e.ContextManager.TransactionContext = e.TransactionContext; e.StateMachine.ChangeState(state.States.TransactionContextActive); } } class TransactionContextInitializingCoordinator : InactiveState { public TransactionContextInitializingCoordinator(ProtocolState state) : base(state) { } public override void OnEvent(TransactionContextEnlistTransactionEvent e) { e.ContextManager.Requests.Enqueue(e); } public override void OnEvent(TransactionContextCreatedEvent e) { e.ContextManager.TransactionContext = e.TransactionContext; e.StateMachine.ChangeState(state.States.TransactionContextActive); } public override void OnEvent(TransactionContextTransactionDoneEvent e) { e.StateMachine.ChangeState(state.States.TransactionContextFinished); } } class TransactionContextActive : InactiveState { public TransactionContextActive(ProtocolState state) : base(state) { } public override void Enter(StateMachine stateMachine) { base.Enter(stateMachine); TransactionContextStateMachine contextStateMachine = (TransactionContextStateMachine)stateMachine; TransactionContextManager contextManager = contextStateMachine.ContextManager; foreach (TransactionContextEnlistTransactionEvent e in contextManager.Requests) { state.ActivationCoordinator.SendCreateCoordinationContextResponse(contextManager.TransactionContext, e.Result); } contextManager.Requests.Clear(); } public override void OnEvent(TransactionContextEnlistTransactionEvent e) { state.ActivationCoordinator.SendCreateCoordinationContextResponse(e.ContextManager.TransactionContext, e.Result); } public override void OnEvent(TransactionContextTransactionDoneEvent e) { e.StateMachine.ChangeState(state.States.TransactionContextFinished); } } class TransactionContextFinished : TerminalState { public TransactionContextFinished(ProtocolState state) : base(state) { } public override void Enter(StateMachine stateMachine) { base.Enter(stateMachine); TransactionContextStateMachine contextStateMachine = (TransactionContextStateMachine)stateMachine; TransactionContextManager contextManager = contextStateMachine.ContextManager; Fault fault = contextManager.Fault; foreach (TransactionContextEnlistTransactionEvent e in contextManager.Requests) { state.ActivationCoordinator.SendFault(e.Result, fault); } contextManager.Requests.Clear(); } public override void OnEvent(TransactionContextEnlistTransactionEvent e) { state.ActivationCoordinator.SendFault(e.Result, e.ContextManager.Fault); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ToolboxCategory.cs
- WebBrowserBase.cs
- Pen.cs
- Marshal.cs
- BrowserCapabilitiesFactory.cs
- HostProtectionPermission.cs
- Literal.cs
- ObjectConverter.cs
- DataControlButton.cs
- SettingsPropertyCollection.cs
- CollectionBuilder.cs
- StylusDevice.cs
- IgnoreFileBuildProvider.cs
- XNameConverter.cs
- Automation.cs
- ComEventsSink.cs
- WindowsFormsHost.cs
- SymbolMethod.cs
- Asn1IntegerConverter.cs
- XmlCodeExporter.cs
- SecureConversationServiceCredential.cs
- CookieProtection.cs
- IteratorFilter.cs
- MimePart.cs
- Viewport2DVisual3D.cs
- CapabilitiesAssignment.cs
- webclient.cs
- CreateUserWizardStep.cs
- ChtmlLinkAdapter.cs
- WizardSideBarListControlItemEventArgs.cs
- FacetDescription.cs
- UnauthorizedAccessException.cs
- HostedElements.cs
- QilInvokeLateBound.cs
- ObjectStateEntry.cs
- SqlClientWrapperSmiStream.cs
- ValidationEventArgs.cs
- ContractBase.cs
- TraceHandlerErrorFormatter.cs
- FixedNode.cs
- CodeGeneratorOptions.cs
- SQLInt32.cs
- glyphs.cs
- ISCIIEncoding.cs
- DataControlFieldCollection.cs
- ToolStripHighContrastRenderer.cs
- SelectionEditor.cs
- ScriptManager.cs
- AuthStoreRoleProvider.cs
- ScriptingSectionGroup.cs
- HostSecurityManager.cs
- AvTraceFormat.cs
- RelatedEnd.cs
- SettingsAttributeDictionary.cs
- XmlUrlEditor.cs
- LinqDataSourceDisposeEventArgs.cs
- RenderData.cs
- Win32Native.cs
- AutoResizedEvent.cs
- ImageKeyConverter.cs
- XmlSchemaComplexContentRestriction.cs
- TraceSource.cs
- DialogWindow.cs
- InputBinder.cs
- WsdlBuildProvider.cs
- PartialClassGenerationTask.cs
- MobileRedirect.cs
- XmlNodeChangedEventManager.cs
- ButtonPopupAdapter.cs
- RelationshipConstraintValidator.cs
- ColumnMapVisitor.cs
- TreeView.cs
- OLEDB_Util.cs
- PipeStream.cs
- ThumbAutomationPeer.cs
- XmlCustomFormatter.cs
- MenuItemStyleCollection.cs
- FixedSOMLineCollection.cs
- Point3DAnimation.cs
- CollectionEditorDialog.cs
- GPPOINTF.cs
- OutKeywords.cs
- RestHandlerFactory.cs
- HttpModuleActionCollection.cs
- Track.cs
- WindowsAuthenticationEventArgs.cs
- CollaborationHelperFunctions.cs
- SmtpReplyReader.cs
- QuaternionKeyFrameCollection.cs
- SqlConnection.cs
- TimerEventSubscriptionCollection.cs
- HostedTransportConfigurationManager.cs
- DataGridViewMethods.cs
- SpellCheck.cs
- SiblingIterators.cs
- PermissionRequestEvidence.cs
- TextRange.cs
- SHA512Managed.cs
- RoleManagerEventArgs.cs
- CodeParameterDeclarationExpression.cs