web server - Borland Technical Publications
web server - Borland Technical Publications web server - Borland Technical Publications
Application development overview The Connectors 1.0 specification defines the CCI for EIS access. The CCI is a standard client API for application components that enables these and EAI frameworks to drive interactions across heterogeneous EISs. The CCI is primarily targeted for Enterprise Application Integration (EAI), third-party enterprise tool vendors, and migration of legacy modules to the J2EE Platform. In the CCI, a connection factory is a public interface that enables connection to an EIS instance. The ConnectionFactory interface is implemented by the Resource Adapter to provide this service. An application looks up a ConnectionFactory instance in the JNDI namespace, and uses it to request to obtain EIS connections. The application then uses the returned Connection interface to access the EIS. To provide a consistent application programming model across both CCI and EIS-specific APIs, the ConnectionFactory and Connection interfaces comply to the Interface Template design pattern. This defines the skeleton of the connection creation and connection closing, deferring the appropriate steps to subclasses. This allows for these interfaces to be easily extended and adapted to redefine certain steps of connection creation and closing without changing these operations' structure. For more information on the application of the Interface 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. Chapter 27: Using VisiConnect 271
Application development overview 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 container terminates a component instance, the container cleans up all the connections used by that component instance. Non-managed application scenario In the non-managed application scenario, a similar programming model must be followed in the application component. The non-managed application must lookup a connection factory instance, request to obtain an EIS connection, use the connection for EIS interactions, and close the connection when completed. The following steps are performed when a non-managed application component requests to obtain a connection to an EIS instance from a connection factory: 1 The application component calls the getConnection() method on the javax.resource.cci.ConnectionFactory instance to get a connection to the underlying EIS instance. 2 The connection factory instance delegates the connection request to the default connection manager instance. The Resource Adapter provides the default connection manager implementation. 3 The connection manager instance creates a new physical connection to the underlying EIS instance by calling the ManagedConnectionFactory.createManagedConnection() method. 4 Invoking ManagedConnectionFactory.createManagedConnection() creates a new physical connection to the underlying EIS, represented by the ManagedConnection instance it returns. The ManagedConnectionFactory uses the security information from the JAAS Subject object, and ConnectionRequestInfo, and its configured set of properties (port number, server name, etc.) to create the new ManagedConnection instance. 5 The connection manager instance calls the ManagedConnection.getConnection() method to get an application-level connection handle. This method call does not necessarily create a new physical connection to the EIS instance; it produces a temporary handle that is used by an application to access the underlying physical connection, represented by the ManagedConnection instance. 6 The connection manager instance returns the connection handle to the connection factory instance; the connection factory in turn returns the connection to the requesting application component. Code excerpts - programming to the CCI The following code excerpts illustrate the application programming model based on the CCI requesting to obtain a connection, obtaining the connection factory, creating the interaction and interaction spec, obtaining a record factory and records, executing the interaction with the records, and performing the same using result sets and custom records. // Get a connection to an EIS instance after lookup of a connection factory // instance from the JNDI namespace. In this case, the component allows the // container to manage the EIS sign-on javax.naming.Context ctx = new javax.naming.InitialContext(); javax.resource.cci.ConnectionFactory cxFactory = (javax.resource.cci.ConnectionFactory)ctx.lookup( "java:comp/env/shme/shmeAdapter" ); javax.resource.cci.Connection cx = cxFactory.getConnection(); 272 BES Developer’s Guide
- Page 231 and 232: 220 BES Developer’s Guide
- Page 233 and 234: Configuring JMS administered object
- Page 235 and 236: Tibco Creating Clustered JMS Servic
- Page 237 and 238: Sonic serverUrl String localhost:72
- Page 239 and 240: Sonic Creating Clustered JMS Servic
- Page 241 and 242: OpenJMS Even though OpenJMS can be
- Page 243 and 244: OpenJMS Important If you use OpenJM
- Page 245 and 246: OpenJMS openjms.clean_messages_on_s
- Page 247 and 248: OpenJMS Table 24.1 Property Name De
- Page 249 and 250: Other JMS providers The following a
- Page 251 and 252: 240 BES Developer’s Guide
- Page 253 and 254: Creating the Interceptor Class For
- Page 255 and 256: Creating the JAR file Creating the
- Page 257 and 258: Components Components The Connector
- Page 259 and 260: System Contracts Connection Managem
- Page 261 and 262: System Contracts Security Managemen
- Page 263 and 264: Common Client Interface (CCI) Conne
- Page 265 and 266: Packaging and Deployment Figure 26.
- Page 267 and 268: Resource Adapters Resource Adapters
- Page 269 and 270: Connection management Connection ma
- Page 271 and 272: Security management with the Securi
- Page 273 and 274: Security management with the Securi
- Page 275 and 276: Resource Adapter overview Note Reso
- Page 277 and 278: Deployment Descriptors for the Reso
- Page 279 and 280: Developing the Resource Adapter Con
- Page 281: Deploying the Resource Adapter Pack
- Page 285 and 286: Application development overview //
- Page 287 and 288: Application development overview
- Page 289 and 290: Other Considerations Other Consider
- Page 291 and 292: Other Considerations To illustrate,
- Page 293 and 294: Other Considerations } } { cf = new
- Page 295 and 296: General syntax and usage General sy
- Page 297 and 298: Syntax and usage for iastool Table
- Page 299 and 300: Syntax and usage for java2iiop Exam
- Page 301 and 302: Syntax and usage for appclient Tabl
- Page 303 and 304: Building and running the BES exampl
- Page 305 and 306: Using the iastool command-line tool
- Page 307 and 308: Using the iastool command-line tool
- Page 309 and 310: Using the iastool command-line tool
- Page 311 and 312: Using the iastool command-line tool
- Page 313 and 314: Using the iastool command-line tool
- Page 315 and 316: Using the iastool command-line tool
- Page 317 and 318: Using the iastool command-line tool
- Page 319 and 320: Using the iastool command-line tool
- Page 321 and 322: Using the iastool command-line tool
- Page 323 and 324: Using the iastool command-line tool
- Page 325 and 326: Using the iastool command-line tool
- Page 327 and 328: Using the iastool command-line tool
- Page 329 and 330: Using the iastool command-line tool
- Page 331 and 332: Using the iastool command-line tool
Application development overview<br />
8 After the component finishes with the connection, it closes it using the close()<br />
method on the connection interface.<br />
cx.close();<br />
9 If the application component fails to close an allocated connection after its use, that<br />
connection is considered an unused connection. <strong>Borland</strong> Enterprise Server<br />
manages to cleanup of unused connections. When the container terminates a<br />
component instance, the container cleans up all the connections used by that<br />
component instance.<br />
Non-managed application scenario<br />
In the non-managed application scenario, a similar programming model must be<br />
followed in the application component. The non-managed application must lookup a<br />
connection factory instance, request to obtain an EIS connection, use the connection<br />
for EIS interactions, and close the connection when completed.<br />
The following steps are performed when a non-managed application component<br />
requests to obtain a connection to an EIS instance from a connection factory:<br />
1 The application component calls the getConnection() method on the<br />
javax.resource.cci.ConnectionFactory instance to get a connection to the underlying<br />
EIS instance.<br />
2 The connection factory instance delegates the connection request to the default<br />
connection manager instance. The Resource Adapter provides the default<br />
connection manager implementation.<br />
3 The connection manager instance creates a new physical connection to the<br />
underlying EIS instance by calling the<br />
ManagedConnectionFactory.createManagedConnection() method.<br />
4 Invoking ManagedConnectionFactory.createManagedConnection() creates a new<br />
physical connection to the underlying EIS, represented by the ManagedConnection<br />
instance it returns. The ManagedConnectionFactory uses the security information from<br />
the JAAS Subject object, and ConnectionRequestInfo, and its configured set of<br />
properties (port number, <strong>server</strong> name, etc.) to create the new ManagedConnection<br />
instance.<br />
5 The connection manager instance calls the ManagedConnection.getConnection()<br />
method to get an application-level connection handle. This method call does not<br />
necessarily create a new physical connection to the EIS instance; it produces a<br />
temporary handle that is used by an application to access the underlying physical<br />
connection, represented by the ManagedConnection instance.<br />
6 The connection manager instance returns the connection handle to the connection<br />
factory instance; the connection factory in turn returns the connection to the<br />
requesting application component.<br />
Code excerpts - programming to the CCI<br />
The following code excerpts illustrate the application programming model based on the<br />
CCI requesting to obtain a connection, obtaining the connection factory, creating the<br />
interaction and interaction spec, obtaining a record factory and records, executing the<br />
interaction with the records, and performing the same using result sets and custom<br />
records.<br />
// Get a connection to an EIS instance after lookup of a connection factory<br />
// instance from the JNDI namespace. In this case, the component allows the<br />
// container to manage the EIS sign-on<br />
javax.naming.Context ctx = new javax.naming.InitialContext();<br />
javax.resource.cci.ConnectionFactory cxFactory =<br />
(javax.resource.cci.ConnectionFactory)ctx.lookup(<br />
"java:comp/env/shme/shmeAdapter" );<br />
javax.resource.cci.Connection cx = cxFactory.getConnection();<br />
272 BES Developer’s Guide