ユーザーズ・ガイド

     前  次    新規ウィンドウで目次を開く    PDFとして表示 - 新規ウィンドウ  Adobe Readerを取得 - 新規ウィンドウ
コンテンツはここから始まります

Oracle Tuxedo JCA Adapterインフロー・トランザクション・ガイド

このガイドでは、コネクタ・ベースのMDB (非JMSベースのMDB)機能を使用して、インフロー・トランザクションの構成、デプロイメント、およびプログラミングを行う方法について説明します。この機能を使用すると、Oracle TuxedoからJavaアプリケーション・サーバーへのインフロー(インバウンド)トランザクションが可能になります。この付録の内容は以下のとおりです。

 


パッケージングとコンテンツ

インフロー・トランザクション機能は、 RARファイルとして配布されます。jarファイルを解凍し、Oracle Tuxedo JCA Adapter構成をアプリケーション・サーバーにインストールする前に構成を変更する必要があります。

サポートされるアプリケーション・サーバーとOracle Tuxedoのバージョン

表1は、サポートされるOracle Tuxedoとアプリケーション・サーバーのバージョンのリストです。

表1 サポートされるバージョン
名前
バージョン
WebSphereアプリケーション・サーバー
7.0
Oracle Tuxedo
11gR1PS1

RARファイル名

RARファイル名は、com.oracle.tuxedo.TuxedoAdapter.rarです。Oracle Tuxedo JCA Adapter構成を変更した後、(任意の名前を使用して)構成をアーカイブ化し、Oracle Tuxedo JCA Adapterをアプリケーション・サーバーに構成できます。

RARファイルのコンテンツ

表2は、RARファイルのコンテンツのリストです。

表2 RARファイルのコンテンツ
ファイル名
説明
adapter.properties
Oracle Tuxedo JCA Adapterのメッセージ・カタログ。
adapter_ja.properties
Oracle Tuxedo JCA Adapterのメッセージ・カタログの日本語版。
com.bea.core.i18n_1.4.0.0.jar
I18Nライブラリ
com.bea.core.jatmi_1.3.2.0.jar
JATMIライブラリ
com.oracle.tuxedo.adapter_1.2.1.0.jar
Oracle Tuxedo JCA Adapter
dmconfig.xml
Oracle Tuxedo JCA Adapter構成のdmconfigサンプル・ファイル。
javax.ejb_3.0.1.jar
EJB 3.0ライブラリ
javax.transaction_1.0.0.0_1-1.jar
JTA 1.1ライブラリ
tja.xsd
Oracle Tuxedo JCA Adapterのスキーマ・ファイル。
META-INF/MANIFEST.MF
マニフェスト・ファイル
META-INF/client-side.ra.xml
クライアント側専用のリソース・アダプタ・デプロイメント記述子サンプル
META-INF/ra.xml
接続ファクトリ・ベースの構成用リソース・アダプタ・デプロイメント記述子サンプル
META-INF/sample.weblogic-ra.xml
接続ファクトリ・ベースの構成用WebLogic Serverのweblogic-ra.xmlサンプル・ファイル
META-INF/server.ra.xml
dmconfigベース構成用リソース・アダプタ・デプロイメント記述子サンプル
META-INF/weblogic-ra.xml
WebLogic Serverのweblogic-ra.xmlサンプル・ファイル

 


概要

Oracle Tuxedo JCA Adapterは、トランザクション・コンテキスト・フォーマットなどのOracle Tuxedo TDOMAINプロトコルをサポートしています。図1を参照してください。Oracle Tuxedo JCA Adapterは、Oracle Tuxedoからインバウンド・リクエストを受信し、関連するOracle Tuxedoトランザクション・コンテキストがあるかどうかチェックします。トランザクション・コンテキストがある場合、Oracle Tuxedo JCA Adapterは、Oracle Tuxedoトランザクション・コンテキストに基づきjavax.transaction.xa.Xidを作成します。

Oracle Tuxedo JCA Adapterは、このXIDをExecutionContextに設定し、実行するためにExecutionContextと共にWorkインスタンスをアプリケーション・サーバーWorkManagerに送信します。インポートしたトランザクションをこの手順でJavaアプリケーション・サーバーに伝播すると、アプリケーション・サーバーと後続の参加者はインポートしたトランザクションの一部として機能できます。

図1 Oracle Tuxedo TDOMAINプロトコル

Oracle Tuxedo TDOMAINプロトコル

 


構成

構成は2つのパートに分けることができます。最初のパートはOracle Tuxedo JCA Adapter構成、次のパートはアプリケーション・サーバーにおけるアダプタの構成です。

Oracle Tuxedo JCA Adapter構成

「エクスポートした」サービスとは、Oracle Tuxedoクライアントによってアクセスが可能なJavaリソースです。この特別な場合には、コネクタ・ベースのMDBです。Javaアプリケーション・サーバーにあるリソースにアクセスするには、Oracle Tuxedoクライアント用dmconfigファイルで「Export」要素を構成する必要があります

dmconfigファイル内の1つの「Export」要素は、Oracle Tuxedoクライアントにエクスポートしたリソースを参照します。リスト1は、Oracle Tuxedoクライアントにエクスポートした2つのサービス(TolowerEcho)を示しています。RemoteNameは、Oracle Tuxedo GWTDOMAINゲートウェイによってサービスが呼び出される場合に使用されるサービス名です。name属性はリソースのサービス名です。Typeはインフロー・トランザクション用MDBにする必要があり、SourceはMDBのJNDIバインディングです。

リスト1 エクスポートされたサービスの例
<Export name=”Tolower”>
  <RemoteName>TolowerMDB</RemoteName>
  <SessionName>session_1</SessionName>
  <Type>MDB</Type>
  <Source>eis/Tolower</Source>
</Export>
<Export name=”Echo”>
  <RemoteName>EchoMDB</RemoteName>
  <SessionName>session_1</SessionName>
  <Type>MDB</Type>
  <Source>eis/Echo</Source>
</Export>

1つのMDBを使用してエクスポートされた複数のサービスもサポートされます。これには、アダプタ・アプリケーション開発者の自由度を向上する目的があります。dmconfigファイルのSource要素で指定したJNDI名と同一の名前を使用して複数のサービスを構成できます。ただし、当該MDBにはアプリケーションによって実装されたインタフェースが1つしかないため、アプリケーションが独自にディスパッチを実行する必要があります。リスト2は、1つのMDBを使用してエクスポートされた複数のサービスの例を示しています。

リスト2 エクスポートされた複数のサービスの例
<Export name=”INFO_SERVICE”>
  <RemoteName>INFO</RemoteName>
  <SessionName>session_1</SessionName>
  <Type>MDB</Type>
  <Source>eis/services</Source>
