web server - Borland Technical Publications

web server - Borland Technical Publications web server - Borland Technical Publications

techpubs.borland.com
from techpubs.borland.com More from this publisher
12.11.2014 Views

Chapter 21 21Connecting to Resources with BES: Chapter using the Definitions Archive (DAR) Note J2EE specifies a uniform mechanism for establishing connections to resources using Java standard interfaces. A resource related object containing resource manager location details and connection attributes is bound under a JNDI service provider, and can be retrieved by your application as a resource connection factory in a JNDI lookup. Sample resource connection factories include JDBC datasources and JMS connection factories. Once a resource connection factory is obtained from JNDI, a connection to the desired resource manager can then be established. A connection to a relational database is obtained through a JDBC datasource, a connection to a message broker is obtained through a JMS connection factory, and general Enterprise Information Systems (EIS) connections are obtained through JCA resource adapters. Use the Borland Management Console and Borland Deployment Descriptor Editor (DDEditor) to create, edit, and deploy resource connection factories and other resource related JNDI objects, such as JMS destinations. An XML descriptor file (jndidefinitions.xml), generally called the JNDI Definitions module, captures the properties representing resource related objects. This file is packaged in a Data ARchive (DAR) module. In BES, a partition hosted Naming Service represents the default JNDI service provider - its an implementation of a CosNaming service provider. Resource related objects are bound in the Naming Service of a BES partition through deployment of DAR or RAR module using standard BES deployment procedures. At that time, only properties required to create an instance of a resource connection factory, or JMS destination, are stored in the JNDI bound object. During JNDI lookup for a resource related object, an instance of the desired resource object is created using the stored property values from the object retrieved. The newly created instance is then passed back to the caller of JNDI lookup() method. In this way, DARs can be successfully deployed to a BES partition without having to load classes for vendor specific resource objects. Class libraries for resource vendors are only required by application processes that actually perform JNDI lookup of resource related objects. In prior versions of BES, a file-system service provider called the Serial Provider was the default JNDI service provider for deployment of DARs and JNDI Definitions modules. Resource related objects bound to this provider involved creation of the resource objects during deployment, and hence required vendor class libraries to be deployed in advance. In addition, JNDI names for resource related objects required a Chapter 21: Connecting to Resources with BES: using the Definitions Archive (DAR) 191

JNDI Definitions Module Important serial URL prefix, that is “serial://”. With the Naming Service being the default service provider, this prefix is no longer required in JNDI name specification. Deployment of existing DARs/JNDI Definitions modules that have JNDI names with this prefix are now automatically bound to the Naming Service. A resource related object is obtained in J2EE through a resource reference. You can reference resource connection factories or JMS destinations from EJBs, servlets and other J2EE application components using resource-reference elements in the component's deployment descriptors. Refer to Chapter 22, “Using JDBC” for more specific information on how to define JDBC datasource resource references, and Chapter 23, “Using JMS” for resource reference definition examples of JMS connection factories and destinations. Each BES partition has a predeployed DAR module named default-resources.dar containing example definitions for JDBC datasources, JMS connection factories and JMS destinations. This module can be examined, updated and redeployed in the following steps: 1 Navigate to default-resources.dar under the Deployed Modules node of a partition in the left pane of the BES console. 2 Right-click on default-resources.dar and select Edit deployment descriptor from the context menu. The Borland Deployment Descriptor Editor window will open. The available datasources and connection factories should be visible in the left pane. 3 Right-click on the root node in the navigation pane of the Borland Deployment Descriptor Editor and select the appropriate option to create a New object you want to add. When a J2EE component attempts a JNDI lookup for a resource reference, vendor classes associated with the resource object must be available in the runtime environment. If the J2EE component is deployed to a BES partition, the vendor class libraries must be deployed to the partition as a library archive. Exceptions to this rule include JNDI lookups for resource objects whose dependent class libraries are bundled with BES. For example, a JDataStore datasource or any JMS resource object of the JMS message server installed with BES. For documentation updates, go to www.borland.com/techpubs/bes. JNDI Definitions Module Note Resource related objects are bound under the Naming Service through deployment of a DAR file containing the JNDI Definitions Module. A DAR has a special .dar file extension. It must be deployed to a BES partition either individually or packaged with other J2EE modules in an EAR file. A DAR is not a part of the J2EE specification. It is a Borland-specific implementation designed to simplify deployment and management of resource connection factories and JMS destinations. You do not package connection factory or JMS destination vendor classes in this archive type. Those classes must be deployed as a library to individual Partitions. The only contents of the DAR that you must provide is an XML descriptor file called jndi-definitions.xml. It contains definitions for resource related objects, each with a JNDI name identifying its location in JNDI. Like other descriptors, this is placed within the META-INF directory of the DAR. The contents of the DAR hence is as follows: META-INF/jndi-definitions.xml 192 BES Developer’s Guide

