Example #1
0
  public boolean accept(Packet packet) {
    if (delegate == null) {
      delegate = createFilter();
    }

    return delegate.accept(packet);
  }
  /**
   * Processes a packet to see if it meets the criteria for this packet collector. If so, the packet
   * is added to the result queue.
   *
   * <p>If the result queue's capacity {@link #MAX_PACKETS} is reached, the collector is canceled
   * using the proved {@link CancelHook}.
   *
   * @param packet the packet to process
   * @singleThreaded should only be accessed by the single threaded executer of {@link
   *     de.fu_berlin.inf.dpp.net.business.DispatchThreadContext}
   */
  public void processPacket(Packet packet) {
    if (packet == null) return;

    if (packetFilter == null || packetFilter.accept(packet)) {
      try {
        resultQueue.add(packet);
      } catch (IllegalStateException e) {
        log.warn("Queue has reached capacity, collector canceled.");
        cancel();
      }
    }
  }
 /**
  * Processes a packet to see if it meets the criteria for this packet collector. If so, the packet
  * is added to the result queue.
  *
  * @param packet the packet to process.
  */
 protected synchronized void processPacket(Packet packet) {
   if (packet == null) {
     return;
   }
   if (packetFilter == null || packetFilter.accept(packet)) {
     // If the max number of packets has been reached, remove the oldest
     // one.
     if (resultQueue.size() == maxPackets) {
       resultQueue.removeLast();
     }
     // Add the new packet.
     resultQueue.addFirst(packet);
     // Notify waiting threads a result is available.
     notifyAll();
   }
 }
Example #4
0
 /**
  * Notify and process the packet interceptor if the filter matches the packet.
  *
  * @param packet the packet which will be sent.
  */
 public void notifyListener(Packet packet) {
   if (packetFilter == null || packetFilter.accept(packet)) {
     packetInterceptor.interceptPacket(packet);
   }
 }
Example #5
0
 /**
  * Notify and process the packet listener if the filter matches the packet.
  *
  * @param packet the packet which was sent or received.
  */
 public void notifyListener(Packet packet) {
   if (packetFilter == null || packetFilter.accept(packet)) {
     packetListener.processPacket(packet);
   }
 }
Example #6
0
 private StreamNegotiator determineNegotiator(Packet streamInitiation) {
   return primaryFilter.accept(streamInitiation) ? primaryNegotiator : secondaryNegotiator;
 }