</Export>
<Export name=”ACCOUNT_SERVICE”>
  <RemoteName>ACCOUNT</RemoteName>
  <SessionName>session_1</SessionName>
  <Type>MDB</Type>
  <Source>eis/services</Source>
</Export>

この例では、JNDI名eis/servicesにバインドする同一のMDBを使用して、Oracle Tuxedoクライアントに2つのサービス(INFOACCOUNT)をエクスポートします。ここでは、MDBに渡したサービス名を使用してディスパッチするMDBを1つ構成してデプロイする必要があります。リスト3は、独自にディスパッチを実行するMDBサンプル・コード・フラグメントを示しています。

リスト3 MDBコード・フラグメント
public Reply service(TPServiceInformation mydata)
    throws TuxedoReplyException
{
  String serviceName = mydata.getServiceName();
  if (serviceName.equals(“ACCOUNT_SERVICE”)) {
    doAccount1(mydata);
  }
   else if (serviceName.equals(“INFO_SERVICE”)) {
    doInfo(mydata);
  }
  else {
    /* throws an exception */
  }
}

リスト4は、Oracle Tuxedo JCA Adapter構成ファイルの詳細な例を示しています。

リスト4 Oracle Tuxedo JCA Adapter構成ファイルの例
<?xml version="1.0" encoding="UTF-8"?><TuxedoConnector>
  <LocalAccessPoint name="JDOM">
    <AccessPointId>JDOM_ID</AccessPointId>
    <NetworkAddress>//localhost:10801</NetworkAddress>
  </LocalAccessPoint>
  <RemoteAccessPoint name="TDOM1">
    <AccessPointId>TDOM1_ID</AccessPointId>
    <NetworkAddress>//localhost:12478</NetworkAddress>
  </RemoteAccessPoint>
  <SessionProfile name="profile_1">
    <BlockTime>60000</BlockTime>
    <ConnectionPolicy>ON_STARTUP</ConnectionPolicy>
  </SessionProfile>
  <Session name="session_1">
    <LocalAccessPointName>JDOM</LocalAccessPointName>
    <RemoteAccessPointName>TDOM1</RemoteAccessPointName>
    <ProfileName>profile_1</ProfileName>
  </Session>
  <Export name="Tolower">
    <RemoteName>TolowerMDB</RemoteName>
    <SessionName>session_1</SessionName>
    <Type>MDB</Type>
    <Source>eis/tolower</Source>
  </Export>
  <Export name="Echo">
    <RemoteName>EchoMDB</RemoteName>
    <SessionName>session_1</SessionName>
    <Type>MDB</Type>
    <Source>eis/echo</Source>
  </Export>
  <Export name="INFO_SERVICE">
    <RemoteName>INFO</RemoteName>
    <SessionName>session_1</SessionName>
    <Type>MDB</Type>
    <Source>eis/services</Source>
  </Export>
  <Export name="ACCOUNT_SERVICE">
    <RemoteName>ACCOUNT</RemoteName>
    <SessionName>session_1</SessionName>
    <Type>MDB</Type>
    <Source>eis/services</Source>
  </Export>
</TuxedoConnector>

アプリケーション・サーバーのリソース・アダプタの構成

リソース・アダプタ・デプロイメント記述子(ra.xml)を構成する必要があります。ra.xmlという名前は変更できません。すべてのRARファイルは、1つのra.xmlファイルを格納する必要があります。MDBを使用してインフロー・トランザクションを機能させるには、inbound-resourceadapter要素を構成する必要があります。この要素は、Oracle Tuxedo JCA Adapter専用のインタフェースとアクティブ化仕様を記述するために使用されます。

inbound-resourceadapter要素を修正します。構成可能なプロパティは、sourceプロパティのみです。構成済の場合、JCAコンテナには、EJB記述子(ejb-jar.xml)ファイルで指定されるsourceプロパティが必要になります。

リスト5は、ra.xmlファイルの例を示しています。ベースとしてOracle Tuxedo JCA Adapterと共に配布されるra.xmlファイルを使用して、必要に応じてカスタマイズできます。

