[ Pobierz caÅ‚ość w formacie PDF ] .If you write your own server components that complete some or all of the data-base actions in your transaction, that component must be registered in an MTS42 Chapter 5 ObjectContext ObjectASP in a Nutshell: A Desktop Quick Reference, eMatter EditionCopyright © 2000 O Reilly & Associates, Inc.All rights reserved.SetAbortpackage.* MTS transactional support is provided only if the component is regis-tered.What s more, you should create your own library packages and not includeyour component in the IIS in-process package.Custom library packages can beused by multiple ASP applications and are run in the same process as the ASPDLL.Setting up library packages also gives your component the ability to bepooled for reuse by your applications.This pooling is managed by MTS as well.You also can add your components to a server package, but doing so is requiredonly for role-based transactions or transactions running on remote computers.Note that you should not give objects functioning in transactions session- or appli-cation-level scope, since transactional objects are deactivated at the end of theirtransaction.If you do give such an object session or application scope, calls afterthe end of the transaction will fail and raise an error.Although transactions are supported only for database actions, you can add codeto the OnTransactionCommit and OnTransactionAbort event procedures to provideyour own nondatabase transactional support.For example, code in these eventprocedures could easily be used to write or remove files from the file system uponsuccess or failure of a given transaction.ObjectContext exposes six methods other than the ones you can access throughASP.However, these are accessible only through code within the server compo-nents being managed by MTS.Transactional scripts are a very important addition to ASP.If you had access todatabase transactions only through use of ActiveX Data Objects, it would still be avery important and useful function.However, by creating custom server compo-nents, you can create complex and powerful transactions.Methods ReferenceSetAbortObjectContext.SetAbortAborts the transaction as a whole.When it is called, the transaction ends unsuc-cessfully, regardless of code that has or has not already been processed in yourscript.You can use this method in your script after testing for the completion of a givenpart of the transaction, or a server component managed by MTS can call it.CallingSetAbort rolls back any parts of the transaction that have already occurred andcalls the ObjectContext_OnTransactionAbort event procedure if one exists in yourscript.ParametersNone* For more information on MTS packages and server components, see the forthcoming book,Developing ASP Components, written by Shelley Powers and published by O Reilly & Associates.SetAbort 43ASP in a Nutshell: A Desktop Quick Reference, eMatter EditionCopyright © 2000 O Reilly & Associates, Inc.All rights reserved.SetAbortExampleNotesAny segment of a transactional script can call the SetAbort method.Note that ifyou have code that exists after the call to SetAbort, it will not be processed untilafter the execution of the OnTransactionAbort event procedure, if one exists.Forthis reason, be sure that your OnTransactionAbort event procedure performs anycleanup that is necessary for actions that are not supported in an MTS transaction(notably file actions).If you want some code to be processed regardless of a call to SetAbort, make surethat it is before the call to SetAbort in the script, or test for completion of the trans-action after your code in the script.44 Chapter 5 ObjectContext ObjectASP in a Nutshell: A Desktop Quick Reference, eMatter EditionCopyright © 2000 O Reilly & Associates, Inc.All rights reserved.OnTransactionAbortSetCompleteObjectContext.SetCompleteSignals the successful completion of a transaction.When it is called, the code inthe OnTransactionCommit event procedure code is processed if it exists
[ Pobierz całość w formacie PDF ] zanotowane.pldoc.pisz.plpdf.pisz.plmikr.xlx.pl
|