Project JXTA

net.jxta.impl.shell
Class ShellMessageQueue

java.lang.Object
  |
  +--net.jxta.impl.shell.ShellMessageQueue

public class ShellMessageQueue
extends java.lang.Object

Shell message queue for the Shell Input and Output PipeService

Since:
JXTA 1.0

Field Summary
static int Max_Messages
           
 
Constructor Summary
ShellMessageQueue()
          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

ShellMessageQueue

public ShellMessageQueue()
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