public synchronized ChannelHolder rentConnection() {

    Collection<ChannelHolder> values = freeDataChannels.values();
    if (values.isEmpty()) {
      return null;
    }
    ChannelHolder theOne = values.iterator().next();
    freeDataChannels.remove(theOne.getConnectionId());
    return theOne;
  }
  public synchronized boolean recycleConnection(String connectionID) {

    ChannelHolder c = getConnectionByID(connectionID);

    if (c == null) {
      return false;
    }

    c.setPipedChannel(null);

    freeDataChannels.put(connectionID, c);

    return true;
  }
 public synchronized boolean notifyConnectionInUse(ChannelHolder connection) {
   return freeDataChannels.remove(connection.getConnectionId()) != null;
 }
 public void addDataConnection(ChannelHolder channelHolder) {
   String connectionId = channelHolder.getConnectionId();
   allDataChannels.put(connectionId, channelHolder);
   freeDataChannels.put(connectionId, channelHolder);
 }