自訂 JCA 配置元素

您可以自訂在安裝資源配接器時,產生 JCA 內容子元素的方法。

關於這項作業

當您安裝獨立式資源配接器或內嵌在應用程式中的資源配接器時,可以在 <resourceAdapter> 元素底下新增一或多個 <customize> 子元素,為所指定的介面或實作類別,選擇要用於內容子元素的字尾。自訂子元素可讓您避免因為配置元素需要有唯一名稱,而有很長的內容子元素名稱。
註:

如果要新增 Liberty 的 JCA 支援,您必須利用 WebSphere® Application Server Developer Tools for Eclipse 的「伺服器配置」編輯器「程式碼」視圖,或利用其他文字編輯器,來編輯 server.xml 檔。 測試版不支援在「設計」視圖中編輯 Connection Factory、管理物件、啟動規格和資源配接器的部分配置。

程序

  1. 針對獨立式資源配接器,從您想要自訂的現有配置開始。 例如,如果資源配接器 MyAdapter 提供兩個 Connection Factory,其中簡式介面和實作類別名稱都不是唯一的:
    <featureManager>
     <feature>jca-1.6</feature>
     <feature>jndi-1.0</feature>  <!-- 新增 jndi 特性來啟用查閱 Connection Factory 和受管理物件。-->
     ...
    </featureManager>
    <resourceAdapter location="C:/adapters/MyAdapter.rar"/>
    
    <connectionFactory jndiName="eis/cci-cf">
     <properties.MyAdapter.javax.resource.cci.ConnectionFactory serverName="localhost"/>
    </connectionFactory>
    
    <connectionFactory jndiName="eis/custom-cf">
     <properties.MyAdapter.com.vendor.adapter.custom.ConnectionFactory hostName="localhost"/>
    </connectionFactory>
  2. 新增 customize 子元素至 resourceAdapter,為這兩個 Connection Factory 介面選擇字尾。
    <featureManager>
     <feature>jca-1.6</feature> 
     <feature>jndi-1.0</feature>  <!-- 新增 jndi 特性來啟用查閱 Connection Factory 和受管理物件。--> 
    	...    
    </featureManager> 
    
    <resourceAdapter location="C:/adapters/MyAdapter.rar">
     <customize interface="javax.resource.cci.ConnectionFactory" suffix="cci"/>
     <customize interface="com.vendor.adapter.custom.ConnectionFactory" suffix="custom"/>
    </resourceAdapter>
    
    <connectionFactory jndiName="eis/cci-cf">
     <properties.MyAdapter.cci serverName="localhost"/>
    </connectionFactory> 
    
    <connectionFactory jndiName="eis/custom-cf">
     <properties.MyAdapter.custom hostName="localhost"/>
    </connectionFactory>
  3. 針對內嵌在應用程式中的資源配接器,從您想要自訂的現有配置開始。 例如,假設您的應用程式 app1 有一個名為 MyAdapter 的內嵌式資源配接器,如下所示:
    <featureManager>
     <feature>jca-1.6</feature>
     <feature>jndi-1.0</feature>  <!-- 新增 jndi 特性來啟用查閱 Connection Factory 和受管理物件。-->
    	...
    </featureManager>
    
    <application name="app1" type="ear" location="C:/applications/app1.ear"/>
    
    <adminObject jndiName="eis/interactionSpec-find">
     <properties.app1.MyAdapter.javax.resource.cci.InteractionSpec-com.vendor.adapter.finder.InteractionSpecImpl resultSetType="1003"/>
    </adminObject>
    
    <adminObject jndiName="eis/interactionSpec-update">
     <properties.app1.MyAdapter.com.vendor.adapter.InteractionSpec-com.vendor.adapter.updater.InteractionSpecImpl executionTimeout="3000"/> 
    </adminObject>
  4. 為應用程式中的「資源配接器保存檔 (RAR)」模組指定 resourceAdapter 元素。將 id 屬性指定為 RAR 模組的模組名稱。新增 customize 子元素,為這兩個以介面或實作類別為基礎的受管理物件選擇字尾。 在此範例中,只有指定實作類別,這樣就足以識別受管理物件:
    <featureManager>
     <feature>jca-1.6</feature>
     <feature>jndi-1.0</feature>  <!-- 新增 jndi 特性來啟用查閱 Connection Factory 和受管理物件。-->
    	...
    </featureManager>
    
    <application name="app1" type="ear" location="C:/applications/app1.ear">
     <resourceAdapter id="MyAdapter">
      <customize implementation="com.vendor.adapter.finder.InteractionSpecImpl" suffix="finder"/>
      <customize implementation="com.vendor.adapter.updater.InteractionSpecImpl" suffix="updater"/>
     </resourceAdapter>
    </application>
    
    <adminObject jndiName="eis/interactionSpec-find">
     <properties.app1.MyAdapter.finder resultSetType="1003"/>
    </adminObject>
    
    <adminObject jndiName="eis/interactionSpec-update">
     <properties.app1.MyAdapter.updater executionTimeout="3000"/>
    </adminObject>

指示主題類型的圖示 作業主題

檔名:twlp_jca_config_custelements.html