|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jgroups.blocks.MessageListenerAdapter
public class MessageListenerAdapter
This class provides multiplexing possibilities for MessageListener
instances. Usually, we have more than one instance willing to listen to
incoming messages, but only one that can produce state for group.
PullPushAdapter
allows only one instance of MessageListener
to be registered for message notification. With help of this class you
can overcome this limitation.
Field Summary | |
---|---|
protected java.util.HashSet |
messageListeners
|
protected MessageListener[] |
messageListenersCache
|
protected MessageListener |
stateListener
|
Constructor Summary | |
---|---|
MessageListenerAdapter()
Create default instance of this class. |
|
MessageListenerAdapter(MessageListener mainListener)
Create instance of this class. |
Method Summary | |
---|---|
void |
addMessageListener(MessageListener listener)
Add message listener to this adapter. |
byte[] |
getState()
Get state from state listener if present. |
void |
getState(java.io.OutputStream ostream)
Allows an application to write a state through a provided OutputStream. |
byte[] |
getState(java.lang.String state_id)
Allows an application to provide a partial state as a byte array |
void |
getState(java.lang.String state_id,
java.io.OutputStream ostream)
Allows an application to write a partial state through a provided OutputStream. |
void |
receive(Message msg)
Receive message from group. |
void |
removeMessageListener(MessageListener listener)
Remove message listener from this adapter. |
void |
setState(byte[] state)
Set state of ths group. |
void |
setState(java.io.InputStream istream)
Allows an application to read a state through a provided InputStream. |
void |
setState(java.lang.String state_id,
byte[] state)
Allows an application to read a partial state indicated by state_id from a given state byte array parameter. |
void |
setState(java.lang.String state_id,
java.io.InputStream istream)
Allows an application to read a partial state through a provided InputStream. |
void |
setStateListener(MessageListener listener)
Register listener for state notification events. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected MessageListener stateListener
protected final java.util.HashSet messageListeners
protected MessageListener[] messageListenersCache
Constructor Detail |
---|
public MessageListenerAdapter()
addMessageListener(MessageListener)
or
removeMessageListener(MessageListener)
to add or remove message
listeners, and setStateListener(MessageListener)
to set listener
that will participate in state transfer.
public MessageListenerAdapter(MessageListener mainListener)
mainListener
is a main
listener instance that received message notifications and can get and
set group state.
mainListener
- instance of MessageListener
that will
provide state messages.Method Detail |
---|
public byte[] getState()
getState
in interface MessageListener
null
if no state
listeners were registered.public byte[] getState(java.lang.String state_id)
ExtendedMessageListener
getState
in interface ExtendedMessageListener
state_id
- id of the partial state requested
public void getState(java.io.OutputStream ostream)
ExtendedMessageListener
getState
in interface ExtendedMessageListener
ostream
- the OutputStreamOutputStream.close()
public void getState(java.lang.String state_id, java.io.OutputStream ostream)
ExtendedMessageListener
getState
in interface ExtendedMessageListener
state_id
- id of the partial state requestedostream
- the OutputStreamOutputStream.close()
public void receive(Message msg)
receive
in interface MessageListener
msg
- message to distribute within message listeners.public void setState(byte[] state)
setState
in interface MessageListener
public void setState(java.lang.String state_id, byte[] state)
ExtendedMessageListener
setState
in interface ExtendedMessageListener
state_id
- id of the partial state requestedstate
- partial state for the given state_idpublic void setState(java.io.InputStream istream)
ExtendedMessageListener
setState
in interface ExtendedMessageListener
istream
- the InputStreamInputStream.close()
public void setState(java.lang.String state_id, java.io.InputStream istream)
ExtendedMessageListener
setState
in interface ExtendedMessageListener
state_id
- id of the partial state requestedistream
- the InputStreamInputStream.close()
public final void addMessageListener(MessageListener listener)
listener
for message notification.
Note, state notification will not be used.
public void removeMessageListener(MessageListener listener)
listener
from message notification.
public void setStateListener(MessageListener listener)
listener
for state notification events. There can
be only one state listener per adapter.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |