groupmgmt
Class GroupDisseminator

java.lang.Object
  extended bygroupmgmt.GroupDisseminator
Direct Known Subclasses:
SinglePhaseDisseminator

public abstract class GroupDisseminator
extends java.lang.Object

The GroupDisseminator abstract class; Implementations of this class are responsible for coordinating group changes with members of the group, based on connection changes sent by the MemberDetector.

If the constructor is overridden it must call super().
changeGroup() must be implemented to respond to requests from the MemberDetector.
start() and stop() must be implemented.
When the group is actually changed, the implementing class must call fireGroupChangedEvent() to notify any listeners (ie the GroupManager) of the actual change in the group.

Version:
July 2003
Author:
Christine Julien, Tom Elgin

Field Summary
private  boolean active
          Is this MemberDetector active (changing the group and notifying)?
private  java.util.Vector groupChangedListeners
          A list of all GroupChangedListeners that are registered to receive GroupChangedEvents from this GroupDisseminator.
 
Constructor Summary
GroupDisseminator()
          Constructor.
 
Method Summary
(package private)  void activate()
          The GroupManager calls this when we should activate the Disseminator.
 void addGroupChangedListener(GroupChangedListener listener)
          Registers a GroupChangedListener to receive all GroupChangedEvents generated by this GroupDisseminator.
(package private)  boolean attemptChangeGroup(Member[] arriving, Member[] departing)
          Called by MemberDetector when it finds a change in connections.
abstract  void changeGroup(Member[] arriving, Member[] departing)
          Change the configuration of the current group.
(package private)  void deactivate()
          The GroupManager calls this when we should deactivate the disseminator.
protected  void fireGroupChangedEvent(GroupChangedEvent event)
          Sends a GroupChangedEvent to all registered listeners.
 boolean isActive()
          Check if this GroupDisseminator is active.
 void removeGroupChangedListener(GroupChangedListener listener)
          Unregisters a GroupChangedListener, stops sending GroupChangedEvents to the listener.
protected abstract  void start()
          Start responding to changeGroup messages and fire GroupChangedEvents.
protected abstract  void stop()
          Suspend all activity - stop firing GroupChangedEvents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

groupChangedListeners

private java.util.Vector groupChangedListeners
A list of all GroupChangedListeners that are registered to receive GroupChangedEvents from this GroupDisseminator.


active

private boolean active
Is this MemberDetector active (changing the group and notifying)?

Constructor Detail

GroupDisseminator

public GroupDisseminator()
Constructor.

Method Detail

activate

void activate()
The GroupManager calls this when we should activate the Disseminator. Don't override this method, use start().


deactivate

void deactivate()
The GroupManager calls this when we should deactivate the disseminator. Don't override this method, use stop().


isActive

public boolean isActive()
Check if this GroupDisseminator is active.

Returns:
Whether the GroupDisseminator is active or not.

start

protected abstract void start()
Start responding to changeGroup messages and fire GroupChangedEvents. (May also start listening for network messages from members) This method is called after GroupManager.connect() is called.


stop

protected abstract void stop()
Suspend all activity - stop firing GroupChangedEvents. This method is called after GroupManager.disconnect() is called.


attemptChangeGroup

boolean attemptChangeGroup(Member[] arriving,
                           Member[] departing)
Called by MemberDetector when it finds a change in connections. Calls changeGroup in the implementing class if the Disseminator is active.

Parameters:
arriving - The Member(s) we are newly connected to.
departing - The Member(s) we are no longer connected to.
Returns:
Whether or not the changeGroup was processed.

changeGroup

public abstract void changeGroup(Member[] arriving,
                                 Member[] departing)
Change the configuration of the current group. Should inform the GroupManager of any changes to the group via a GroupChangedEvent.

Parameters:
arriving - The Member(s) we are newly connected to.
departing - The Member(s) we are no longer connected to.

addGroupChangedListener

public void addGroupChangedListener(GroupChangedListener listener)
Registers a GroupChangedListener to receive all GroupChangedEvents generated by this GroupDisseminator.

Parameters:
listener - The GroupChangedListener to receive events.

removeGroupChangedListener

public void removeGroupChangedListener(GroupChangedListener listener)
Unregisters a GroupChangedListener, stops sending GroupChangedEvents to the listener.

Parameters:
listener - The GroupChangedListener to stop receiving events.

fireGroupChangedEvent

protected void fireGroupChangedEvent(GroupChangedEvent event)
Sends a GroupChangedEvent to all registered listeners. Called by the implementing class when the group changes.

Parameters:
event - The GroupChangedEvent to send.