Exemplo n.º 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;
  }
Exemplo n.º 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;
  }
Exemplo n.º 3
0
 public synchronized boolean notifyConnectionInUse(ChannelHolder connection) {
   return freeDataChannels.remove(connection.getConnectionId()) != null;
 }
Exemplo n.º 4
0
 public void addDataConnection(ChannelHolder channelHolder) {
   String connectionId = channelHolder.getConnectionId();
   allDataChannels.put(connectionId, channelHolder);
   freeDataChannels.put(connectionId, channelHolder);
 }