/**
  * Close handle
  *
  * @param handle The handle
  */
 void closeHandle(StatisticsConnection handle) {
   ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
   event.setConnectionHandle(handle);
   for (ConnectionEventListener cel : listeners) {
     cel.connectionClosed(event);
   }
 }
 /**
  * Close handle
  *
  * @param handle The handle
  */
 public void closeHandle(MultipleConnection2 handle) {
   ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
   event.setConnectionHandle(handle);
   for (ConnectionEventListener cel : listeners) {
     cel.connectionClosed(event);
   }
 }
  /**
   * Close handle
   *
   * @param handle The handle
   */
  void closeHandle(TxLogConnection handle) {
    ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
    event.setConnectionHandle(handle);

    List<ConnectionEventListener> copy = new ArrayList<ConnectionEventListener>(listeners);
    for (ConnectionEventListener cel : copy) {
      cel.connectionClosed(event);
    }
  }
  /**
   * Error handle
   *
   * @param handle The handle
   * @param exception The exception
   */
  void errorHandle(TxLogConnection handle, Exception exception) {
    ConnectionEvent event =
        new ConnectionEvent(this, ConnectionEvent.CONNECTION_ERROR_OCCURRED, exception);
    event.setConnectionHandle(handle);

    List<ConnectionEventListener> copy = new ArrayList<ConnectionEventListener>(listeners);
    for (ConnectionEventListener cel : copy) {
      cel.connectionErrorOccurred(event);
    }
  }
  /**
   * Notifies that an application has closed the connection.
   *
   * <p>Remove and close the UserPoolItem associated with the PoolItem. If it's the last
   * UserPoolItem, move to the idle state.
   */
  public void connectionClosed(ConnectionEvent event) {
    Object handle = event.getConnectionHandle();

    if (!_hasConnectionError && handle == null && _shareHead != null) {
      log.fine(
          L.l(
              "JCA close event '{0}' for {1} did not have a connection handle.  Please notify the JCA resource provider.",
              event, _mConn));
    }

    UserPoolItem ptr = _shareHead;
    UserPoolItem prev = null;

    while (ptr != null) {
      UserPoolItem next = ptr.getShareNext();

      Object userConn = ptr.getUserConnection();

      if (userConn == handle || handle == null) {
        if (prev != null) prev.setShareNext(next);
        else _shareHead = next;

        ptr.close();
      } else prev = ptr;

      ptr = next;
    }

    if (_shareHead == null) {
      toIdle();
      return;
    }
  }
 public void fireConnectionEvent(int event) {
   ConnectionEvent connnectionEvent = new ConnectionEvent(this, event);
   connnectionEvent.setConnectionHandle(this.fileConnection);
   for (ConnectionEventListener listener : this.listeners) {
     switch (event) {
       case LOCAL_TRANSACTION_STARTED:
         listener.localTransactionStarted(connnectionEvent);
         break;
       case LOCAL_TRANSACTION_COMMITTED:
         listener.localTransactionCommitted(connnectionEvent);
         break;
       case LOCAL_TRANSACTION_ROLLEDBACK:
         listener.localTransactionRolledback(connnectionEvent);
         break;
       case CONNECTION_CLOSED:
         listener.connectionClosed(connnectionEvent);
         break;
       default:
         throw new IllegalArgumentException("Unknown event: " + event);
     }
   }
 }