Project JXTA

net.jxta.impl.endpoint
Class EndpointReceiveQueue

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

public class EndpointReceiveQueue
extends java.lang.Object

A EndpointMessageQueue is the queing mechanism to queue Message 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 nonblocking poll or a blocking waitForMessage.

Since:
JXTA 1.0

Field Summary
static int Max_Messages
           
 
Constructor Summary
EndpointReceiveQueue()
          Default constructor
EndpointReceiveQueue(int size)
          Default constructor
 
Method Summary
 void close()
          close it
 int getMaxNbOfMessages()
          how many messages will fit in this queue
 boolean isClosed()
          Atomically return whether or not this queue has been closed.
 net.jxta.endpoint.Message next()
          Return next message in the queue if there is one.
 net.jxta.endpoint.Message poll(long timeOut)
          Gets a Message from the queue.
 void push(net.jxta.endpoint.Message message)
          Push a TransportMessage onto the queue.
 void setMaxNbOfMessages(int maxMsgs)
          Set how many messages this queue may store.
 net.jxta.endpoint.Message waitForMessage()
          Wait until there is a Message 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(int size)
Default constructor
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

next

public net.jxta.endpoint.Message next()
Return next message in the queue if there is one.
Returns:
Message, null if the queue is empty

poll

public net.jxta.endpoint.Message poll(long timeOut)
                               throws java.lang.InterruptedException
Gets a Message from the queue. If no Message is immediately available, then wait the specified amount of time. Per Java convention, a timeout of zero (0) means wait an infinite amount of time.
Parameters:
timeOut - in ms
Returns:
a Message

waitForMessage

public net.jxta.endpoint.Message waitForMessage()
                                         throws java.lang.InterruptedException
Wait until there is a Message in the queue, and return it. Returns null if the queue has been closed.
Returns:
a Message

isClosed

public boolean isClosed()
Atomically return whether or not this queue has been closed.
Returns:
boolean indicating whether this queue has been closed.

close

public void close()
close it

getMaxNbOfMessages

public int getMaxNbOfMessages()
how many messages will fit in this queue
Returns:
int indicating how many messages will fit in the queue.

setMaxNbOfMessages

public void setMaxNbOfMessages(int maxMsgs)
Set how many messages this queue may store. Note that if there are more messages already in the queue than the specified amount then the queue will retain its current capacity.
Parameters:
maxMsgs - The number of messages which the queue must be able to store.

Project JXTA