else
} else if (ackMode == Session.CLIENT_ACKNOWLEDGE) {        List cancels = new ArrayList();  for(Iterator i = state.getClientAckList().iterator(); i.hasNext(); )
   public Object handleClosing(Invocation invocation) throws Throwable   {      MethodInvocation mi = (MethodInvocation)invocation;      SessionState state = getState(invocation);      SessionDelegate del = (SessionDelegate)mi.getTargetObject();            int ackMode = state.getAcknowledgeMode();      // select eligible acknowledgments      List acks = new ArrayList();      List cancels = new ArrayList();      for(Iterator i = state.getToAck().iterator(); i.hasNext(); )      {         DeliveryInfo ack = (DeliveryInfo)i.next();         if (ackMode == Session.AUTO_ACKNOWLEDGE ||             ackMode == Session.DUPS_OK_ACKNOWLEDGE)         {            acks.add(new DefaultAck(ack.getMessageProxy().getDeliveryId()));                     }         else         {            Cancel cancel = new Cancel(ack.getMessageProxy().getDeliveryId(), ack.getMessageProxy().getDeliveryCount());            cancels.add(cancel);         }         i.remove();      }            // On closing we acknowlege any AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE, since the session      // might have closed before the onMessage had finished executing.      // We cancel any client ack or transactional, we do this explicitly so we can pass the updated      // delivery count information from client to server. We could just do this on the server but      // we would lose delivery count info.      if (!acks.isEmpty())      {         del.acknowledgeBatch(acks);      }      if (!cancels.isEmpty())      {         log.info("Calling canceldeliveries: " + cancels.size());         del.cancelDeliveries(cancels);      }      return invocation.invokeNext();   }