org.atmosphere.plugin.jgroups
Class JGroupsChannel

java.lang.Object
  extended by org.jgroups.ReceiverAdapter
      extended by org.atmosphere.plugin.jgroups.JGroupsChannel
All Implemented Interfaces:
org.jgroups.MembershipListener, org.jgroups.MessageListener, org.jgroups.Receiver

public class JGroupsChannel
extends org.jgroups.ReceiverAdapter

JGroupsChannel establishes a connection to a JGroups cluster. It sends/receives over that and forwards the received messages to the appropriate Broadcaster on its node. Best practice would have only 1 of these per Atmosphere application. Each JGroupsFilter instance has a reference to the singleton JGroupsChannel object and registers its broadcaster via the addBroadcaster() method.

Author:
westraj

Constructor Summary
JGroupsChannel(org.jgroups.JChannel jchannel, String clusterName)
          Constructor
 
Method Summary
 void addBroadcaster(org.atmosphere.cpr.Broadcaster broadcaster)
          Adds/replaces the broadcaster to the JGroupsChannel
 void destroy()
          Shutdown the cluster.
 void init()
          Connect to the cluster
 void receive(org.jgroups.Message jgroupMessage)
          
 void removeBroadcaster(org.atmosphere.cpr.Broadcaster broadcaster)
          Removes the broadcaster from the JGroupsChannel
 void send(String topic, Object message)
          Called from a ClusterBroadcastFilter filter() method to send the message over to other Atmosphere cluster nodes
 
Methods inherited from class org.jgroups.ReceiverAdapter
block, getState, setState, suspect, unblock, viewAccepted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JGroupsChannel

public JGroupsChannel(org.jgroups.JChannel jchannel,
                      String clusterName)
Constructor

Parameters:
jchannel - unconnected JGroups JChannel object
clusterName - name of the group to connect the JChannel to
Method Detail

init

public void init()
          throws Exception
Connect to the cluster

Throws:
Exception

destroy

public void destroy()
Shutdown the cluster.


receive

public void receive(org.jgroups.Message jgroupMessage)

Specified by:
receive in interface org.jgroups.MessageListener
Overrides:
receive in class org.jgroups.ReceiverAdapter

send

public void send(String topic,
                 Object message)
Called from a ClusterBroadcastFilter filter() method to send the message over to other Atmosphere cluster nodes

Parameters:
topic -
message -

addBroadcaster

public void addBroadcaster(org.atmosphere.cpr.Broadcaster broadcaster)
Adds/replaces the broadcaster to the JGroupsChannel

Parameters:
broadcaster -

removeBroadcaster

public void removeBroadcaster(org.atmosphere.cpr.Broadcaster broadcaster)
Removes the broadcaster from the JGroupsChannel

Parameters:
broadcaster -


Copyright © 2013. All Rights Reserved.