Switch Table
The XA interface describes a structure called a switch table, which lists the names of the xa_ routines implemented in the resource manager. This structure is called xa_switch_t, and is defined in the xa.h header file. The switch table helps build servers that are truly independent of the database vendor being used.
In order to be integrated in the X/Open environment, each resource manager must define the name of its XA switch table. Sybase provides two XA switches:
*sybase_TUX_xa_switch, for single-threaded applications
*sybase_TXS_xa_switch, for multithreaded applications.
In spite of the nominal implication that the TUX and TXS switch structures are TPM-specific, the use of these switches is not dependent on the use of Tuxedo or TXS TPMs. Rather, as described above, their use is dependent on whether the application is single-threaded or multithreaded.
NOTE: If you are using a single-threaded build for the DB XA Module, you must use sybase_TUX_xa_switch as the xa switch table and for multithreaded builds you must use sybase_TXS_xa_switch. The DB XA Module may not function properly if you use the wrong switches.
You can use the following DB XA method to access the switch table in a database-independent manner:
 
static void* RWDBManager::xaSwitch(const RWCString& accessLib)
If you have built the DB XA Module using a single-threaded build type, xaSwitch() returns sybase_TUX_xa_switch. If you are using a multithreaded build, this method returns sybase_TXS_xa_switch.
For static libraries, you must supply "SYBASE_CT" to the xaSwitch() method.
 
(struct xa_switch_t*)RWDBManager::xaSwitch("SYBASE_CT");
For shared libraries, you must supply the name of the access library, using the same name as the non-XA library. For example:
 
(struct xa_switch_t *)RWDBManager::xaSwitch("libct<ver>8d.so");
Note that the method RWDBManager::xaSwitch(const RWCString&) returns a void*. This return value must be cast to a struct xa_switch_t pointer.