Adding resource manager connection factory references

The J2EE specification provides a means for J2EE components to refer to resource manager connection factories by using "logical" names called resource manager connection factory references. You can use the deployment descriptor editors to define resource manager connection factory references.

A resource manager connection factory is an object that is used to create connections to a resource manager. For example, an object that implements the javax.sql.DataSource interface is a resource manager connection factory for java.sql.Connection objects that implement connections to a database management system.

At deployment, the resource manager connection factory references are bound to the actual resource manager connection factories that exist in the target operational environment.

Resource manager connection factory objects that are accessed through a reference are only valid within the component instance that performed the lookup.

For each resource manager connection factory reference that you define, a resourece-ref element is added to the deployment descriptor for that application component. The references are scoped to the application component where they are defined, so they are not accessible to other application components during run time. Other components can define resource manager connection factory references with the same name without causing a name conflict.

To define a resource manager connection factory reference:

  1. Open the Add Reference wizard from the deployment descriptor editor for your J2EE module.

  2. Select Resource reference and click Next.

  3. In the Name field, specify a name for the reference, or accept the default name provided by the wizard (recommended). The value entered in the Name field is used in the res-ref-name entry in the deployment descriptor.

    The name of the reference is relative to the java:comp/env context. For example, the name should be jms/StockHistoryDB rather than java:comp/env/jms/StockHistoryDB.

  4. In the Type field, select the Java programming language type of the resource manager connection factory that the application component code expects. The value entered in this field is used in the res-type entry in the deployment descriptor.

  5. In the Authentication field, indicate whether your application (or servlet, for JSP 1.2 Web projects) performs resource sign-on programmatically, or whether the container manages all authentication for this resource The value specified here is used in the res-auth entry in the deployment descriptor.

  6. For J2EE 1.3 or later projects, in the Shareable field, indicate whether the connections to the resource manager that are obtained through the given resource manager connection factory reference can be shared. By default, connections are assumed to be shareable. The value specified here is used in the res-sharing-scope entry in the deployment descriptor.

  7. In the Description text area, enter a description for the reference.

  8. Click Finish.

 

Related concepts

Client Deployment Descriptor editor

 

Related tasks

Defining references in J2EE modules
Adding EJB references
Adding message destination references
Adding resource environment references
Adding security role references
Adding Web service references