Configuring JCA connection factories

You can configure connection factories that comply with Java™ EE Connector Architecture (JCA) specification.

About this task

You can configure one or more connection factory instances for connection factory types that are provided by an installed resource adapter.
Note: To configure JCA support for Liberty, you must edit the server.xmlfile using either the Source view of the Server configuration editor of the WebSphere® Application Server Developer Tools for Eclipse, or some other text editor. This topic assumes that a resource adapter with a unique identifier of MyAdapter has already been configured in the server, see the documentation on configuring resource adapters for further details. An end-to-end example of configuring a basic scenario is provided in the following steps.
Note: Editing the properties sub-elements of the server configuration for connection factories, administrative objects, activation specifications, and resource adapters in the Design view of WebSphere® Development Tools (WDT) is not supported.

Procedure

  1. Update the server.xml file to add the jca-1.6 feature under the featureManager tag.
    <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. Install a resource adapter. For example, update the server.xml file as follows:
    <resourceAdapter location="C:/adapters/MyAdapter.rar"/>
  3. Configure one or more connection factory instances. When you configure the connection factory instances, you must supply a properties subelement, even if you do not want to override any configuration properties, in order to associate the connectionFactory element with a connection factory interface that is provided by a particular resource adapter. In the following example, the MyAdapter resource adapter provides only one type of connection factory:
    <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. (Optional) If required, identify the available connection factory property subelement names.
    • If a resource adapter provides exactly one connection factory interface, excluding any JMS connection factories, the subelement is: properties.<rar_identifier>

    • If the interface name is unique without the package name, the subelement name is: properties.<rar_identifier>.<InterfaceName>
    • If the implementation name is unique without the package name, the subelement name is: properties.<rar_identifier>.<ImplementationName>
    • In other cases, the subelement name is: properties.<rar_identifier>.<fully.qualified.InterfaceName>

Example

Use the following example to learn how to configure resource adapters with two connection factories with unique interface class names.

In the following snippet from a ra.xml file, the MyAdapter resource adapter provides two connection factories with unique interface class names:

<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> 
The following is an example of a server configuration for this scenario:
<connectionFactory jndiName="eis/cf">
 <properties.MyAdapter.ConnectionFactory serverName="localhost"/>
</connectionFactory>

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

Use the following example to learn how to configure resource adapters with two connection factories with unique implementation class names.

In the following snippet from a ra.xml file, the MyAdapter resource adapter provides two connection factories with unique implementation class names:

<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>
The following is an example of a server configuration for this scenario:
<connectionFactory jndiName="eis/cf1">
 <properties.MyAdapter.ConnectionFactoryImpl serverName="localhost"/>
</connectionFactory> 

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

Use the following example to learn how to configure resource adapters with two connection factories where neither the simple interface nor implementation class names are unique.

In the following snippet from a ra.xml file, the MyAdapter resource adapter provides two connection factories where neither the simple interface nor the implementation class names are unique:

<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>
The following is an example of a server configuration for this scenario:
<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>
It is possible to override the suffixes of configuration element names. See the information about customizing JCA configuration elements to learn how to override the suffixes of configuration element names.

Icon that indicates the type of topic Task topic

File name: twlp_jca_config_confact.html