示例#1
0
  /** Notification that a ContentResponse was given. */
  public void handleContentResponse(ContentResponse responseMsg) {
    URN urn = responseMsg.getURN();
    // Only process if we requested this msg.
    // (Don't allow arbitrary responses to be processed)
    if (urn != null && REQUESTED.remove(urn)) {
      ContentResponseData response = new ContentResponseData(responseMsg);
      CACHE.addResponse(urn, response);
      if (LOG.isDebugEnabled()) LOG.debug("Adding response (" + response + ") for URN: " + urn);

      Collection<Responder> responders = OBSERVERS.remove(urn);
      if (responders != null) {
        removeResponders(responders);
        for (Responder next : responders) next.observer.handleResponse(next.urn, response);
      }
    } else if (LOG.isWarnEnabled()) {
      if (urn == null) {
        LOG.debug("No URN in response: " + responseMsg);
      } else {
        LOG.debug("Didn't request URN: " + urn + ", msg: " + responseMsg);
      }
    }
  }