Example #1
0
  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;
  }
Example #2
0
  public synchronized boolean recycleConnection(String connectionID) {

    ChannelHolder c = getConnectionByID(connectionID);

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

    c.setPipedChannel(null);

    freeDataChannels.put(connectionID, c);

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