DevPortal

How do I use Connectors (Resource Adaptors)?


Table of Contents


How do I use Connectors (Resource Adaptors)?

A J2EE application may consist of connector components such as resource adapters. This section describes how to deploy a resource adapter, define a connection factory, and test the resource adapter using an application.

How do I package Resource Adapters?

A resource adapter is packaged in a .rar file, which can be deployed on any J2EE server. A .rar file may be contained in a .ear file as a module, or may exist as a standalone file.

Where are the Resource Adapter Archive Components located?

After deployment, the standalone resource adapter files are located at: <install_dir>/server/nodes/<server_name>/archives/<rar name>/<rar version dir>.

If the adapter is part of an application, the files are located at: <install_dir>/server/nodes/<server_name>/archives/<application name>/<application version dir>/<rar name>/.

A rar contains the following files and directories:

Table 1: Files in a .rar file

Directory/FilesDescription
.jarContains the implementation classes for connecting to the EIS.
ra.xmlContains all the details of the resource adapter. It is located in the Meta-inf folder.
*.htmlRefers to HTML files.
library filesAny system specific libraries required by the RAR classes.

How do I manage Standard Resource Adapter Deployment Descriptor?

A resource adapter has an associated descriptor file containing adapter-specific parameters. These parameters are defined based on the J2EE Connector Architecture (henceforth referred to as JCA) specification.

The resource adapter descriptor file, ra.xml, is located at <install_dir>/server/nodes/<server_name>/archives/<rar name>/<rar version dir>/META-INF.

If the resource adapter is part of an application, the file is located at: <install_dir>/server/nodes/<server_name>/archives/<application name>/<application version dir>/<rar name>/META-INF.

A resource adapter descriptor file contains:

How do I manage Pramati Specific Resource Adapter Deployment Descriptor?

In addition to the descriptor file, there is a Pramati specific descriptor file, pramati-j2ee-server.xml, with a tag called connector for the resource adapter. It contains the name of the resource adapter and the configuration details of all the connection factories that are bound to it. The configuration details are:

This file is located at <install_dir>/server/nodes/<server_name>/archives/<rar name>/<rar version dir>. If the resource adapter is part of an application, the file is located at <install_dir>/server/nodes/<server_name>/archives/<application name>/<application version dir>/.

Usage Scenario

A connector (or a resource adapter) can act as a communication bridge between an EIS and J2EE applications running on an application server. This communication can be in two modes if the connector is a JCA 1.5 connector.

If it's a J2EE 1.0 connector, the communication is initiated only by the application, while in case of a 1.5 connector the application can initiate communication and the EIS can also initiate contact with the application using a message delivery model.

To integrate a client with an EIS in a typical enterprise scenario:

  1. Obtain a resource adapter specific to the EIS and deploy it on the application server.
  2. Define a connection factory for the resource adapter in the server namespace. For a standalone adapter, you can define a connection factory at any time. For a resource adapter that is part of an application, you can define a connection factory only when you deploy the application. To deploy the application, resolve the application-specific tasks and the resource adapter specific task of defining the connection factory.
  3. Use the client API provided by the resource adapter, to access data from the information system.

The resource adapter functions as a factory for connections. An application client uses a connection factory to access a connection instance, which it then uses to connect to the EIS.

What types of Client Interfaces are available?

The client interfaces used by enterprise applications and resource adapters to connect to heterogeneous EIS are of two types: The CCI has two main interfaces: ConnectionFactory is an interface that allows an application client to obtain a connection to an EIS instance.

Sample Code

// obtain application server specific naming context
Context ic = new InitialContext();
javax.resource.cci.ConnectionFactory cf = javax.resource.cci,ConnectionFactory)ic.lookup("myconnfact");
javax.resource.cci.Connection con = cf.getConnection();
//use the connection object to access data using CCI
con.doSomething();.........
//close the connection
con.close();
Example of non-CCI interfaces are:
for ConnectionFactory interface-
javax.sql.DataSource;
for Connection Interface -
java.sql.Connection
// obtain application server specific naming context
Context ic = new InitialContext();
javax.sql.DataSource ds =
(javax.resource.DataSource)ic.lookup("myconnfact");
java.sql.Connection con = cf.getConnection();
con.doSomething();.........
//finally close the connection
con.close();
Also,
for ConnectionFactory interface-
com.myeis.SomeConnectionFactory;
for Connection Interface -
com.myeis.MyConnection
// obtain application server specific naming context
com.myeis.SomeConnectionFactory cf = (com.myeis.SomeConnectionFactory)ic.lookup("myconnfact");
com.myeis.MyConnection myCon = cf.getConnection();
//use the connection object to access data using the API provided by the connection interface
myCon.doSomething();.........
//close the connection
myCon.close();

How does Pramati implement JCA?

Pramati Server implements the system contracts for an application server according to the JCA 1.5 specification. The Pramati JCA implementation supports connection, transaction, and security contracts. It has the following features:

You can download the JCA 1.5 specification from http://java.sun.com/j2ee/download.html#connectorspec.

How do I deploy Resource Adapters?

RARs can be deployed on Server in two ways:

The recommended way of deploying a Resource Adapter (standalone, or packaged inside another .ear) is to open it in the Deploy Tool. Once opened, click the rar node in the tree and select Configuration.

Set the following attributes:

If the resource adapter is a JCA 1.5 Resource Adapter, an additional set of properties need to be configured to create a connection factory. The Deploy Tool automatically detects the version of the Resource Adapter and displays the appropriate panels for configuration.

For a 1.5 Resource Adapter, the additional configuration is selecting the Connection Definition, that is, the ManagedConnectionFactory implementation and the Connection and Connection Factory classes and their implementations. Once this is selected, the property section comes up, as described above.

Note: A Resource Adapter can be deployed just like any other application on the Server.

The Property panel defines one property set for each ManagedConnectionFactory instance for creating connections to various underlying EIS instances.

How do I deploy applications?

  1. At the Server shell, type deploytool. The Deploy Tool UI appears.
  2. Click Archive > Open. Specify the name and location of the enterprise application.
  3. Click Archive > Deploy. The application is deployed.

How do I start applications?

  1. In the Console, click Applications. A list of all the deployed applications appears.
  2. Click Start to start the enterprise application.

How do I undeploy Resource Adapters?

  1. At the default prompt, type deploytool.
  2. Select Archive > Undeploy > (resource adapter name). The resource adapter is undeployed. The connection factories that are bound to the resource adapter are unbound.

Note: You can type 'list' at the ressh (the resource administration shell) prompt to verify that the connection factories are no longer bound for a particular resource adapter once it is undeployed.

How do I deploy Resource Adapters on Cluster Nodes?

Deploying a resource adapter on a cluster node is similar to deploying it on a standalone server. The additional factors are:

How do I create Connector Resources after deploying Resource Adapters?

Connector resources (or connection factories) can be created post-deployment of a resource adapter also. This can be done using either:

How do I use Server Shell to create Connector Resources (for a 1.0 connector)?

Type ressh at the Server shell prompt to go to the resource administration shell. Your prompt should change to resourceadmin@(servername)>.

Even though most of the commands in the ressh work in two modes, you can only use the interactive mode for this command. Type add_jca_cf and press Enter. It prompts you for further details as follows:

resourceadmin@server> - rarName * #

Enter the resource adapter name for which you want to create a connection factory. The name you enter here must be the name of a resource adapter that you have deployed earlier.

resourceadmin@default> - jndiName * #

Enter a unique name for the connection factory. This is the name by which the connection factory will be bound in the server's JNDI namespace.

resourceadmin@default> - user #

Enter the name of a user if you want the connection factory to be server authored. Press Enter without entering anything if you want the credentials for connecting to be provided by the application code at runtime.

resourceadmin@default> - password * #

Enter the password, keeping in mind the things mentioned above.

resourceadmin@default> - maxPoolSize [40]

Enter a valid value for the maximum pool size that your connection factory should have. The default value is 40.

resourceadmin@default> - connectionRequestTimeoutSeconds [10]

Enter a valid value for the maximum time in seconds that your application will wait for a connection from the connection factory. The default value is 10 seconds.

Next, you are prompted for entering configuration data for the managed connection factory. Note that this step is optional for some resource adapters. Whether the MCF has any configurable properties or not depends on the resource adapter provider/EIS. Enter the relevant values.

Added JCA Connection Factory jndi name This message indicates that your JCA 1.0 connection factory was created successfully. If there were any errors while creating, a stack trace is displayed. You can refer to the stack trace and error messages to detect the problem.

How do I use Server Shell to create Connector Resources (for a 1.5 Connector)?

Type ressh at the server shell prompt to go to the resource administration shell. Your prompt should change to resourceadmin@(servername)>.

Even though most of the commands in the ressh work in two modes, you can only use the interactive mode for this command. Type add_jca_cf and press Enter. It will prompt you for further details as follows:

resourceadmin@server> - rarName * #

Enter the resource adapter name for which you want to create a connection factory. The name you enter here must be the name of a resource adapter that you have deployed earlier.

resourceadmin@default> - jndiName * #

Enter a unique name for the connection factory. This is the name by which the connection factory will be bound in the Server's JNDI namespace.

resourceadmin@default> - user #

Enter the name of a user if you want the connection factory to be server authored. Press Enter without entering anything if you want the credentials for connecting to be provided by the application code at runtime.

resourceadmin@default> - password * #

Enter the password, keeping in mind the things mentioned above.

resourceadmin@default> - maxPoolSize [40]

Enter a valid value for the maximum pool size that your connection factory should have. The default value is 40.

resourceadmin@default> - connectionRequestTimeoutSeconds [10]

Enter a valid value for the maximum time in seconds that your application will wait for a connection from the connection factory. The default value is 10 seconds.

Outbound connection definition * #

A list of all available connection definitions are shown before this prompt. This lets you choose the connection implementation that you want for your connection factory. Type the number corresponding to the connection definition data set and press Enter.

Based on your selection, you are prompted for entering configuration data for the managed connection factory. Note that this step is optional for some resource adapters. Whether the MCF has any configurable properties or not depends on the resource adapter provider/EIS. Enter the relevant values.

Added JCA Connection Factory jndi name This message indicates that your JCA 1.5 connection factory was created successfully. If there were any errors while creating, a stack trace is displayed. You can refer to the stack trace and error messages to detect the problem.

How do I use J2EE Connector 1.5 Resource Adapters for Inbound Communication?

The J2EE Connector Architecture 1.5 specification defines additional contracts for an application server as well as a Resource Adapter provider (usually an EIS), which facilitate the EIS to initiate communication to the J2EE application based on a message delivery model. In this model, the resource adapter acts like a bridge between the EIS and the J2EE application. For example, the EIS may be a legacy message oriented middleware (MOM) system, or it may be a non-RDBMS information system.

This new architecture also embraces the J2EE standard message driven beans (MDBs). Prior to J2EE 1.4, MDBs were restricted to being message listeners from JMS-based messaging providers. J2EE 1.4, the EJB 2.1, and JCA 1.5 specification has extended MDBs to implement any Message Listener interface, meaning that MDBs in a J2EE application can now receive messages from any messaging provider with custom APIs.

The requirements for this to happen are:

Also, JMS-based providers are also required to provide a resource adapter for communication between applications and the JMS provider. If the JMS provider does not have a 1.5 JCA resource adapter, Pramati Server provides a generic wrapper adapter for such providers.


© Pramati Technologies 2007 Runs on Pramati Server | Feedback | Legal