リスト5 ra.xmlファイルの例
<?xml version="1.0" encoding="UTF-8"?>
<connector xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
    version="1.5">
  <display-name>Tuxedo JCA Adapter</display-name>
  <vendor-name>Oracle</vendor-name>
  <eis-type>Tuxedo</eis-type>
  <resourceadapter-version>11gR1(11.1.1.2.1)</resourceadapter-version>
  <license>
    <description>Tuxedo SALT license</description>
    <license-required>false</license-required>
  </license>
  <resourceadapter>
    <resourceadapter-class>com.oracle.tuxedo.adapter.TuxedoResourceAdapter</resourceadapter-class>
    <!--
      The following is the list of properties name can be configured as adapter-wise configuration.
      traceLevel  - java.lang.String  - a numerical value
      xaAffinity  - java.lang.String  - transaction affinity to a remote domain, "true" or "false", default to true
      keyFileName - java.lang.String  - encryption key file name
      throwFailureReplyException - java.lang.Boolean - default to ture
      appManagedLocalTxTimeout   - java.lang.Integer - Application managed transaction or AUTOTRAN timeout
                                                       defaults to 300 seconds
      fieldTable16Class - java.lang.String - a comma-separated list of fully qualified FML classes
      fieldTable32class - java.lang.String - a comma-separated list of fully qualified FML32 classes
      viewFile16Class   - java.lang.String - a comma-separated list of fully qualified VIEW classes
      viewFile32Class   - java.lang.String - a comma-separated list of fully qualified VIEW32 classes
      tpusrFile         - java.lang.String - path name to the TPUSR file 
      remoteMBEncoding  - java.lang.String - remote Tuxedo encoding name for multi-byte language
      mBEncodingMapFile - java.lang.String - path name to Multi-byte encoding name mapping
      autoTran          - java.lang.Boolean- enable adapter-wise AUTOTRAN, default to false
    -->
    <outbound-resourceadapter>
      <connection-definition>
        <managedconnectionfactory-class>com.oracle.tuxedo.adapter.spi.TuxedoManagedConnectionFactory</managedconnectionfactory-class>
        <!--
          The following is the list of properties that you can use
          to configure thee connection pool or connection factory.
          You must either configure localAccessPointSpec or
          connectionFactoryName if transaction is used.
          These property described here is serving as template, user should not
          configure them here, instead user should configure them either through WebSphere console 
          or weblogic-ra.xml side file.
        -->
        <config-property>
          <description>factory-wise AUTOTRAN setting, default to false, overrides adapter-wise setting</description>
          <config-property-name>autoTran</config-property-name>
          <config-property-type>java.lang.Boolean</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise Failure Reply Exception setting, default to true, overrides adapter-wise setting</description>
          <config-property-name>throwFailureReplyException</config-property-name>
          <config-property-type>java.lang.Boolean</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise application managed transaction or AUTOTRAN time out, overrides adapter-wise setting</description>
          <config-property-name>appManagedLocalTxTimeout</config-property-name>
          <config-property-type>java.lang.Integer</config-property-type>
        </config-property>
        <config-property>
          <description>connection factory or pool name, this is required if XA or local application managed
                       transaction is required</description>
          <config-property-name>connectionFactoryName</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>application password in either clear text or cipher text using com.oracle.tuxedo.tools.EncryptPassword tool</description>
          <config-property-name>applicationPassword</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>local access point specification of the format //hostname:port/domainId=DOMAINID</description>
          <config-property-name>localAccessPointSpec</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise SSL to configure whether mutual authentication is required, default to false</description>
          <config-property-name>mutualAuthenticationRequired</config-property-name>
          <config-property-type>java.lang.Boolean</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise SSL for configuring identity key store file name, must be configured if SSL is desired</description>
          <config-property-name>identityKeyStoreFileName</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise SSL setting for private key alias used in the key store, must be configured if SSL is desired</description>
          <config-property-name>privateKeyAlias</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise trusted key store file name, must be configured if SSL is desired</description>
          <config-property-name>trustedKeyStoreFileName</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise password for identityKeyStore in clear text</description>
          <config-property-name>identityKeyStorePassPhrase</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise password for privateKeyAlias in clear text</description>
          <config-property-name>privateKeyAliasPassPhrase</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise password for trustedKeyStore in clear text</description>
          <config-property-name>trustedKeyStorePassPhrase</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise RemoteAccessPoint specification of the format //hostname:port/domainId=DOMAINID</description>
          <config-property-name>remoteAccessPointSpec</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise allow anonymous access to Tuxedo, default to false</description>
          <config-property-name>rapAllowAnonymous</config-property-name>
          <config-property-type>java.lang.Boolean</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise application key value for anonymous user, default to -1</description>
          <config-property-name>rapDefaultApplicationKey</config-property-name>
          <config-property-type>java.lang.Integer</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise application key fully qualified class name for AppKey generator</description>
          <config-property-name>rapApplicationKeyClass</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise custom application key parameter</description>
          <config-property-name>rapApplicationKeyClassParam</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise session profile block timeout value, default to 60000 milliseconds</description>
          <config-property-name>spBlockTime</config-property-name>
          <config-property-type>java.lang.Integer</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise whether allows interoperate with 6.5 Tuxedo Domain, default to false</description>
          <config-property-name>spInteroperate</config-property-name>
          <config-property-type>java.lang.Boolean</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise security setting, legal values: NONE, DM_PW, APP_PW</description>
          <config-property-name>spSecurity</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise credential propagation policy, either LOCAL or GLOBAL</description>
          <config-property-name>spCredentialPolicy</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise number of seconds that session waits between automatic connection establishment,
                       default to 60 seconds. A value of 0 disabled connection retry</description>
          <config-property-name>spRetryInterval</config-property-name>
          <config-property-type>java.lang.Long</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise maximum number of times adapter will try to establish a session connection to
                       remote Tuxedo access point. Default value is Long.MAX_VALUE.</description>
          <config-property-name>spMaxRetries</config-property-name>
          <config-property-type>java.lang.Long</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise compression threshold, default to Integer.MAX_VALUE</description>
          <config-property-name>spCompressionLimit</config-property-name>
          <config-property-type>java.lang.Integer</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise minimum encryption strength requirement, legal values are 0, 40, 56, 128, 256.
                       Default value is 0.</description>
          <config-property-name>spMinEncryptBits</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise maximum encryption strength requirement, legal values are 0, 40, 56, 128, 256.
                       Default value is 128.</description>
          <config-property-name>spMaxEncryptBits</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise the maximum idle time before sending application level keep alive.
                       It is measured in millisecond, and roundup to seconds. Default value is 0.</description>
          <config-property-name>spKeeyAlive</config-property-name>
          <config-property-type>java.lang.Long</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise how long adapter will wait for acknowledgement before adapter decides the
                       connection already lost.  Measurement in millisecond, and its default value is 10 seconds.
                       A value of 0 will disable the wait, and thus will not close the connection</description>
          <config-property-name>spKeepAliveWait</config-property-name>
          <config-property-type>java.lang.Long</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise valid Tuxedo service names in a comma-separated list.  If not specified then
                       default import will be used and will grant all service request to remote Tuxedo domain</description>
          <config-property-name>impResourceName</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>Exported resource, types of resource supported are EJB, POJO, MDB.</description>
          <config-property-name>exportSpec</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
        <connectionfactory-impl-class>com.oracle.tuxedo.adapter.cci.TuxedoConnectionFactory</connectionfactory-impl-class>
        <connection-interface>javax.resource.cci.Connection</connection-interface>
        <connection-impl-class>com.oracle.tuxedo.adapter.cci.TuxedoJCAConnection</connection-impl-class>
      </connection-definition>
<!--
      <transaction-support>NoTransaction</transaction-support>
      <transaction-support>LocalTransaction</transaction-support>
-->
      <transaction-support>XATransaction</transaction-support>
      <authentication-mechanism>
        <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
        <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
      </authentication-mechanism>
      <reauthentication-support>false</reauthentication-support>
    </outbound-resourceadapter>
    <inbound-resourceadapter>
      <messageadapter>
        <messagelistener>
          <messagelistener-type>com.oracle.tuxedo.adapter.intf.TuxedoMDBService</messagelistener-type>
          <activationspec>
            <activationspec-class>com.oracle.tuxedo.adapter.spi.TuxedoActivationSpec</activationspec-class>
            <required-config-property>
              <config-property-name>source</config-property-name>
            </required-config-property>
          </activationspec>
        </messagelistener>
      </messageadapter>
    </inbound-resourceadapter>
  </resourceadapter>
</connector>

inbound-resourceadapter要素には、コンテナ・ベースのMDBで実装する必要があるインタフェース・クラスとアクティブ化仕様クラスが含まれます。

完全修飾インタフェース名は、com.oracle.t uxedo.adapter.intf.TuxedoMDBServiceです。完全修飾アクティブ化仕様は、com.oracle.tuxedo.adapter.spi.TuxedoActivationSpecです。Oracle Tuxedo JCA Adapter ra.xmlファイルでこれらの2つの値のいずれも変更しないでください

Oracle Tuxedo GWTDOMAINゲートウェイの構成

Oracle Tuxedo JCA Adapterと通信するには、Oracle Tuxedo GWTDOMAINゲートウェイを構成する必要もあります。リスト6は、Tuxedo /Domain構成ファイルの例を示しています。

リスト6 Tuxedo /Domain構成ファイルの例
#
*DM_RESOURCES
#
VERSION=U22
# 
#
#
*DM_LOCAL_DOMAINS
#
# NOTE: Remove DYNAMIC_RAP line if you are not running with Tuxedo 11.1.1.2.0
#
"TDOM1"    GWGRP=GROUP3
	TYPE=TDOMAIN
	DOMAINID="TDOM1_ID"
	BLOCKTIME=60
	SECURITY=NONE
            DMTLOGDEV="C:\test\JCA\inflow_tx/tdom/DMTLOG"
            DYNAMIC_RAP="YES"
#
*DM_REMOTE_DOMAINS
#
#
JDOM 	TYPE=TDOMAIN
	DOMAINID="JDOM_ID"
#
#
*DM_TDOMAIN
#
TDOM1	NWADDR="//localhost:12478"
JDOM 	NWADDR="//localhost:10801"
#
#
*DM_LOCAL_SERVICES
#
#Exported
#
#
*DM_REMOTE_SERVICES
#
#Imported
#
TolowerMDB
EchoMDB
INFO
ACCOUNT

この例では、Oracle TuxedoはTolowerMDBEchoMDBINFO、およびACCOUNTサービスをインポートします。一方、Oracle Tuxedo JCA Adapterはこれらをエクスポートします。

 


Oracle Tuxedo JCA Adapterデプロイメント

WebSphere Integrated Solution Consoleで、https://localhost:9047/ibm/console/logon.jsp (ここで9047は、アプリケーション・サーバーのリスニングするポート番号)を入力します。

dmconfigファイルの構成

WebSphereアプリケーション・サーバーにOracle Tuxedo JCA Adapterをデプロイする前に、dmconfig構成ファイルを作成する必要があります。リスト7は、dmconfigファイルの例を示しています。

リスト7 dmconfigファイルの例
<?xml version="1.0" encoding="UTF-8"?><TuxedoConnector>
  <LocalAccessPoint name="JDOM">
    <AccessPointId>JDOM_ID</AccessPointId>
    <NetworkAddress>//localhost:10801</NetworkAddress>
  </LocalAccessPoint>
  <RemoteAccessPoint name="TDOM1">
    <AccessPointId>TDOM1_ID</AccessPointId>
    <NetworkAddress>//localhost:12478</NetworkAddress>
  </RemoteAccessPoint>
  <SessionProfile name="profile_1">
    <BlockTime>60000</BlockTime>
    <ConnectionPolicy>ON_STARTUP</ConnectionPolicy>
  </SessionProfile>
  <Session name="session_1">
    <LocalAccessPointName>JDOM</LocalAccessPointName>
    <RemoteAccessPointName>TDOM1</RemoteAccessPointName>
    <ProfileName>profile_1</ProfileName>
  </Session>
  <Export name="ECHOMDB">
    <RemoteName>ECHO</RemoteName>
    <SessionName>session_1</SessionName>
    <Type>MDB</Type>
   <Source>eis/echo</Source>
  </Export>
</TuxedoConnector>

リソース・アダプタ・デプロイメント記述子

リソース・アダプタ・デプロイメント記述子は、ゼロから作成することも既存のものを変更することもできます。リスト8は、デプロイメント記述子の例を示しています。

リスト8 デプロイメント記述子の例
<?xml version="1.0" encoding="UTF-8"?>
<connector xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
    version="1.5">
  <display-name>Tuxedo JCA Adapter</display-name>
  <vendor-name>Oracle</vendor-name>
  <eis-type>Tuxedo</eis-type>
  <resourceadapter-version>11gR1(11.1.1.2.1)</resourceadapter-version>
  <license>
    <description>Tuxedo SALT license</description>
    <license-required>false</license-required>
  </license>
  <resourceadapter>
    <resourceadapter-class>com.oracle.tuxedo.adapter.TuxedoResourceAdapter</resourceadapter-class>
    <!--
      The following is the list of properties name can be configured as adapter-wise configuration.
      traceLevel  - java.lang.String  - a numerical value
      xaAffinity  - java.lang.String  - transaction affinity to a remote domain, "true" or "false", default to true
      keyFileName - java.lang.String  - encryption key file name
      throwFailureReplyException - java.lang.Boolean - default to ture
      appManagedLocalTxTimeout   - java.lang.Integer - Application managed transaction or AUTOTRAN timeout
                                                       defaults to 300 seconds
      fieldTable16Class - java.lang.String - a comma-separated list of fully qualified FML classes
      fieldTable32class - java.lang.String - a comma-separated list of fully qualified FML32 classes
      viewFile16Class   - java.lang.String - a comma-separated list of fully qualified VIEW classes
      viewFile32Class   - java.lang.String - a comma-separated list of fully qualified VIEW32 classes
      tpusrFile         - java.lang.String - path name to the TPUSR file 
      remoteMBEncoding  - java.lang.String - remote Tuxedo encoding name for multi-byte language
      mBEncodingMapFile - java.lang.String - path name to Multi-byte encoding name mapping
      autoTran          - java.lang.Boolean- enable adapter-wise AUTOTRAN, default to false
    -->
    <config-property>
      <config-property-name>traceLevel</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>2000000</config-property-value>
    </config-property>
<!--
    <config-property>
      <config-property-name>xaAffinity</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>true</config-property-value>
    </config-property>
-->
    <config-property>
      <config-property-name>dmconfig</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>C:\test\JCA\inflow_tx/adapter/dmconfig.xml</config-property-value>
    </config-property>
    <config-property>
      <config-property-name>keyFileName</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>C:\test\JCA\inflow_tx/adapter/foo.key</config-property-value>
    </config-property>
    <config-property>
      <config-property-name>debugAdapter</config-property-name>
      <config-property-type>java.lang.Boolean</config-property-type>
      <config-property-value>true</config-property-value>
    </config-property>
    <config-property>
      <config-property-name>debugJatmi</config-property-name>
      <config-property-type>java.lang.Boolean</config-property-type>
      <config-property-value>true</config-property-value>
    </config-property>
    <config-property>
      <config-property-name>debugConfig</config-property-name>
      <config-property-type>java.lang.Boolean</config-property-type>
      <config-property-value>true</config-property-value>
    </config-property>
    <config-property>
      <config-property-name>debugSession</config-property-name>
      <config-property-type>java.lang.Boolean</config-property-type>
      <config-property-value>true</config-property-value>
    </config-property>
    <config-property>
      <config-property-name>debugXa</config-property-name>
      <config-property-type>java.lang.Boolean</config-property-type>
      <config-property-value>true</config-property-value>
    </config-property>
    <config-property>
      <config-property-name>debugPdu</config-property-name>
      <config-property-type>java.lang.Boolean</config-property-type>
      <config-property-value>true</config-property-value>
    </config-property>
    <config-property>
      <config-property-name>debugSec</config-property-name>
      <config-property-type>java.lang.Boolean</config-property-type>
      <config-property-value>true</config-property-value>
    </config-property>
