com.echomine.jabber
Class MessageRequestQueue

java.lang.Object
  extended by com.echomine.jabber.MessageRequestQueue

public class MessageRequestQueue
extends java.lang.Object

this class stores messages that are to be sent out. If the message is waiting for a reply message, it will put it into the outstanding queue. Everything is synchronized for multithreading safety. The queue must be "start()ed" first and shutdown() afterwards.


Constructor Summary
MessageRequestQueue()
           
 
Method Summary
 void addMessage(JabberMessage msg)
          adds a message to send to the end of the queue
 void clear()
          clear all the messages in the queues
 JabberMessage getMessageForReply(java.lang.String id)
          checks if the there is an outstanding message waiting for a reply.
 void shutdown()
          wake up all the waiting threads possibly because someone is doing some shutdown work
 void start()
          resets all states back to the default
 JabberMessage waitForMessage()
          this will go into a wait state, waiting for any incoming messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageRequestQueue

public MessageRequestQueue()
Method Detail

addMessage

public void addMessage(JabberMessage msg)
adds a message to send to the end of the queue


waitForMessage

public JabberMessage waitForMessage()
this will go into a wait state, waiting for any incoming messages. Once a message comes in and is retrieved, it will check to see if the message requires a reply.

Returns:
the jabber message or null if no message

shutdown

public void shutdown()
wake up all the waiting threads possibly because someone is doing some shutdown work


getMessageForReply

public JabberMessage getMessageForReply(java.lang.String id)
checks if the there is an outstanding message waiting for a reply. If so, it will retrieve the original message AND remove it from the outstanding message queue.

Parameters:
id - the unique ID of the message
Returns:
the original message, null if no message corresponds to the specified ID

clear

public void clear()
clear all the messages in the queues


start

public void start()
resets all states back to the default



Copyright © 2001-2005 Echomine. All Rights Reserved.