user manual

316 BES Developers Guide
Application Development Overview
Template design pattern to these interfaces, refer to Section 5.5.1 in the
Connectors 1.0 specification (http://java.sun.com/j2ee/connector).
Managed Application Scenario
The following steps are performed when a managed application requests to
obtain a connection to an EIS instance from a connection factory, as specified
in the res-type variable:
1 The application assembler or component provider specifies the connection
factory requirements for an application component by using a deployment
descriptor:
res-ref-name: shme/shmeAdapter
res-type:javax.resource.cci.ConnectionFactory
res-auth: Application | Container
2 The Resource Adapter deployer sets the configuration information for the
Resource Adapter.
3 VisiConnect uses a configured Resource Adapter to create physical
connections to the underlying EIS.
4 The application component performs a JNDI lookup of a connection factory
instance in the component's environment:
// obtain the initial JNDI Naming context
javax.naming.Context ctx = new javax.naming.InitialContext();
// perform the JNDI lookup to obtain the connection factory
javax.resource.cci.ConnectionFactory cxFactory =
(javax.resource.cci.ConnectionFactory)ctx.lookup(
"java:comp/env/shme/shmeAdapterConnectionFactory");
5 The JNDI name passed in the context lookup is that same as that specified
in the res-ref-element of the component's deployment descriptor. The JNDI
lookup returns a connection factory instance of type
java.resource.cci.ConnectionFactory as specified in the res-type element.
6 The application component invokes the getConnection() method on the
connection factory to request to obtain an EIS connection. The returned
connection instance represents an application level handle to an underlying
physical connection. An application component requests multiple
connections by invoking the getConnection() method on the connection
factory multiple times.
javax.resource.cci.Connection cx = cxFactory.getConnection();
7 The application component uses the returned connection to access the
underlying EIS. This is specific to the Resource Adapter.
8 After the component finishes with the connection, it closes it using the
close() method on the connection interface.
cx.close();
9 If the application component fails to close an allocated connection after its
use, that connection is considered an unused connection. Borland
Enterprise Server manages to cleanup of unused connections. When the