<!--
-->
    <outbound-resourceadapter>
      <connection-definition>
        <managedconnectionfactory-class>com.oracle.tuxedo.adapter.spi.TuxedoManagedConnectionFactory</managedconnectionfactory-class>
        <!--
          The following is the list of properties that you can use to
          to configure connection pool or connection factory.
          User must either configure localAccessPointSpec or
          connectionFactoryName if transaction is used.
          These property described here is serving as template, user should not
          configure them here, instead user should configure them either through WebSphere console 
          or weblogic-ra.xml side file.
        -->
        <config-property>
          <description>factory-wise AUTOTRAN setting, default to false, overrides adapter-wise setting</description>
          <config-property-name>autoTran</config-property-name>
          <config-property-type>java.lang.Boolean</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise Failure Reply Exception setting, default to true, overrides adapter-wise setting</description>
          <config-property-name>throwFailureReplyException</config-property-name>
          <config-property-type>java.lang.Boolean</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise application managed transaction or AUTOTRAN time out, overrides adapter-wise setting</description>
          <config-property-name>appManagedLocalTxTimeout</config-property-name>
          <config-property-type>java.lang.Integer</config-property-type>
        </config-property>
        <config-property>
          <description>connection factory or pool name, this is required if XA or local application managed
                       transaction is required</description>
          <config-property-name>connectionFactoryName</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>application password in either clear text or cipher text using com.oracle.tuxedo.tools.EncryptPassword tool</description>
          <config-property-name>applicationPassword</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>local access point specification of the format //hostname:port/domainId=DOMAINID</description>
          <config-property-name>localAccessPointSpec</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise SSL to configure whether mutual authentication is required, default to false</description>
          <config-property-name>mutualAuthenticationRequired</config-property-name>
          <config-property-type>java.lang.Boolean</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise SSL for configuring identity key store file name, must be configured if SSL is desired</description>
          <config-property-name>identityKeyStoreFileName</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise SSL setting for private key alias used in the key store, must be configured if SSL is desired</description>
          <config-property-name>privateKeyAlias</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise trusted key store file name, must be configured if SSL is desired</description>
          <config-property-name>trustedKeyStoreFileName</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise password for identityKeyStore in clear text</description>
          <config-property-name>identityKeyStorePassPhrase</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise password for privateKeyAlias in clear text</description>
          <config-property-name>privateKeyAliasPassPhrase</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise password for trustedKeyStore in clear text</description>
          <config-property-name>trustedKeyStorePassPhrase</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise RemoteAccessPoint specification of the format //hostname:port/domainId=DOMAINID</description>
          <config-property-name>remoteAccessPointSpec</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise allow anonymous access to Tuxedo, default to false</description>
          <config-property-name>rapAllowAnonymous</config-property-name>
          <config-property-type>java.lang.Boolean</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise application key value for anonymous user, default to -1</description>
          <config-property-name>rapDefaultApplicationKey</config-property-name>
          <config-property-type>java.lang.Integer</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise application key fully qualified class name for AppKey generator</description>
          <config-property-name>rapApplicationKeyClass</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise custom application key parameter</description>
          <config-property-name>rapApplicationKeyClassParam</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise session profile block timeout value, default to 60000 milliseconds</description>
          <config-property-name>spBlockTime</config-property-name>
          <config-property-type>java.lang.Integer</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise whether allows interoperate with 6.5 Tuxedo Domain, default to false</description>
          <config-property-name>spInteroperate</config-property-name>
          <config-property-type>java.lang.Boolean</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise security setting, legal values: NONE, DM_PW, APP_PW</description>
          <config-property-name>spSecurity</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise credential propagation policy, either LOCAL or GLOBAL</description>
          <config-property-name>spCredentialPolicy</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise number of seconds that session waits between automatic connection establishment,
                       default to 60 seconds. A value of 0 disabled connection retry</description>
          <config-property-name>spRetryInterval</config-property-name>
          <config-property-type>java.lang.Long</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise maximum number of times adapter will try to establish a session connection to
                       remote Tuxedo access point. Default value is Long.MAX_VALUE.</description>
          <config-property-name>spMaxRetries</config-property-name>
          <config-property-type>java.lang.Long</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise compression threshold, default to Integer.MAX_VALUE</description>
          <config-property-name>spCompressionLimit</config-property-name>
          <config-property-type>java.lang.Integer</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise minimum encryption strength requirement, legal values are 0, 40, 56, 128, 256.
                       Default value is 0.</description>
          <config-property-name>spMinEncryptBits</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise maximum encryption strength requirement, legal values are 0, 40, 56, 128, 256.
                       Default value is 128.</description>
          <config-property-name>spMaxEncryptBits</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise the maximum idle time before sending application level keep alive.
                       It is measured in millisecond, and roundup to seconds. Default value is 0.</description>
          <config-property-name>spKeepAlive</config-property-name>
          <config-property-type>java.lang.Long</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise how long adapter will wait for acknowledgement before adapter decides the
                       connection already lost.  Measurement in millisecond, and its default value is 10 seconds.
                       A value of 0 will disable the wait, and thus will not close the connection</description>
          <config-property-name>spKeepAliveWait</config-property-name>
          <config-property-type>java.lang.Long</config-property-type>
        </config-property>
        <config-property>
          <description>factory-wise valid Tuxedo service names in a comma-separated list.  If not specified then
                       default import will be used and will grant all service request to remote Tuxedo domain</description>
          <config-property-name>impResourceName</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
          <description>Exported resources.  Types of resource supported are</description>
          <config-property-name>exportSpec</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
        <connectionfactory-impl-class>com.oracle.tuxedo.adapter.cci.TuxedoConnectionFactory</connectionfactory-impl-class>
        <connection-interface>javax.resource.cci.Connection</connection-interface>
        <connection-impl-class>com.oracle.tuxedo.adapter.cci.TuxedoJCAConnection</connection-impl-class>
      </connection-definition>
<!--
      <transaction-support>NoTransaction</transaction-support>
      <transaction-support>LocalTransaction</transaction-support>
