12.11.2014 Views

web server - Borland Technical Publications

web server - Borland Technical Publications

web server - Borland Technical Publications

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Application development overview<br />

The Connectors 1.0 specification defines the CCI for EIS access. The CCI is a<br />

standard client API for application components that enables these and EAI frameworks<br />

to drive interactions across heterogeneous EISs. The CCI is primarily targeted for<br />

Enterprise Application Integration (EAI), third-party enterprise tool vendors, and<br />

migration of legacy modules to the J2EE Platform.<br />

In the CCI, a connection factory is a public interface that enables connection to an EIS<br />

instance. The ConnectionFactory interface is implemented by the Resource Adapter to<br />

provide this service. An application looks up a ConnectionFactory instance in the JNDI<br />

namespace, and uses it to request to obtain EIS connections.<br />

The application then uses the returned Connection interface to access the EIS. To<br />

provide a consistent application programming model across both CCI and EIS-specific<br />

APIs, the ConnectionFactory and Connection interfaces comply to the Interface<br />

Template design pattern. This defines the skeleton of the connection creation and<br />

connection closing, deferring the appropriate steps to subclasses. This allows for these<br />

interfaces to be easily extended and adapted to redefine certain steps of connection<br />

creation and closing without changing these operations' structure. For more<br />

information on the application of the Interface Template design pattern to these<br />

interfaces, refer to Section 5.5.1 in the Connectors 1.0 specification (http://<br />

java.sun.com/j2ee/connector).<br />

Managed application scenario<br />

The following steps are performed when a managed application requests to obtain a<br />

connection to an EIS instance from a connection factory, as specified in the res-type<br />

variable:<br />

1 The application assembler or component provider specifies the connection factory<br />

requirements for an application component by using a deployment descriptor:<br />

res-ref-name: shme/shmeAdapter<br />

res-type:javax.resource.cci.ConnectionFactory<br />

res-auth: Application | Container<br />

2 The Resource Adapter deployer sets the configuration information for the Resource<br />

Adapter.<br />

3 VisiConnect uses a configured Resource Adapter to create physical connections to<br />

the underlying EIS.<br />

4 The application component performs a JNDI lookup of a connection factory instance<br />

in the component's environment:<br />

// obtain the initial JNDI Naming context<br />

javax.naming.Context ctx = new javax.naming.InitialContext();<br />

// perform the JNDI lookup to obtain the connection factory<br />

javax.resource.cci.ConnectionFactory cxFactory =<br />

(javax.resource.cci.ConnectionFactory)ctx.lookup(<br />

"java:comp/env/shme/shmeAdapterConnectionFactory");<br />

5 The JNDI name passed in the context lookup is that same as that specified in the<br />

res-ref-element of the component's deployment descriptor. The JNDI lookup returns<br />

a connection factory instance of type java.resource.cci.ConnectionFactory as<br />

specified in the res-type element.<br />

6 The application component invokes the getConnection() method on the connection<br />

factory to request to obtain an EIS connection. The returned connection instance<br />

represents an application level handle to an underlying physical connection. An<br />

application component requests multiple connections by invoking the<br />

getConnection() method on the connection factory multiple times.<br />

javax.resource.cci.Connection cx = cxFactory.getConnection();<br />

7 The application component uses the returned connection to access the underlying<br />

EIS. This is specific to the Resource Adapter.<br />

Chapter 27: Using VisiConnect 271

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

Saved successfully!

Ooh no, something went wrong!