![]() |
|
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.
<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/Files | Description |
|---|---|
| .jar | Contains the implementation classes for connecting to the EIS. |
| ra.xml | Contains all the details of the resource adapter. It is located in the Meta-inf folder. |
| *.html | Refers to HTML files. |
| library files | Any system specific libraries required by the RAR classes. |
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:
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>/.
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:
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.
javax.resource.cci.ConnectionFactory to implement connection factoryjavax.resource.cci.Connection to implement connectionConnectionFactory is an interface that allows an application client to obtain a connection to an EIS instance.
// 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();
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:
http://java.sun.com/j2ee/download.html#connectorspec.
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.
deploytool. The Deploy Tool UI appears.deploytool.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.
Deploying a resource adapter on a cluster node is similar to deploying it on a standalone server. The additional factors are:
Connector resources (or connection factories) can be created post-deployment of a resource adapter also. This can be done using either:
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.
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.
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 |