エンタープライズリソースアダプタの設定

このセクションでは、標準リソースアダプタデプロイメントディスクリプタである ra.xml と、JRun 固有のデプロイメントディスクリプタである jrun-ra.xml について説明します。ra.xml ファイルに display-name 要素が含まれており、管理された接続ファクトリインスタンスが 1 つだけ必要な場合、jrun-ra.xml ファイルは不要です。詳細については、<JRun のルートディレクトリ>/docs/descriptordocs/index.html ファイルにリストされているデプロイメントディスクリプタのドキュメントを参照してください。

リソースアダプタのプログラミング方法の詳細については、『JRun プログラマーガイド』および「JRun ドキュメントの概要」に記載されている参考文献を参照してください。

ra.xml デプロイメントディスクリプタについて

リソースアダプタ開発者は、リソースアダプタの実装コード、設定プロパティ、およびセキュリティ情報に関する情報が含まれている ra.xml ファイルを作成します。デプロイ担当者は ra.xml ファイルの resourceadapter/config-properties セクションを修正して、リソースアダプタの設定可能なプロパティを設定します。また、デプロイ担当者は、ra.xml ファイルで定義されているトランザクション管理レベルに基づいてトランザクション管理を行うように JRun を設定し、ファイルの resourceadapter/authentication-mechanism セクションの情報に基づいてセキュリティを設定します。

ra.xml ファイルには、connector 要素の下に次の最上位レベルの要素が含まれています。

XML 要素
必須/
オプション

説明
display-name、description、icon
オプション
ツールで使用する名前、説明、およびイメージ
vendor-name
必須
名前またはリソースアダプタプロバイダ
spec-version
必須
リソースアダプタによってサポートされるコネクタのアーキテクチャ仕様のバージョン。デプロイ担当者は、仕様のデプロイおよび実行時の必要条件をサポートするようにリソースを設定できます。
eis-type
必須
アダプタを作成するエンタープライズ情報システム (EIS) のタイプ
version
必須
リソースアダプタプロバイダが指定したリソースアダプタのバージョン
license
オプション
リソースアダプタをデプロイして使用するためにライセンスが必要かどうかを指定します。また、ライセンス条件をオプションで記述します。
resourceadapter
必須
リソースアダプタに関する次のような情報
  • コネクタのアーキテクチャ規定の一部として必要なクラスおよびインターフェイスの完全修飾名
  • トランザクションサポートレベル
  • ManagedConnectionFactory インスタンスの設定可能なレベル
  • 1 つ以上のサポートされている認証メカニズム
  • 追加の必要なセキュリティ上のアクセス許可

例:ra.xml デプロイメントディスクリプタ

J2EE Reference Implementation とともに提供されている次の ra.xml ファイルでは、JDBC データベースのリソースアダプタを設定します。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE connector PUBLIC '-//Sun Microsystems, Inc.//DTD Connector 1.0//EN'
'http://java.sun.com/dtd/connector_1_0.dtd'>
<connector>
  <display-name>BlackBoxNoTx</display-name>
  <vendor-name>Java Software</vendor-name>
  <spec-version>1.0</spec-version>
  <eis-type>JDBC Database</eis-type>
  <version>1.0</version>
  <resourceadapter>
    <managedconnectionfactory-class>
    com.sun.connector.blackbox.NoTxManagedConnectionFactory
    </managedconnectionfactory-class>
    <connectionfactory-interface>javax.sql.DataSource
    </connectionfactory-interface>
    <connectionfactory-impl-class>
    com.sun.connector.blackbox.JdbcDataSource
    </connectionfactory-impl-class>
    <connection-interface>
    java.sql.Connection
    </connection-interface>
    <connection-impl-class>
    com.sun.connector.blackbox.JdbcConnection
    </connection-impl-class>
    <transaction-support>NoTransaction</transaction-support>
    <config-property>
    <config-property-name>ConnectionURL</config-property-name>
    <config-property-type>java.lang.String</config-property-type>
      <config-property-value>
      jdbc:cloudscape:rmi:CloudscapeDB;create=true
      </config-property-value>
    </config-property>
    <authentication-mechanism>
      <authentication-mechanism-type>
      BasicPassword
      </authentication-mechanism-type>
      <credential-interface>
      javax.resource.security.PasswordCredential
      </credential-interface>
    </authentication-mechanism>
    <reauthentication-support>false</reauthentication-support>
  </resourceadapter>
</connector>

jrun-ra.xml デプロイメントディスクリプタについて

リソースアダプタの ra.xml ファイルに display-name 値がある場合、JRun では jrun-ra.xml ファイルを使用せずにこのリソースアダプタをデプロイできます。表示名はこのアダプタを参照する EJB などのアプリケーションコンポーネントの JNDI 名になります。jrun-ra.xml ファイルは、設定プロパティの変更、接続プール値の設定、セキュリティ情報の挿入、または複数の ManagedConnectionFactory インスタンスの使用に必要です。

メモ:  jrun-ra.xml ファイルは自動的に生成できます。詳細については、 弟3章の"JRun 固有のデプロイメントディスクリプタの操作,"を参照してください。

例:jrun-ra.xml デプロイメントディスクリプタ

次の jrun-ra.xml ファイルでは、認証が必要なリソースアダプタインスタンスと、認証が不要なリソースアダプタインスタンスを設定します。

<?xml version="1.0" encoding="UTF-8"?>
<jrun-connectionfactory>
  <managedconnectionfactory-class>
  com.sun.connector.blackbox.NoTxManagedConnectionFactory
  </managedconnectionfactory-class>
    <managedconnectionfactory-instance>
        <jndi-name>J2EEConnector/secure-blackbox-notx</jndi-name>
        <config-property>
          <config-property-name>ConnectionURL</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
          <config-property-value>
          jdbc:cloudscape:CloudscapeDB;create=true
          </config-property-value>
        </config-property>
        <security-info>
          <username>victor</username>
          <password>victor</password>
        </security-info>
        <connection-pool>
            <name>mypool</name>
            <objectType>java.lang.StringBuffer</objectType>
            <minimumSize>1</minimumSize>
            <maximumSize>10</maximumSize>
            <connectionTimeout>6</connectionTimeout>
            <userTimeout>12</userTimeout>
            <skimmerFrequency>300</skimmerFrequency>
            <shrinkBy>2</shrinkBy>
            <debugging>true</debugging>
        </connection-pool>
    </managedconnectionfactory-instance>
    <managedconnectionfactory-instance>
        <jndi-name>J2EEConnector/blackbox-notx</jndi-name>
        <config-property>
            <config-property-name>ConnectionURL</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
          <config-property-value>
          jdbc:cloudscape:CloudscapeDB;create=true
          </config-property-value>
        </config-property>
        <connection-pool>
            <name>mypool</name>
            <objectType>java.lang.StringBuffer</objectType>
            <minimumSize>1</minimumSize>
            <maximumSize>10</maximumSize>
            <connectionTimeout>6</connectionTimeout>
            <userTimeout>12</userTimeout>
            <skimmerFrequency>300</skimmerFrequency>
            <shrinkBy>2</shrinkBy>
            <debugging>true</debugging>
        </connection-pool>
    </managedconnectionfactory-instance>
</jrun-connectionfactory>