|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.tribe.adapters.PullPushAdapter
Allows a client to be notified when messages have been received instead of having to actively poll the channel for new messages. Typically used in the client role (receive()). This blocks works with any kind of reliable group channel.
Note that message delivery is single threaded and if the message handler hangs, it will block further message delivery. Send() methods are just provided for convenience and wraps calls to the same methods on the channel.
This adapter is inspired from JGroups PullPushAdapter but does not deal with views.
Field Summary | |
protected ReliableGroupChannel |
channel
|
protected MessageListener |
listener
|
protected java.lang.Thread |
readerThread
|
Constructor Summary | |
PullPushAdapter(ReliableGroupChannel channel,
MessageListener listener)
Creates a new PullPushAdapter on a channel and use the
provided listener for callbacks on message reception. |
Method Summary | |
ReliableGroupChannel |
getChannel()
Return the underlying channel. |
void |
run()
Reentrant run(): message reception is serialized, then the listener is notified of the message reception |
java.util.ArrayList |
send(java.io.Serializable msg)
Sends the given message to all members of the group. |
java.util.ArrayList |
send(java.io.Serializable msg,
java.util.ArrayList members)
Sends a message to a subset of group members. |
java.util.ArrayList |
send(java.io.Serializable msg,
GroupIdentifier gid,
java.util.ArrayList members)
Sends a message to members of group gid without being necessary member of the group. |
void |
start()
Start a new thread |
void |
stop()
Stop the current adapter and its associated thread. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected ReliableGroupChannel channel
protected MessageListener listener
protected java.lang.Thread readerThread
Constructor Detail |
public PullPushAdapter(ReliableGroupChannel channel, MessageListener listener)
PullPushAdapter
on a channel and use the
provided listener for callbacks on message reception.
channel
- channel to read messages fromlistener
- MessageListener for callbacksMethod Detail |
public ReliableGroupChannel getChannel()
public void start()
public void stop()
public java.util.ArrayList send(java.io.Serializable msg) throws ChannelException, NotConnectedException
msg
- message to send
ArrayList
of Members who failed, or null if all
members received successfully the message.
ChannelException
- if an error occurs
NotConnectedException
- if the channel is not connected to any groupReliableGroupChannel.send(Serializable)
public java.util.ArrayList send(java.io.Serializable msg, java.util.ArrayList members) throws ChannelException, NotConnectedException
msg
- message to sendmembers
- ArrayList
of Member
that are
all part of the group
ArrayList
of Members who failed, or null if all
members received successfully the message.
ChannelException
- if an error occurs
NotConnectedException
- if the channel is not connected to any groupReliableGroupChannel.send(Serializable, ArrayList)
public java.util.ArrayList send(java.io.Serializable msg, GroupIdentifier gid, java.util.ArrayList members) throws ChannelException, NotConnectedException
msg
- message to sendmembers
- ArrayList
of Member
that are
all part of the group
ArrayList
of Members who failed, or null if all
members received successfully the message.
ChannelException
- if an error occurs
NotConnectedException
- if the channel is not connected to any groupReliableGroupChannel.send(Serializable, GroupIdentifier, ArrayList)
public void run()
run
in interface java.lang.Runnable
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |