Tuesday, November 6, 2007

Relationship to Connectors::JAVA


The J2EE Connector Architecture 1.0 Specification defines a set of contracts that
allow a resource adapter to extend a container in a pluggable way. A resource
adapter provides connectivity to an external system from the application server. The
resource adapter’s functionality is similar to that provided by the JDBC interfaces
used in the J2EE platform to establish a connection with a data source. These
interfaces, which the Connector specification refers to as the service provider interface
(SPI), are the following:

  • DataSource
  • ConnectionPoolDataSource
  • XADataSource
Additionally, the Connector Architecture defines a packaging format to allow a
resource adapter to be deployed into a J2EE compliant application server.


System Contracts

The system contracts defined in the Connector specfication describe the interface
between an application server and one or more resource adapters. This interface
allows a resource adapter to be bundled in such a way that it can be used by any
application server that supports the system contracts.
The following standard contracts are defined between an application server and a
back end system:
  • A connection management contract that enables application components toconnect to a back end system.
The connection management contract is equivalent to the services described by
the JDBC interfaces DataSource and ConnectionPoolDataSource.
Chapter 19 Relationship to Connectors 168
  • A transaction management contract between the transaction manager and a backend system supporting transactional access to its resources.
The transaction contract is equivalent to the services described by the JDBC
interface XADataSource.
  • A security contract that enables secure access to a back end system.The security contract does not have an equivalent in the JDBC API.Authentication in the JDBC API always consists of providing a user name and apassword.
The JDBC specification does not make a distinction between its application
programming interface (API) and the SPI. However, a driver can map the JDBC
interfaces in the SPI to the Connector system contracts.


Mapping Connector System Contracts to
JDBC Interfaces

Driver vendors who want to supply JDBC drivers that use the Connector system
contracts have several options:

1. To write a set of classes that wrap a JDBC driver and implement the Connector
system contracts. Constructing these wrappers is fairly straightforward and
should allow JDBC driver vendors to provide resource adapters quickly enough
so that they are available when application server vendors have implemented the
Connector contracts.

2. To implement the Connector system contracts natively. This approach avoids the
overhead of wrapper classes, but the implementation effort may be more involved
and time-consuming. This alternative is a more long-term option.
Either approach will allow JDBC driver vendors to package their drivers as resource
adapters and get all the benefits of pluggability, packaging, and deployment.


Packaging JDBC Drivers in Connector
RAR File Format

Resource adapters can be packaged, along with a deployment descriptor, into a
Resource adapter ARchive, or RAR file. The RAR file contains the Java classes/
interfaces, native libraries, deployment descriptor, and other resources needed to
deploy the adapter.
The deployment descriptor maps the classes in the resource adapter to the specific
roles that they perform. The descriptor also details the capabilities of the resource
adapter in terms of what level of transactional support it provides, the kind of
security it supports, and so on.

CODE EXAMPLE is an example of a deployment descriptor for a JDBC driver. The
class com.acme.JdbcManagedConnectionFactory could be supported by an
implementation of javax.sql.XADataSource. The resource adapter section
contains information on the level of transaction support, the mechanism used for
authentication, and configuration information for deploying the data source in the
JNDI namespace.




’http://java.sun.com/j2ee/dtds/connector_1_0.dtd’>

Acme JDBC Adapter
Acme Software Inc
1.0
1.0
JDBC Database

com.acme.JdbcManagedConnectionFactorymanagedconnectionfactory-class>
javax.sql.DataSource
com.acme.JdbcDataSource
java.sql.Connection
com.acme.JdbcConnection
xa_transaction

XADataSourceName
java.lang.String
Chapter 19 Relationship to Connectors 170
jdbc/XAAcme


basic-password
javax.resource.security.PasswordCredentialcredential-interface>

false


CODE EXAMPLE 19-1 Example of a resource adapter deployment descriptor.
See the Connector specification for more details.

No comments: