配置 JCA 连接工厂

您可以配置符合 Java™ EE 连接器体系结构 (JCA) 规范的连接工厂。

关于此任务

您可以配置安装的资源适配器提供的连接工厂类型的一个或多个连接工厂实例。
注: 要配置 Liberty 概要文件的 JCA 支持,必须使用 WebSphere® Application Server Developer Tools for Eclipse 的服务器配置编辑器的“源代码”视图或某个其他文本编辑器来编辑 server.xml 文件。本主题假定在服务器中已配置具有唯一标识 MyAdapter 的资源适配器,请参阅有关配置资源适配器的文档以获取更多详细信息。以下步骤中提供了配置基本场景的端到端示例。
注: 不支持在 WebSphere® Development Tools (WDT) 的“设计”视图中编辑连接工厂、管理对象、激活规范和资源适配器的服务器配置的属性子元素。

过程

  1. 更新 server.xml 文件以在 featureManager 标记下添加 jca-1.6 功能部件。
    <featureManager>
    	<feature>jca-1.6</feature> 
    	<feature>jndi-1.0</feature>  <!-- Add the jndi feature to enable look up of connection factories and administered objects. -->   
    		... 
    </featureManager>
  2. 安装资源适配器。 例如,按如下所示更新 server.xml 文件:
    <resourceAdapter location="C:/adapters/MyAdapter.rar"/>
  3. 配置一个或多个连接工厂实例。 当您配置连接工厂实例时,必须提供 properties 子元素(即使您不想覆盖任何配置属性也是如此),以便将 connectionFactory 元素与特定资源适配器所提供的连接工厂接口相关联。在以下示例中,MyAdapter 资源适配器仅提供一种类型的连接工厂:
    <connectionFactory jndiName="eis/cf1">
     <properties.MyAdapter portNumber="1234" someVendorProperty="100"/>
    </connectionFactory>
    
    <connectionFactory jndiName="eis/cf2" containerAuthDataRef="auth2">
     <connectionManager maxPoolSize="20" connectionTimeout="0"/>
     <properties.MyAdapter portNumber="1234" someVendorProperty="200"/>
    </connectionFactory>
    <authData id="auth2" user="user2" password="{xor}Lz4sLCgwLTtt"/>
  4. (可选)如果需要,请标识可用的连接工厂属性子元素名称。
    • 如果资源适配器刚好提供了一个连接工厂接口(排除任何 JMS 连接工厂),那么子元素为:properties.<rar_identifier>

    • 如果接口名称是唯一的,且不具有软件包名称,那么子元素名称为:properties.<rar_identifier>.<InterfaceName>
    • 如果实现名称唯一,并且没有软件包名称,那么子元素名称为:properties.<rar_identifier>.<ImplementationName>
    • 在其他情况下,子元素名称为:properties.<rar_identifier>.<fully.qualified.InterfaceName>

示例

使用以下示例来了解如何配置具有两个连接工厂且接口类名唯一的资源适配器。

ra.xml 文件的以下片段中,MyAdapter 资源适配器提供了具有唯一接口类名的两个连接工厂:

<connection-definition>
  <config-property>
  <config-property-name>ServerName</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.vendor.adapter.ConnectionFactoryImpl</connectionfactory-impl-class>
</connection-defintion>
<connection-definition>
 <config-property>
  <config-property-name>ServerName</config-property-name>
  <config-property-type>java.lang.String</config-property-type>
 </config-property> 
 <connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
 <connectionfactory-impl-class>com.vendor.adapter.DataSourceImpl</connectionfactory-impl-class>
</connection-defintion> 
以下是此方案的服务器配置的示例:
<connectionFactory jndiName="eis/cf">
 <properties.MyAdapter.ConnectionFactory serverName="localhost"/>
</connectionFactory>

<connectionFactory jndiName="jdbc/ds">
 <properties.MyAdapter.DataSource serverName="localhost"/>
</connectionFactory>

使用以下示例来了解如何配置具有两个连接工厂且实现类名唯一的资源适配器。

ra.xml 文件的以下片段中,MyAdapter 资源适配器提供了具有唯一实现类名的两个连接工厂:

<connection-definition>
  <config-property>
  <config-property-name>ServerName</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.vendor.adapter.ConnectionFactoryImpl</connectionfactory-impl-class>
</connection-defintion>

<connection-definition>
  <config-property>
  <config-property-name>ServerName</config-property-name>
  <config-property-type>java.lang.String</config-property-type>
 </config-property>
 <connectionfactory-interface>com.vendor.adapter.ConnectionFactory</connectionfactory-interface>
 <connectionfactory-impl-class>com.vendor.adapter.MyConnectionFactoryImpl</connectionfactory-impl-class>
</connection-defintion>
以下是此方案的服务器配置的示例:
<connectionFactory jndiName="eis/cf1">
 <properties.MyAdapter.ConnectionFactoryImpl serverName="localhost"/>
</connectionFactory> 

<connectionFactory jndiName="eis/cf2">
 <properties.MyAdapter.MyConnectionFactoryImpl serverName="localhost"/>
</connectionFactory>

使用以下示例来了解如何配置具有两个连接工厂,而简单接口类名和实现类名都不唯一的资源适配器。

ra.xml 文件的以下片段中,MyAdapter 资源适配器提供了两个连接工厂,而简单接口类名和实现类名都不唯一:

<connection-definition>
 <config-property>
  <config-property-name>ServerName</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.vendor.adapter.ConnectionFactoryImpl</connectionfactory-impl-class>
</connection-defintion>

<connection-definition>
  <config-property>
  <config-property-name>HostName</config-property-name>
  <config-property-type>java.lang.String</config-property-type>
 </config-property> 
 <connectionfactory-interface>com.vendor.adapter.custom.ConnectionFactory</connectionfactory-interface>
 <connectionfactory-impl-class>com.vendor.adapter.custom.ConnectionFactoryImpl</connectionfactory-impl-class>
</connection-defintion>
以下是此方案的服务器配置的示例:
<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>
可以覆盖配置元素名称的后缀。请参阅有关定制 JCA 配置元素的信息,以了解如何覆盖配置元素名称的后缀。

用于指示主题类型的图标 任务主题



时间戳记图标 最近一次更新时间: Monday, 5 December 2016
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-libcore-mp&topic=twlp_jca_config_confact
文件名:twlp_jca_config_confact.html