This class implements a message store that can be used to provide a blocking
mechanism for transport protocol messages.
breakWaiting
public void breakWaiting()
close
public void close()
Closes the store. This will cause any blocking operations on the message
store to return.
getMessage
public SshMessage getMessage(int messageId)
throws MessageStoreEOFException,
InterruptedException
Get a message from the store. This method will block until a message
with an id matching the supplied id arrives, or the message store
closes. The message is removed from the store.
messageId
- the id of the message requried
- the next available message with the id supplied
getMessage
public SshMessage getMessage(int messageId,
int timeout)
throws MessageStoreEOFException,
MessageNotAvailableException,
InterruptedException
Get a message from the store. This method will block until a message
with an id matching the supplied id arrives,the specified timeout is
reached or the message store closes. The message will be removed from
the store.
messageId
- the id of the message requriedtimeout
- the maximum number of milliseconds to block before
returning.
- the next available message with the id supplied
getMessage
public SshMessage getMessage(int[] messageIdFilter)
throws MessageStoreEOFException,
InterruptedException
Get a message from the store. This method will block until a message
with an id matching the supplied filter arrives, or the message store
closes. The message is removed from the store.
messageIdFilter
- an array of message ids that are acceptable
- the next available message
getMessage
public SshMessage getMessage(int[] messageIdFilter,
int timeout)
throws MessageStoreEOFException,
MessageNotAvailableException,
InterruptedException
Get a message from the store. This method will block until a message
with an id matching the supplied filter arrives, the specified timeout
is reached or the message store closes. The message is removed from the
store.
messageIdFilter
- an array of message ids that are acceptable.timeout
- the maximum number of milliseconds to block before
returning.
- the next available message
getRegisteredMessageIds
public Object[] getRegisteredMessageIds()
Returns an Object array (Integers) of the registered message ids.
- the registered message id array
hasMessages
public boolean hasMessages()
Evaluate whether the store has any messages.
- true if messages exist, otherwise false
isClosed
public boolean isClosed()
Evaluate whether the message store is closed.
isRegisteredMessage
public boolean isRegisteredMessage(Integer messageId)
Determines if the message id is a registered message of this store.
messageId
- the message id
- true if the message id is registered, otherwise false
nextMessage
public SshMessage nextMessage()
throws MessageStoreEOFException,
InterruptedException
Get the next message in the store or wait until a new message arrives.
The message is removed from the store.
- the next available message.
peekMessage
public SshMessage peekMessage(int messageId,
int timeout)
throws MessageStoreEOFException,
MessageNotAvailableException,
InterruptedException
Get a message from the store without removing it, only blocking for the
number of milliseconds specified in the timeout field.
messageId
- the acceptable message idtimeout
- the timeout setting in milliseconds
- the next available message
peekMessage
public SshMessage peekMessage(int[] messageIdFilter)
throws MessageStoreEOFException,
MessageNotAvailableException,
InterruptedException
Get a message from the store without removing or blocking if the message
does not exist.
messageIdFilter
- the id of the message requried
- the next available message with the id supplied
peekMessage
public SshMessage peekMessage(int[] messageIdFilter,
int timeout)
throws MessageStoreEOFException,
MessageNotAvailableException,
InterruptedException
Get a message from the store without removing it; only blocking for the
number of milliseconds specified in the timeout field. If timeout is
zero, the method will not block.
messageIdFilter
- an array of acceptable message idstimeout
- the number of milliseconds to wait
- the next available message of the acceptable message ids
registerMessage
public void registerMessage(int messageId,
Class implementor)
Register a message implementation with the store.
messageId
- the id of the messageimplementor
- the class of the implementation
removeMessage
public void removeMessage(SshMessage msg)
Removes a message from the message store.
msg
- the message to remove
size
public int size()
Returns the number of messages contained within this message store.