![]() |
Overview Returns an object that represents the transaction context currently associated with the current thread, and disassociates the currently associated transaction context from the current thread. Original interface CosTransactions::Current Interface
Intended Usage
If there is no current transaction, a NULL reference is returned.
This object can be given to the resume operation to reestablish this context in the same, or a different, thread within the same server process.
IDL Syntax
Control suspend();
Input parameters
- Control
- Represents the transaction context currently associated with the current thread. The caller should not free the returned object; the Transaction Service retains ownership of it.
Return values
None.
Examples
The following examples demonstrate the usage of CosTransactions::Current::suspend.
C++ Example
#include <CosTransactions.hh> // CosTransactions module ... CosTransactions::Control_ptr control = NULL; ... //Access the CosTransactions::Current object. CORBA::Object_ptr orbCurrentPtr = CBSeriesGlobal::orb()->resolve_initial_references("TransactionCurrent"); CosTransactions::Current_ptr current = CosTransactions::Current::_narrow(orbCurrentPtr); ... // Invoke the begin operation on the CosTransactions::Current object. current->begin(); ... // Suspend the association between the transaction and the thread. control = current->suspend(); if (!control) { // There was no transaction associated with this thread prior to the // suspend. Perform appropriate action. cout << "Error: No transaction prior to suspend" << endl; }
Java Example
import org.omg.CosTransactions.*; // CosTransactions module ... org.omg.CosTransactions.Control control = null; ... //Access the org.omg.CosTransactions.Current object. org.omg.CORBA.Object orbCurrentPtr = com.ibm.CBCUtil.CBSeriesGlobal.orb().resolve_initial_references( "TransactionCurrent"); org.omg.CosTransactions.Current current = org.omg.CosTransactions.CurrentHelper.narrow(orbCurrentPtr); ... // Invoke the begin operation on the org.omg.CosTransactions.Current object. current.begin(); ... // Suspend the association between the transaction and the thread. control = current.suspend(); if (control == null) { // There was no transaction associated with this thread prior to the // suspend. Perform appropriate action. System.out.println ("Error: No transaction prior to suspend"); }