Sure, no problem. The code needs to be inserted in your ManagedConnection 
implementation. You need an instance variable to track the "listeners" on the 
connection. As I understand it, when JBoss allocates the connection using the 
ConnectionManager, it calls the "addConnectionEventListener" method in your 
ManagedConnection class, adding the Connection Manager as a 
ConnectionEventListener. When you close the client connection, your code should 
call an method (I called mine "disconnectConnection") in the Managed Connection 
that notifies any listeners that the connection has closed. When the 
ConnectionManager receives this notification, it returns the ManagedConnection 
to the pool.

So, for example:

private ArrayList _listeners = new ArrayList();
  | public void addConnectionEventListener(ConnectionEventListener arg0) {
  |     _listeners.add(arg0);
  | }
  | public void removeConnectionEventListener(ConnectionEventListener arg0) {
  |     _listeners.remove(arg0);
  | }
  | 
  | /**
  |  * Called by the CCI Connection to notify the Managed Connection that is 
has finished.
  |  * This should post the correct event
  |  * to listeners on this managed connection (namely the AppServer's 
ConnectionManager).
  |  * @param arg0 The CCI Connection being disconnected
  |  */
  | public void disconnectConnection(Connection arg0) {
  |     // Create the disconnection event
  |     ConnectionEvent cev     = new 
ConnectionEvent(this,ConnectionEvent.CONNECTION_CLOSED);
  |     // Set the handle to the actual CCI connection being removed
  |     cev.setConnectionHandle(arg0);
  | 
  |     // Send the event to the listeners
  |     for(int i = 0; i < _listeners.size(); i++) {
  |             ConnectionEventListener l       = 
(ConnectionEventListener)_listeners.get(i);
  |             l.connectionClosed(cev);
  |     }
  | }

And then in the actual Client Connection class:

protected FSManagedConnection m_mc;
  | public void close() throws ResourceException {
  |     FSManagedConnection mc  = m_mc;
  |     m_mc                    = null;
  |     mc.disconnectConnection(this);
  | }

Hope this helps,
Dan.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3901960#3901960

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3901960


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to