-->
      <transaction-support>XATransaction</transaction-support>
      <authentication-mechanism>
        <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
        <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
      </authentication-mechanism>
      <reauthentication-support>false</reauthentication-support>
    </outbound-resourceadapter>
    <inbound-resourceadapter>
      <messageadapter>
        <messagelistener>
          <messagelistener-type>com.oracle.tuxedo.adapter.intf.TuxedoMDBService</messagelistener-type>
          <activationspec>
            <activationspec-class>com.oracle.tuxedo.adapter.spi.TuxedoActivationSpec</activationspec-class>
            <required-config-property>
              <config-property-name>source</config-property-name>
            </required-config-property>
          </activationspec>
        </messagelistener>
      </messageadapter>
    </inbound-resourceadapter>
  </resourceadapter>
</connector>

Oracle Tuxedo JCA Adapterのデプロイ

デプロイメント記述子を使用してリソース・アダプタをjarファイル化してリソース・アーカイブを作成した後、これをWebSphereアプリケーション・サーバーにデプロイできます。

WebSphere Integrated Solution Consoleにログインした後、左ウィンドウ・ペインから「リソース」を選択します。図2に示すように、「リソース・アダプタ」を選択します。「リソース・アダプタ」ウィンドウが表示されます。「参照」をクリックし、RARファイルを検索します。

図2 WebSphere Integrated Solution Console

WebSphere Integrated Solution Console

「次へ」をクリックすると、図3に示すように、「一般プロパティ」ページが表示されます。「説明」テキスト入力ボックスに適切な説明を入力します。

図3 「一般プロパティ」ページ

一般プロパティ

「OK」「保存」の順にクリックします。

アクティブ化仕様の構成

「リソース・アダプタ」 > Tuxedo JCA Adapterから、「Additional Properties」J2Cアクティブ化仕様を選択すると、図4で示すように「J2Cアクティブ化仕様」ページが表示されます。「新規」を選択し、アクティブ化仕様名とそのJNDI名を入力します(この例では、仕様名をEchoMDB、JNDI名をeis/echoとします)。このJNDI名は、EchoMDBというJNDI名を使用します。

図4 「J2Cアクティブ化仕様」ページ

「J2Cアクティブ化仕様」ページ

「OK」をクリックし、指定を完了します。

WebSphere Integrated Consoleを使用したMDBの構成

WebSphereアプリケーション・サーバーを起動し、Integrated Solution Consoleを使用してWebSphereにログインします。通常、コンソール・ポート番号は904X (「X」は任意の数字)です。

注意: logs/server1/SystemOut.logを検索できます。 TCPチャンネルTCP_3はリスニングしているという旨の「TCP Channel TCP_3 is listening.」を確認します。

WebSphereへのMDBのデプロイ

共有ライブラリの構成

コンソールの左ペインで「環境」を選択すると、サブメニュー付きメニュー・アイテムが展開されます。共有ライブラリを選択すると、共有ライブラリ画面が表示されます。

「新規」をクリックすると、構成画面が表示されます。「名前」に任意の名前を入力します。この例では、「名前」テキスト入力ボックスにEchoMDBEnvと入力します。「クラスパス」ウィンドウで、次の2つのJARファイルのフルパス名を入力します。

区切りには[Enter]キーを押し、「保存」をクリックします。

MDBのインストール

コンソールの左ペインで、「アプリケーション」新しいアプリケーションのインストールの順に選択します。「エンタープライズ・アプリケーション」メニューが表示されます。

新しいアプリケーションへのパスローカル・ファイル・システムを選択します。「参照」をクリックし、「EchoMDB.jar」ファイルを選択します。

アプリケーションのインストール方法で、すべてのインストール・オプションとパラメータの表示を選択します。「次へ」をクリックすると、図5で示すように「インストール・オプションの選択」ページが表示されます。エンタープライズBeanのデプロイを選択し、「次へ」をクリックします。

図5 「インストール・オプションの選択」ページ

「インストール・オプションの選択」ページ

「手順2: サーバーにモジュールをマッピングする」で、Echo MDBを使用するサーバーを選択します。EchoMDBにチェック・マークを入れ、「適用」をクリックします。「次へ」をクリックします。

図6 EchoMDBモジュールの選択

EchoMDBモジュールの選択

「手順3: メッセージドリブンBeanのリスナーをバインドする」で、図7で示すようにアクティブ化仕様を選択し、このMDBのJNDI名を入力します(この場合、eis/echoを入力します)。

図7 アクティブ化仕様

アクティブ化仕様

「次へ」をクリックすると、図8に示すように、「サマリー」ページが表示されます。「終了」をクリックします。アプリケーション・サーバーがMDBをコンパイルしてデプロイします。

図8 「サマリー」ページ

「サマリー」ページ

「保存」をクリックします。

MDBのアクティブ化

コンソールの左ペインで、「アプリケーション」を選択してから「エンタープライズ・アプリケーション」を選択します。EchoMDB.jarを選択し、「起動」をクリックします。Echo” EJBがアクティブ化されます。

Oracle Tuxedoアプリケーション・ドメイン

Oracle Tuxedo構成

リスト1は、この例で使用されるOracle Tuxedo UBBCONFIGファイルを示しています。

リスト1 Oracle Tuxedo UBBCONFIGファイルの例
#
#Ubbconfig domain1
#
*RESOURCES
IPCKEY			51301
MASTER			site1
MAXACCESSERS	100
MAXSERVERS		25
MAXSERVICES		50
MODEL				SHM
LDBAL				N
BLOCKTIME 	1
SCANUNIT		5
SECURITY        NONE
*MACHINES
DEFAULT:
		APPDIR="C:\test\JCA\inflow_tx/tdom1"
		TUXCONFIG="C:\test\JCA\inflow_tx/tdom1/TUXCONFIG"
		TUXDIR="c:\tuxedo\tux11g"
"NEOCORTEX"	LMID=site1
		MAXWSCLIENTS=2
*GROUPS
GROUP3 LMID=site1 GRPNO=3	OPENINFO=NONE
GROUP2 LMID=site1 GRPNO=2	OPENINFO=NONE
GROUP1 LMID=site1 GRPNO=1  TMSNAME=TMS TMSCOUNT=3
#GROUP1 LMID=site1 GRPNO=1
*SERVERS
DEFAULT:
		CLOPT="-A" RESTART=Y MAXGEN=5
DMADM  		SRVGRP=GROUP2	SRVID=1
GWADM  		SRVGRP=GROUP3	SRVID=2
GWTDOMAIN	SRVGRP=GROUP3	SRVID=3
		ENVFILE="C:\test\JCA\inflow_tx/tdom1/gwt.env"
