org.jgroups.demos.wb

Class Whiteboard

Implemented Interfaces:
ActionListener, ComponentListener, FocusListener, MembershipListener, MessageListener

public class Whiteboard
extends Applet
implements ActionListener, MessageListener, MembershipListener, ComponentListener, FocusListener

Shared whiteboard: members are represented by rectangles that contain their names and the OS/arch of the machine they are working on. The boxes can be moved by anyone and by clicking on them, messages can be sent to specific or all members. Whiteboard is both an application and an applet.
Author:
Bela Ban

Field Summary

RpcDispatcher
disp
static String
groupname

Constructor Summary

Whiteboard()
Whiteboard(String properties)

Method Summary

void
actionPerformed(ActionEvent e)
void
addNode(String lbl, Address addr, int xloc, int yloc)
void
block()
Called whenever the member needs to stop sending messages.
void
componentHidden(ComponentEvent e)
void
componentMoved(ComponentEvent e)
void
componentResized(ComponentEvent e)
void
componentShown(ComponentEvent e)
void
destroy()
void
displayMessage(String sender, String msg)
void
focusGained(FocusEvent e)
void
focusLost(FocusEvent e)
byte[]
getState()
Answers the group state; e.g., when joining.
void
init()
static void
main(String[] args)
void
moveNode(Node n)
void
receive(Message m)
Called when a message is received.
void
removeNode(Object addr)
void
repaint()
void
setState(byte[] new_state)
Sets the group state; e.g., when joining.
void
suspect(Address obj)
Called whenever a member is suspected of having crashed, but has not yet been excluded.
void
viewAccepted(View v)
Called when a change in membership has occurred.

Field Details

disp

public RpcDispatcher disp

groupname

public static final String groupname

Constructor Details

Whiteboard

public Whiteboard()

Whiteboard

public Whiteboard(String properties)

Method Details

actionPerformed

public void actionPerformed(ActionEvent e)

addNode

public void addNode(String lbl,
                    Address addr,
                    int xloc,
                    int yloc)

block

public void block()
Called whenever the member needs to stop sending messages. When the next view is received (viewAccepted()), the member can resume sending messages. If a member does not comply, the message(s) sent between a block() and a matching viewAccepted() callback will probably be delivered in the next view. The block() callback is only needed by the Virtual Synchrony suite of protocols (FLUSH protocol)3.2, otherwise it will never be invoked.
Specified by:
block in interface MembershipListener

componentHidden

public void componentHidden(ComponentEvent e)

componentMoved

public void componentMoved(ComponentEvent e)

componentResized

public void componentResized(ComponentEvent e)

componentShown

public void componentShown(ComponentEvent e)

destroy

public void destroy()

displayMessage

public void displayMessage(String sender,
                           String msg)

focusGained

public void focusGained(FocusEvent e)

focusLost

public void focusLost(FocusEvent e)

getState

public byte[] getState()
Answers the group state; e.g., when joining.
Specified by:
getState in interface MessageListener
Returns:
byte[]

init

public void init()

main

public static void main(String[] args)

moveNode

public void moveNode(Node n)

receive

public void receive(Message m)
Called when a message is received.
Specified by:
receive in interface MessageListener
Parameters:

removeNode

public void removeNode(Object addr)

repaint

public void repaint()

setState

public void setState(byte[] new_state)
Sets the group state; e.g., when joining.
Specified by:
setState in interface MessageListener
Parameters:

suspect

public void suspect(Address obj)
Called whenever a member is suspected of having crashed, but has not yet been excluded.
Specified by:
suspect in interface MembershipListener

viewAccepted

public void viewAccepted(View v)
Called when a change in membership has occurred. No long running actions should be done in this callback. If some long running action needs to be performed, it should be done in a separate thread.
Specified by:
viewAccepted in interface MembershipListener

Copyright B) 1998-2005 Bela Ban. All Rights Reserved.