Syntax
// Note: the class implementing ConnectionRequestInfo should probably // override the equals() method to something like the // essentialyEquals() method mentioned ealier. // Closing the connection, from the outside: // When you are finished with the connector, you must release // the connection handle by calling connection.close(); // Closing the connection, from the inside: // In the CCI connection object, we delegate the call: public void close() throws javax.resource.ResourceException { m_managedConnection.close(); } // In the managed connection, we are notifying all the event listeners th // at this connection was just closed. public void close() { ConnectionEventListener listener = null; ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED); for (int i = 0; i < m_eventListeners.size(); i++) { listener = (ConnectionEventListener) m_eventListeners.elementAt(i); listener.connectionClosed(ce); } } // In response, the application server will place the managed connection // in the pool, but not before cleaning it up. // This is what happens in the clean up. public void cleanup() throws javax.resource.ResourceException { Iterator cciConnectionsIterator = m_cciConnections.iterator(); while (cciConnectionsIterator.hasNext()) ((CCIConnection) cciConnectionsIterator.next()).destroy(); m_cciConnections.clear(); } // Now the connection is pooled. // When the application server shuts down ,or finds that an unused // connection has been open for a long time , it will call the destroy() // method of managed connection. public void destroy() { try { // Killing the actual connection (this is the JDBC connection) m_connection.close(); } catch (Exception e) { m_logWriter.println(e.getMessage()); } }