Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
3.9 KiB

  1. // Tranx.h: interface for transaction support.
  2. // Copyright (c)1997-2001 Microsoft Corporation
  3. //
  4. // Original date of creation: 4/09/2001
  5. // Author: shawnwu
  6. //////////////////////////////////////////////////////////////////////
  7. #if _MSC_VER >= 1000
  8. #pragma once
  9. #endif // _MSC_VER >= 1000
  10. #include "precomp.h"
  11. #include "sceprov.h"
  12. #include "GenericClass.h"
  13. /*
  14. Class description
  15. Naming:
  16. CTranxID stands for Transaction ID
  17. Base class:
  18. CGenericClass, because it is a class representing a WMI
  19. object - its WMI class name is Sce_TransactionID
  20. Purpose of class:
  21. (1) Sce_TransactionID is the transaction ID that is used for
  22. providers to identify who is causing its action so that
  23. we stand a chance to ask that provider to rollback this action.
  24. Foreign providers should use this ID to identify what they did
  25. during the transaction. Currently, WMI doesn't have transaction
  26. support and we need to do it our own. When WMI has that support,
  27. we can remove this class all together (if no third parties are
  28. using it).
  29. (2) CTranxID implements this WMI class Sce_TransactionID so that
  30. the SCE provider can process request for this WMI class. This
  31. Sce_TransactionID is a store oriented class, i.e., it is saved
  32. into a store when PutInst is called to this class.
  33. Design:
  34. (1) it implements all pure virtual functions declared in CGenericClass
  35. so that it is a concrete class to create.
  36. (2) Since it has virtual functions, the desctructor should be virtual.
  37. (3) This class is the only one that will create another WMI class called
  38. Sce_TransactionToken. See function header comments of SpawnTokenInstance.
  39. Use:
  40. (1) This class fulfills its obligation to Sce_TransactionID. The use for that
  41. functionality is guided by CGenericClass and you use it just as it is a
  42. CGenericClass object.
  43. (2) Use its static function in the following ways:
  44. (a) if you have a transaction id (in the form of a string), you can
  45. spawn a WMI instance of Sce_TransactionToken by calling SpawnTokenInstance
  46. (b) Call BeginTransaction to begin a transaction if that store (parameter)
  47. has a transaction id instance (Sce_TransactionID), then it will start
  48. a transaction. When you are done, call EndTransaction.
  49. */
  50. class CTranxID : public CGenericClass
  51. {
  52. public:
  53. CTranxID(
  54. ISceKeyChain *pKeyChain,
  55. IWbemServices *pNamespace,
  56. IWbemContext *pCtx
  57. );
  58. virtual ~CTranxID();
  59. public:
  60. //
  61. // The following four virtual functions are all mandatory to implement to become a concrete class
  62. //
  63. virtual HRESULT PutInst(
  64. IWbemClassObject *pInst,
  65. IWbemObjectSink *pHandler,
  66. IWbemContext *pCtx
  67. );
  68. virtual HRESULT CreateObject(
  69. IWbemObjectSink *pHandler,
  70. ACTIONTYPE atAction
  71. );
  72. //
  73. // we have nothing to clean up
  74. //
  75. virtual void CleanUp(){}
  76. static HRESULT BeginTransaction(
  77. LPCWSTR pszStorePath
  78. );
  79. static HRESULT EndTransaction();
  80. static HRESULT SpawnTokenInstance(
  81. IWbemServices* pNamespace,
  82. LPCWSTR pszTranxID,
  83. IWbemContext *pCtx,
  84. IWbemObjectSink* pSink
  85. );
  86. };