Platform SDK: Transaction Server |
[This product will work only on Windows NT 4.0 versions and earlier. For Windows 2000 and later, see COM+ (Component Services).]
The IObjectContext interface provides access to the current object's context.
Remarks
The header file for the IObjectContext interface is mtx.h.
You obtain a reference to the IObjectContext interface by calling the GetObjectContext function. As with any COM object, you must release an ObjectContext object when you're finished using it.
You can use an object's ObjectContext to:
The IObjectContext interface exposes the following methods.
Method | Description |
---|---|
CreateInstance | Instantiates another MTS object. |
DisableCommit | Declares that the object hasn't finished its work and that its transactional updates are in an inconsistent state. The object retains its state across method calls, and any attempts to commit the transaction before the object calls EnableCommit or SetComplete will result in the transaction being aborted. |
EnableCommit | Declares that the object's work isn't necessarily finished, but its transactional updates are in a consistent state. This method allows the transaction to be committed, but the object retains its state across method calls until it calls SetComplete or SetAbort, or until the transaction is completed. |
IsCallerInRole | Indicates whether the object's direct caller is in a specified role (either directly or as part of a group). |
IsInTransaction | Indicates whether the object is executing within a transaction. |
IsSecurityEnabled | Indicates whether security is enabled. MTS security is enabled unless the object is running in the client's process. |
SetAbort | Declares that the object has completed its work and can be deactivated on returning from the currently executing method, but that its transactional updates are in an inconsistent state or that an unrecoverable error occurred. This means that the transaction in which the object was executing must be aborted. If any object executing within a transaction returns to its client after calling SetAbort, the entire transaction is doomed to abort. |
SetComplete | Declares that the object has completed its work and can be deactivated on returning from the currently executing method. For objects that are executing within the scope of a transaction, it also indicates that the object's transactional updates can be committed. When an object that is the root of a transaction calls SetComplete, MTS attempts to commit the transaction on return from the current method. |
Note When an object calls DisableCommit, EnableCommit, SetComplete, or SetAbort from within a method, two flags (Done and Consistent) are set in its ObjectContext. (See the following table for an explanation.) These flags aren't evaluated by the MTS run-time environment until the object's currently executing method returns to its caller. This means that an object can call these methods any number of times from within one of its own methods, but the last call before the object returns to its client is the one that will be in effect.
Method | Done | Consistent |
---|---|---|
SetAbort | TRUE | FALSE |
SetComplete | TRUE | TRUE |
DisableCommit | FALSE | FALSE |
EnableCommit | FALSE | TRUE |
The Done flag, which allows an object to be deactivated and its transaction to commit or abort, is only evaluated after the object returns from the call that first entered its context. For example, suppose client A calls into object B. Object B calls SetComplete and then calls into object C (passing it a safe reference for a callback). Object C calls back to object B, and then object B returns to client A. Object B won't be deactivated when it returns to object C; it will be deactivated when it returns to client A.
See Also
Basic Security Methods, Passing Object References, Context Objects, Transactions, Deactivating Objects