The ORB provides support for plugging in a transaction service. It provides the TransactionService and the TSIdentification interfaces that can be used to implement a transaction service (or wrap an existing Transaction Service) and to identify the Transaction Service to the ORB.
TransactionService
A transaction service is required to implement the TransactionService interface. This interface is similar to the Sender and Receiver interfaces specified in the CosTSPortability module. We chose not to strictly follow the CosTSPortability APIs so that non-COS Transactions compliant transaction services may also be plugged in easily as well.There are two ways you can set a TransactionService to be used with ORB:
The TransactionService interface is as following.
- by setting the "transaction.service.class" property in the "transactions.properties" file under the lib directory to the fully qualified class name of your TransactionService. When the ORB is initialized, it creates an instance of the TransactionService using this class name. It then initializes the TransactionService instance by calling initialize method on it passing it the ORB object, a ThreadContext object, and all the properties from the "transactions.properties" file.
- programmatically create a TransactionService instance, get the TSIdentification initial object from the ORB, and then set the TransactionService using the identify method on it. The initialize method will get called on the TransactionService instance with the ORB, a ThreadContext object, and null for properties.
package com.sssw.jbroker.api.transaction; import java.util.Properties;
import org.omg.CORBA.ORB;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;public interface TransactionService
{
/**
* Initialize the TransactionService.
*/
void initialize(ORB orb,ThreadContext threadContext, Properties props);/**
* A request is about to be sent. The Transaction Service should
* write the transaction Context using the provided OutputStream.
* The method is only called for objects that inherit from
* org.omg.CosTransactions.TransactionalObject. This method is
* not called if the method invocation will not switch a thread.
*/
void sendingRequest(int requestId, OutputStream contextOS);/**
* A reply has been received. The transaction context from the
* server is available in the given InputStream. The exception
* if not null specifies the exception that occurred. This method is
* only called if there is a transaction context in the received
* reply.
*/
void receivedReply(int requestId, InputStream contextIS,
Exception ex);/**
* A request has been received. The PropagationContext defining the
* transaction can be read from the given InputStream. This method is
* only called if there is a transaction context in the received
* request.
*/
void receivedRequest(int requestId, InputStream contextIS);/**
* A reply is about to be sent. The Transaction Service writes the
* transaction PropagationContext using the provided OutputStream.
* This method is only called if there was a transaction context in
* the received request.
*/
void sendingReply(int requestId, OutputStream contextIS);
}
Note: Any exception thrown by the sender/receiver methods, is thrown back to the client.TSIdentification
The TSIdentification interface is used to programmatically set the TransactionService instance to be used by an ORB object.
package com.sssw.jbroker.api.transaction; /**
* The TSIdentification is an initial service that can be used to set the
* Transaction Service to be used with the ORB.
*/
public interface TSIdentification extends org.omg.CORBA.Object
{
/**
* Set the Transaction Service to be used with ORB. If a transaction
* service is already set and is not the same as the secified Transaction
* Service, then a BAD_PARAM CORBA System exception is thrown.
* The TSIdentification implementation invokes the initialize method
* on the supplied Transaction Service.
*/
void identifyTransactionService(TransactionService ts);
}
Copyright © 1998-2003, Novell, Inc. All rights reserved.