simpserv		SRVGRP=GROUP1	SRVID=20
*SERVICES
TOUPPER_STR
Tuxedo /Domain Configuration
The following is the /Domain configuration for this sample.
#
*DM_RESOURCES
#
VERSION=U22
#
#
*DM_LOCAL_DOMAINS
#
# NOTE: Remove DYNAMIC_RAP line if you are not running with Tuxedo 11.1.1.2.0
#
"TDOM1"    GWGRP=GROUP3
	TYPE=TDOMAIN
	DOMAINID="TDOM1_ID"
	BLOCKTIME=60
	SECURITY=NONE
   DMTLOGDEV="C:\test\JCA\inflow_tx/tdom1/DMTLOG"
   DYNAMIC_RAP="YES"
#
*DM_REMOTE_DOMAINS
#
#
JDOM 	TYPE=TDOMAIN
	DOMAINID="JDOM_ID"
#
#
*DM_TDOMAIN
#
TDOM1	NWADDR="//localhost:12478"
JDOM 	NWADDR="//localhost:10801"
#
#
*DM_LOCAL_SERVICES
#
#Exported
#
TOUPPER_STR
#
*DM_REMOTE_SERVICES
#
#Imported
#
ECHO

 


Oracle Tuxedo JCA Adapter用MDBのプログラミング

インタフェースのTuxedoMDBService

Tuxedo JCA Adapterでは、EJBアプリケーション・コードで実装する必要があるEJB MDBインタフェースが提供されます。

注意: MDBインタフェースは、Oracle Tuxedo JCA Adapterによってサポートされる既存のEJBに類似していますが、同一ではありません。

リスト2は、インタフェースのリストを示しています。

リスト2 インタフェースのリスト
package com.oracle.tuxedo.adapter.intf;
import weblogic.wtc.jatmi.Reply;
import com.oracle.tuxedo.adapter.tdom.TPServiceInformation;
import com.oracle.tuxedo.adapter.TuxedoReplyException;
public interface TuxedoMDBService {
public Reply service(TPServiceInformation service) throws TuxedoReplyException;
}

これはJMSベースのMDBとは異なり、onMessage()インタフェースのかわりにservice()インタフェースが使用されます。リスト3は、Oracle Tuxedoクライアント用の「Tolower」サービスを実装するMDBコードの例を示しています。

リスト3 MDBコードの例
package ejbs;
import com.oracle.tuxedo.adapter.TuxedoReplyException;
import com.oracle.tuxedo.adapter.intf.TuxedoMDBService;
import com.oracle.tuxedo.adapter.tdom.TPServiceInformation;
import javax.ejb.MessageDrivenBean;
import javax.ejb.MessageDrivenContext;
import javax.jms.Message;
import weblogic.wtc.jatmi.Reply;
import weblogic.wtc.jatmi.TypedString;
public class TolowerMDBBeanBean
    implements MessageDrivenBean, TuxedoMDBService
{
    public TolowerMDBBeanBean()
    {
    }
    public MessageDrivenContext getMessageDrivenContext()
    {
        return fMessageDrivenCtx;
    }
    public void setMessageDrivenContext(MessageDrivenContext ctx)
    {
        fMessageDrivenCtx = ctx;
    }
    public void ejbCreate()
    {
    }
    public void onMessage(Message message)
    {
    }
    public void ejbRemove()
    {
    }
    public Reply service(TPServiceInformation mydata)
        throws TuxedoReplyException
    {
        TypedString data = (TypedString)mydata.getServiceData();
        String lowered = data.toString().toLowerCase();
        TypedString return_data = new TypedString(lowered);
        mydata.setReplyBuffer(return_data);
        return mydata;
    }
  private static final long serialVersionUID = 1L;
  private MessageDrivenContext fMessageDrivenCtx;
}

IBM ASTKを使用したインバウンド・コネクタ・ベースMDBの作成

この手順では、WebSphere ASTK 6.1を使用してコネクタ・ベースEJB 2.1 MDBを作成します。シンプルなEJB MDBは、入力文字列をOracle Tuxedoクライアントにエコー・バックします。プロジェクト名はEchoMDBです。

J2EEパースペクティブの使用

「J2EE」パースペクティブがまだない場合、次を実行して「J2EE」パースペクティブを変更します。

「ウィンドウ」メニューからパースペクティブを開くJ2EEの順に選択します。

EJBプロジェクトの作成

「ファイル」メニューから、「新規」「プロジェクト」の順に選択します。「EJB」をクリックして展開し、EJBプロジェクトをハイライトします。 「次へ」をクリックします。

「EJBプロジェクト」メニューで、「プロジェクト名」EchoMDBと入力します。「次へ」をクリックします。「プロジェクト・ファセットの選択」メニューが表示されます。

「プロジェクト・ファセットの選択」メニューで、「EJBモジュール」のバージョンが「2.1」「Java」」のバージョンが「5.0」、「WebSphere EJB」の拡張バージョンが「6.1」であるかを確認し、これら3つの項目が選択されているかを確認します。「次へ」をクリックします。

「EJBモジュール」メニューで、EJBクライアントのJARモジュールを作成してクライアント・インタフェースとクラスを保持するの選択を解除します。これは、インバウンドEJBがOracle Tuxedo JCA Adapterによって呼び出されるため不要になるからです。「終了」をクリックします。

ビルド環境の設定

「プロジェクト・エクスプローラ」「EchoMDB」プロジェクトを右クリックします。コンテキスト・メニューから「プロパティ」を選択すると、図9に示すように「EchoMDBのプロパティ」ウィンドウが開きます。

Javaビルド・パスから外部JARの選択を選択します。Oracle Tuxedo JCA AdapterのRARファイルから次の2つのJarファイルを追加します。(RARファイルを解凍していない場合は解凍します。)

com.bea.core.jatmi_1.3.2.0.jar
com.oracle.tuxedo.adapter_1.2.1.0.jar

「OK」をクリックします。

図9 「EchoMDBプロパティ」ウィンドウ

「EchoMDBプロパティ」ウィンドウ

メッセージ・ドリブンBeanの作成

「プロジェクト・エクスプローラ」の左ウィンドウ・ペインで、新規作成したMDBプロジェクトのEchoMDBを展開します。EchoMDB右クリックし、「新規」を選択して、「その他」を選択します。エンタープライズBeanを選択し、「次へ」をクリックします。図10に示すように「エンタープライズBeanの作成」ポップアップ・ウィンドウが表示されます。

ポップアップ・ウィンドウで、「メッセージドリブンBean」を選択します。EchoMDBという値でBean名を入力します。

図10 「エンタープライズBeanの作成」ウィンドウ

「エンタープライズBeanの作成」ウィンドウ

