com.sun.sgs.impl.io
Class CompleteMessageFilter

java.lang.Object
  extended by com.sun.sgs.impl.io.CompleteMessageFilter

 class CompleteMessageFilter
extends Object

This filter guarantees that only complete messages are delivered to its FilterListener.

It prepends the message length on sending, and reads the length of each message on receiving. If the message is partial, the filter will hold the partial message until the rest of the message is received, even if the message spans multiple calls to filterReceive.

The filterReceive portion of this filter is not thread-safe since it retains state information about partial messages. For this reason, each source of data should have its own instance, and filterReceive should be called by only one thread at a time. filterSend, however, is thread-safe.


Constructor Summary
CompleteMessageFilter()
          Default constructor.
 
Method Summary
(package private)  void filterReceive(FilterListener listener, org.apache.mina.common.ByteBuffer buf)
          Processes network data of arbitrary length and dispatches zero or more complete messages to the given listener.
(package private)  void filterSend(FilterListener listener, byte[] message)
          Prepends the length of the given byte array as a 2-byte short in network byte-order, and passes the result to the sendUnfiltered method of the given listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompleteMessageFilter

CompleteMessageFilter()
Default constructor.

Method Detail

filterReceive

void filterReceive(FilterListener listener,
                   org.apache.mina.common.ByteBuffer buf)
Processes network data of arbitrary length and dispatches zero or more complete messages to the given listener. If a partial message remains, it is buffered until more data is received.

Parameters:
listener - the FilterListener to receive complete messages
buf - the data to filter and optionally deliver to the FilterListener

filterSend

void filterSend(FilterListener listener,
                byte[] message)
Prepends the length of the given byte array as a 2-byte short in network byte-order, and passes the result to the sendUnfiltered method of the given listener.

Parameters:
listener - the FilterListener on which to send the data
message - the data to filter and forward to the listener

Project Darkstar, Version 0.9.11.4
2013-07-29 21:59:53

Copyright © 2007-2013 Sun Microsystems, Inc. All rights reserved