/**
  * 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);
    }
  }
  /** {@inheritDoc} */
  public void rollback() throws ResourceException {
    log.trace("rollback()");

    txState.append(TX_LOCAL_ROLLBACK);

    ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK);

    for (ConnectionEventListener cel : listeners) {
      cel.localTransactionRolledback(ce);
    }
  }
  /** {@inheritDoc} */
  public void commit() throws ResourceException {
    log.trace("commit()");

    txState.append(TX_LOCAL_COMMIT);

    ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.LOCAL_TRANSACTION_COMMITTED);

    for (ConnectionEventListener cel : listeners) {
      cel.localTransactionCommitted(ce);
    }
  }
  /** {@inheritDoc} */
  public void begin() throws ResourceException {
    log.trace("begin()");

    txState.append(TX_LOCAL_BEGIN);

    ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.LOCAL_TRANSACTION_STARTED);

    for (ConnectionEventListener cel : listeners) {
      cel.localTransactionStarted(ce);
    }
  }
 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);
     }
   }
 }