JNDI Definitions Module<br />

Important<br />

serial URL prefix, that is “serial://”. With the Naming Service being the default service<br />

provider, this prefix is no longer required in JNDI name specification. Deployment of<br />

existing DARs/JNDI Definitions modules that have JNDI names with this prefix are now<br />

automatically bound to the Naming Service.<br />

A resource related object is obtained in J2EE through a resource reference. You can<br />

reference resource connection factories or JMS destinations from EJBs, servlets and<br />

other J2EE application components using resource-reference elements in the<br />

component's deployment descriptors. Refer to Chapter 22, “Using JDBC” for more<br />

specific information on how to define JDBC datasource resource references, and<br />

Chapter 23, “Using JMS” for resource reference definition examples of JMS connection<br />

factories and destinations.<br />

Each BES partition has a predeployed DAR module named default-resources.dar<br />

containing example definitions for JDBC datasources, JMS connection factories and<br />

JMS destinations. This module can be examined, updated and redeployed in the<br />

following steps:<br />

1 Navigate to default-resources.dar under the Deployed Modules node of a partition<br />

in the left pane of the BES console.<br />

2 Right-click on default-resources.dar and select Edit deployment descriptor from<br />

the context menu. The <strong>Borland</strong> Deployment Descriptor Editor window will open. The<br />

available datasources and connection factories should be visible in the left pane.<br />

3 Right-click on the root node in the navigation pane of the <strong>Borland</strong> Deployment<br />

Descriptor Editor and select the appropriate option to create a New object you want<br />

to add.<br />

When a J2EE component attempts a JNDI lookup for a resource reference, vendor<br />

classes associated with the resource object must be available in the runtime<br />

environment. If the J2EE component is deployed to a BES partition, the vendor class<br />

libraries must be deployed to the partition as a library archive. Exceptions to this rule<br />

include JNDI lookups for resource objects whose dependent class libraries are bundled<br />

with BES. For example, a JDataStore datasource or any JMS resource object of the<br />

JMS message <strong>server</strong> installed with BES.<br />

For documentation updates, go to www.borland.com/techpubs/bes.<br />

JNDI Definitions Module<br />

Note<br />

Resource related objects are bound under the Naming Service through deployment of<br />

a DAR file containing the JNDI Definitions Module. A DAR has a special .dar file<br />

extension. It must be deployed to a BES partition either individually or packaged with<br />

other J2EE modules in an EAR file.<br />

A DAR is not a part of the J2EE specification. It is a <strong>Borland</strong>-specific implementation<br />

designed to simplify deployment and management of resource connection factories<br />

and JMS destinations. You do not package connection factory or JMS destination<br />

vendor classes in this archive type. Those classes must be deployed as a library to<br />

individual Partitions.<br />

The only contents of the DAR that you must provide is an XML descriptor file called<br />

jndi-definitions.xml. It contains definitions for resource related objects, each with a<br />

JNDI name identifying its location in JNDI. Like other descriptors, this is placed within<br />

the META-INF directory of the DAR. The contents of the DAR hence is as follows:<br />

META-INF/jndi-definitions.xml<br />

192 BES Developer’s Guide

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!