|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sshtools.j2ssh.transport.SshMessageStore
public final class SshMessageStore
This class implements a message store that can be used to provide a blocking mechanism for transport protocol messages.
Constructor Summary | |
---|---|
SshMessageStore()
Contructs the message store. |
Method Summary | |
---|---|
void |
addMessage(byte[] msgdata)
Adds a raw message to the store and processes the data into a registered message. |
void |
addMessage(SshMessage msg)
Add a formed message to the store. |
void |
addMessageListener(SshMessageListener listener)
|
void |
breakWaiting()
|
void |
close()
Closes the store. |
SshMessage |
createMessage(byte[] msgdata)
Create a formed message from raw message data. |
SshMessage |
getMessage(int messageId)
Get a message from the store. |
SshMessage |
getMessage(int[] messageIdFilter)
Get a message from the store. |
SshMessage |
getMessage(int[] messageIdFilter,
int timeout)
Get a message from the store. |
SshMessage |
getMessage(int messageId,
int timeout)
Get a message from the store. |
java.lang.Object[] |
getRegisteredMessageIds()
Returns an Object array (Integers) of the registered message ids. |
boolean |
hasMessages()
Evaluate whether the store has any messages. |
boolean |
isClosed()
Evaluate whether the message store is closed. |
boolean |
isRegisteredMessage(java.lang.Integer messageId)
Determines if the message id is a registered message of this store. |
SshMessage |
nextMessage()
Get the next message in the store or wait until a new message arrives. |
SshMessage |
peekMessage(int messageId)
Get a message from the store without removing it. |
SshMessage |
peekMessage(int[] messageIdFilter)
Get a message from the store without removing or blocking if the message does not exist. |
SshMessage |
peekMessage(int[] messageIdFilter,
int timeout)
Get a message from the store without removing it; only blocking for the number of milliseconds specified in the timeout field. |
SshMessage |
peekMessage(int messageId,
int timeout)
Get a message from the store without removing it, only blocking for the number of milliseconds specified in the timeout field. |
void |
registerMessage(int messageId,
java.lang.Class implementor)
Register a message implementation with the store. |
void |
removeMessage(SshMessage msg)
Removes a message from the message store. |
int |
size()
Returns the number of messages contained within this message store. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SshMessageStore()
Contructs the message store.
Method Detail |
---|
public boolean isClosed()
Evaluate whether the message store is closed.
public void addMessageListener(SshMessageListener listener)
public SshMessage getMessage(int[] messageIdFilter) throws MessageStoreEOFException, java.lang.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
MessageStoreEOFException
- if the message store is closed
java.lang.InterruptedException
- if the thread was interruptedpublic SshMessage getMessage(int[] messageIdFilter, int timeout) throws MessageStoreEOFException, MessageNotAvailableException, java.lang.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.
MessageStoreEOFException
- if the message store is closed
MessageNotAvailableException
- if the message is not available
after a timeout
java.lang.InterruptedException
- if the thread is interruptedpublic SshMessage getMessage(int messageId) throws MessageStoreEOFException, java.lang.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
MessageStoreEOFException
- if the message store closed
java.lang.InterruptedException
- if the thread is interruptedpublic SshMessage getMessage(int messageId, int timeout) throws MessageStoreEOFException, MessageNotAvailableException, java.lang.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.
MessageStoreEOFException
- if the message store closed
java.lang.InterruptedException
- if the thread is interrupted
java.lang.InterruptedException
MessageNotAvailableException
public boolean hasMessages()
Evaluate whether the store has any messages.
public int size()
Returns the number of messages contained within this message store.
public boolean isRegisteredMessage(java.lang.Integer messageId)
Determines if the message id is a registered message of this store.
messageId
- the message id
public void addMessage(byte[] msgdata) throws MessageNotRegisteredException, InvalidMessageException
Adds a raw message to the store and processes the data into a registered message.
msgdata
- the raw message data to process
MessageNotRegisteredException
- if the message id of the raw data
is not a registered message
InvalidMessageException
- if the message is invalidpublic void addMessage(SshMessage msg) throws MessageNotRegisteredException
Add a formed message to the store.
msg
- the message to add to the store
MessageNotRegisteredException
- if the message type is not
registered with the storepublic void close()
Closes the store. This will cause any blocking operations on the message store to return.
public SshMessage nextMessage() throws MessageStoreEOFException, java.lang.InterruptedException
Get the next message in the store or wait until a new message arrives. The message is removed from the store.
MessageStoreEOFException
- if the message store is closed
java.lang.InterruptedException
- if the thread is interruptedpublic void breakWaiting()
public SshMessage peekMessage(int[] messageIdFilter) throws MessageStoreEOFException, MessageNotAvailableException, java.lang.InterruptedException
Get a message from the store without removing or blocking if the message does not exist.
messageIdFilter
- the id of the message requried
MessageStoreEOFException
- if the message store closed
MessageNotAvailableException
- if the message is not available
java.lang.InterruptedException
- if the thread is interruptedpublic SshMessage peekMessage(int[] messageIdFilter, int timeout) throws MessageStoreEOFException, MessageNotAvailableException, java.lang.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
MessageStoreEOFException
- if the message store is closed
MessageNotAvailableException
- if the message is not available
java.lang.InterruptedException
- if the thread is interruptedpublic SshMessage peekMessage(int messageId) throws MessageStoreEOFException, MessageNotAvailableException, java.lang.InterruptedException
Get a message from the store without removing it.
messageId
- the acceptable message id
MessageStoreEOFException
- if the message store is closed.
MessageNotAvailableException
- if the message is not available.
java.lang.InterruptedException
- if the thread is interruptedpublic void removeMessage(SshMessage msg)
Removes a message from the message store.
msg
- the message to removepublic SshMessage peekMessage(int messageId, int timeout) throws MessageStoreEOFException, MessageNotAvailableException, java.lang.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
MessageStoreEOFException
- if the message store is closed
MessageNotAvailableException
- if the message is not available
java.lang.InterruptedException
- if the thread is interruptedpublic void registerMessage(int messageId, java.lang.Class implementor)
Register a message implementation with the store.
messageId
- the id of the messageimplementor
- the class of the implementationpublic java.lang.Object[] getRegisteredMessageIds()
Returns an Object array (Integers) of the registered message ids.
public SshMessage createMessage(byte[] msgdata) throws MessageNotRegisteredException, InvalidMessageException
Create a formed message from raw message data.
msgdata
- the raw message data
MessageNotRegisteredException
- if the message is not a registered
message
InvalidMessageException
- if the message is invalid
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |