jBrokerはトランザクションサービスのプラグインをサポートしています。トランザクションサービスを実装(または既存のトランザクションサービスをラップ)して、トランザクションサービスをjBrokerに対して識別するために使用できるTransactionServiceおよびTSIdentificationインタフェースがあります。
TransactionService
トランザクションサービスは、TransactionServiceインタフェースを実装するために必要です。 このインタフェースは、CosTSPortabilityモジュールで指定されたSenderおよびReceiverインタフェースに類似しています。 CosTSPortability APIに厳密に従わずに、COS以外のトランザクション遵守トランザクションサービスも同様に容易にプラグインできるようにします。TransactionServiceをjBrokerで使用するために設定する方法には次の2通りがあります。
TransactionServiceインタフェースは次のとおりです。
- transaction.service.classプロパティをlibディレクトリの下のtransactions.propertiesファイルで、使用中のTransactionServiceの完全修飾クラス名に設定します。 ORBが初期化されると、このクラス名を使用してTransactionServiceのインスタンスが作成されます。 その後、ORBオブジェクト、ThreadContextオブジェクト、およびtransactions.propertiesファイルからのすべてのプロパティに渡して、初期化メソッドを呼び出すことにより、TransactionServiceインスタンスが初期化されます。
- プログラム上で、TransactionServiceインスタンスを作成し、ORBからTSIdentification初期オブジェクトを取得し、そのメソッドの識別を使用してTransactionServiceを設定します。 初期化メソッドはORB、ThreadContextオブジェクト、プロパティのヌルで呼び出されます。
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);
}
注記: 送信者/受信者メソッドで発生した例外は、クライアントに返されます。TSIdentification
TSIdentificationインタフェースは、ORBオブジェクトで使用されるようにTransactionServiceインスタンスをプログラム上で設定するために使用されます。
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 jBroker.
*/
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.