「次へ」をクリックします。図11に示すように、「メッセージドリブンBeanの種類」ポップアップ・ウィンドウが表示されます。その他の種類を選択し、「参照」をクリックします。TuxedoMDBServiceを入力し、図11のリストから選択して「OK」をクリックします。

図11 「メッセージドリブンBeanの種類」ウィンドウ

「メッセージドリブンBeanの種類」ウィンドウ

「メッセージドリブンBeanの種類」ポップアップ・ウィンドウが表示されます。「終了」をクリックします。

EchoBeanの変更

EchoMDBBean.javaが表示されるまで、左ウィンドウ・ペインのejbModuleを展開します。ECHOサービスを実行するには、EchoMDBBean.javaを変更する必要があります。EchoMDBBean.javaをダブルクリックすると、図12に示すようにデフォルトのエディタと共に「編集」ウィンドウ・ペインが表示されます。

図12 「編集」ウィンドウ

「編集」ウィンドウ

クラス・ファイルの最上段に、リスト1で示すように次の行を追加します。

リスト1 新しい行の追加
import weblogic.wtc.jatmi.Reply;
import weblogic.wtc.jatmi.TPException;
import weblogic.wtc.jatmi.TPReplyException;
import weblogic.wtc.jatmi.TypedString;
import com.oracle.tuxedo.adapter.TuxedoReplyException;
import com.oracle.tuxedo.adapter.intf.TuxedoMDBService;
import com.oracle.tuxedo.adapter.tdom.TPServiceInformation;

リスト2に示すように、クラス・ファイルの最後に記述されたservice()メソッドを編集します。

リスト2 service()
public weblogic.wtc.jatmi.Reply service(
       com.oracle.tuxedo.adapter.tdom.TPServiceInformation mydata)
        throws com.oracle.tuxedo.adapter.TuxedoReplyException {
  TypedString data;
  data = (TypedString)mydata.getServiceData();
  mydata.setReplyBuffer(data);
  return mydata;
} 

ビルド

「プロジェクト・エクスプローラ」でEchoMDBを右クリックし、図13に示すように「デプロイ」を選択します。これによって、ビルド・ディレクトリのクラスにコンパイルされます。

図13 コンパイル

コンパイル

EJB JARファイルの作成

「プロジェクト・エクスプローラ」で「EchoMDB」プロジェクトを右クリックし、「エクスポート」を選択します。図14に示すように「エクスポート」ポップアップ・ウィンドウが表示されます。

図14 「エクスポート」ポップアップ・ウィンドウ

「エクスポート」ポップアップ・ウィンドウ

「エクスポート」ポップアップ・ウィンドウで、EJB JARファイルを選択します。「次へ」をクリックします。図15に示すように「EJB Jarのエクスポート」ポップアップ・ウィンドウが表示されます。ドロップダウン・メニューからEchoMDBを選択し、jarファイルの完全パスを「宛先」テキスト・フィールドに入力します。「終了」をクリックします。

図15 「EJB Jarのエクスポート」ポップアップ・ウィンドウ

「EJB Jarのエクスポート」ポップアップ・ウィンドウ

図16に示すように、「リソースの保存」ポップアップ・ウィンドウが表示されるので、「OK」をクリックします。

図16 「リソースの保存」ポップアップ・ウィンドウ

「リソースの保存」ポップアップ・ウィンドウ

Oracle Tuxedo JCA Adapterのディスパッチ・ベースMDBの場合、2種類のうちいずれかの方法でactivation-config-propertyejb-jar.xmlファイルに追加する必要があります。

  1. 第1の方法はjarファイルを解凍する方法です。jarファイルを解凍した後、META-INF/ejb-jar.xmlを変更してBeanのjarファイルを再JAR化します。リスト1は、この種類のMDBに適したejb-jar.xmlサンプル・ファイルを示しています。
  2. リスト1 ejb-jar.xmlファイルの例
    <?xml version="1.0" encoding="UTF-8"?>
    <ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee  http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
       <display-name>EchoMDB</display-name>
       <enterprise-beans>
          <!-- message driven descriptor -->
          <message-driven id="EchoMDB">
             <ejb-name>EchoMDB</ejb-name>
             <ejb-class>ejbs.EchoMDBBean</ejb-class>
             <!-- message listener interface -->
             <messaging-type>com.oracle.tuxedo.adapter.intf.TuxedoMDBService</messag
    ing-type>
             <transaction-type>Container</transaction-type>
             <!-- the values for the Activation Spec JavaBean -->
             <activation-config>
                <activation-config-property>
                  <activation-config-property-name>source</activation-config-property-name>
                  <activation-config-property-value>eis/echo</activation-config-property-value>
                </activation-config-property>
             </activation-config>
          </message-driven>
       </enterprise-beans>
    </ejb-jar>

ここで、eis/echoEchoMDBのJNDI名です。

  1. 同様に、第2の方法は、MDBをデプロイおよびエクスポートする前にASTKを使用して、ejb-jar.xmlファイルをactivation-config-propertyに直接追加する方法です。

Oracle Tuxedoトランザクション用クライアント・ソース・コード

リスト2は、WebSphereアプリケーション・サーバーからインポートされたECHOサービスにアクセスするシンプルなOracle Tuxedoネイティブ・クライアントを示しています。

リスト2 WebSphereアプリケーション・サーバーからインポートされたECHOサービス
#include <stdio.h>
#include “atmi.h”
main(int argc, char *argv[])
{
  char *sendbuf, *rcvbuf;
  long sendlen, rcvlen;
  int  ret;
  
  if (tpinit((TPINIT *)NULL) == -1) {
    (void)fprintf(stderr, “Tpinit failed\n”);
    exit(1);
  }
  sendlen = strlen(argv[1]);
  if ((sendbuf = (char *)tpalloc(“STRING”, NULL, sendlen + 1)) == NULL) {
      (void)fprintf(stderr, “Error allocating send buffer\n”);
      tpterm();
     exit(2);
  }
  if ((rcvbuf = (char *)tpalloc(“STRING”, NULL, sendlen + 1)) == NULL) {
      (void)fprintf(stderr, “Error allocating receive buffer\n”);
    tpfree(sendbuf);
      tpterm();
     exit(2);
  }
  (void)strcpy(sendbuf, argv[2]);
  tpbegin(45, 0);
  ret = tpcall(“ECHO”, (char *)sendbuf, 0, (char **)&rcvbuf, &rcvlen, (long)0);
  if (ret == -1) {
    tpabort(0);
    tpfree(sendbuf);
    tpfree(recvbuf);
    tpterm();
    exit(1);
  }
  userlog(“Return string: %s”, rcvbuf);
  tpcommit(0);
  tpfree(sendbuf);
  tpfree(rcvbuf);
  tpterm();
  return(0);
}

  先頭に戻る       前  次