Oracle8i Enterprise JavaBeans and CORBA Developer's Guide Release 8.1.5 A64683-01 |
|
This section shows some examples that use the JTS interface for CORBA client code and CORBA server objects. See "Transaction Examples" for a set of complete examples that you can run and modify.
Follow these steps to use JTS methods in your CORBA client code:
AuroraTransactionService.initialize()
, passing to it the service URL for the application (for example, sess_iiop://localhost:2481:ORCL
) and the JNDI initial context.
TS.getTS().getCurrent().begin()
.
For example:
import oracle.aurora.jndi.sess_iiop.ServiceCtx; import oracle.aurora.jts.client.AuroraTransactionService; import oracle.aurora.jts.util.TS; import org.omg.CosTransactions.*; // Include normal startup code... // Initialize a transaction context... AuroraTransactionService.initialize(ic, serviceURL); // Begin a transaction... oracle.aurora.jts.util.TS.getTS().getCurrent().begin(); // Call methods that involve SQL DML... employee.updateEmployee(info); ... // Commit (or roll back) the SQL statements... oracle.aurora.jts.util.TS.getTS().getCurrent().commit(false);
For a complete example that uses these techniques for client-side transaction demarcation, see "clientside".
Follow these steps to use JTS methods in your CORBA server object code:
AuroraTransactionService.initialize()
on the server, as the server does this for you.
TS.getTS().getCurrent().begin()
. You can do this in a separate method, or as part of a method that does the first SQL DML using JDBC or SQLJ. A transaction spans methods--its scope is within the session where it is begun.
TS.getTS().getCurrent().commit(false), or TS.getTS().getCurrent().rollback().
You can also invoke other JTS methods, such as set_timeout()
, from within a server object.
See the complete example at "serversideJTS" for a demonstration of CORBA server-side transaction demarcation.
See the complete example at "multiSessions" for an example that establishes multiple server sessions, each with its own transaction context.