Project JXTA

net.jxta.impl.endpoint
Class EndpointReceiveQueue

java.lang.Object
  |
  +--net.jxta.impl.endpoint.EndpointReceiveQueue

public class EndpointReceiveQueue
extends java.lang.Object

A TransportMessageQueue is the queing mechanism to queue TransportMessage between the various components of the Juxtapose Transport layer. Messages can be pushed onto it in a non blocking way. However receiving messages can be done by unblocking poll or a blocking waitForMessage.

Since:
JXTA 1.0

Field Summary
static int Max_Messages
           
 
Constructor Summary
EndpointReceiveQueue()
          Default constructor
EndpointReceiveQueue(boolean n)
          Default constructor
 
Method Summary
 void close()
          close it
 void doClose()
          cleanly close the queue
 int getMaxNbOfMessages()
           
 net.jxta.endpoint.Message next()
          return next message in the queue
 net.jxta.endpoint.Message poll(int timeOut)
          Gets a TransportMessage from the queue.
 void push(net.jxta.endpoint.Message message)
          Push a TransportMessage onto the queue.
 void setMaxNbOfMessages(int n)
           
 net.jxta.endpoint.Message waitForMessage()
          Wait until there is only one TransportMessage in the queue, and return it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Max_Messages

public static final int Max_Messages
Constructor Detail

EndpointReceiveQueue

public EndpointReceiveQueue()
Default constructor

EndpointReceiveQueue

public EndpointReceiveQueue(boolean n)
Default constructor
Parameters:
notify - when true push does not thread.notify therefore wait is intrrupted when a msg is received
Method Detail

push

public void push(net.jxta.endpoint.Message message)
Push a TransportMessage onto the queue.
Parameters:
message - TransportMessage to be pushed onto the queue

poll

public net.jxta.endpoint.Message poll(int timeOut)
Gets a TransportMessage from the queue. If the queue is emply, throws NoTransportMessageException.
Parameters:
timeOut - in ms
Returns:
a TransportMessage

next

public net.jxta.endpoint.Message next()
return next message in the queue
Returns:
Message, null if the queue is empty or closing

waitForMessage

public net.jxta.endpoint.Message waitForMessage()
Wait until there is only one TransportMessage in the queue, and return it.
Returns:
a TransportMessage

doClose

public void doClose()
cleanly close the queue

close

public void close()
close it

getMaxNbOfMessages

public int getMaxNbOfMessages()

setMaxNbOfMessages

public void setMaxNbOfMessages(int n)

Project JXTA