Package org.jgroups.demos.wb
Class Whiteboard
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Panel
-
- java.applet.Applet
-
- org.jgroups.demos.wb.Whiteboard
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.ComponentListener
,java.awt.event.FocusListener
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,java.util.EventListener
,javax.accessibility.Accessible
,MembershipListener
public class Whiteboard extends java.applet.Applet implements MembershipListener, java.awt.event.ActionListener, java.awt.event.ComponentListener, java.awt.event.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
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description RpcDispatcher
disp
static java.lang.String
groupname
-
Constructor Summary
Constructors Constructor Description Whiteboard()
Whiteboard(java.lang.String properties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
void
addNode(java.lang.String lbl, Address addr, int xloc, int yloc)
void
block()
Called (usually by the FLUSH protocol), as an indication that the member should stop sending messages.void
componentHidden(java.awt.event.ComponentEvent e)
void
componentMoved(java.awt.event.ComponentEvent e)
void
componentResized(java.awt.event.ComponentEvent e)
void
componentShown(java.awt.event.ComponentEvent e)
void
destroy()
void
displayMessage(java.lang.String sender, java.lang.String msg)
void
focusGained(java.awt.event.FocusEvent e)
void
focusLost(java.awt.event.FocusEvent e)
void
getState(java.io.OutputStream ostream)
void
init()
static void
main(java.lang.String[] args)
void
moveNode(Node n)
void
removeNode(java.lang.Object addr)
void
repaint()
void
setState(java.io.InputStream istream)
void
suspect(Address obj)
Called whenever a member is suspected of having crashed, but has not yet been excluded.void
unblock()
Called after the FLUSH protocol has unblocked previously blocked senders, and messages can be sent again.void
viewAccepted(View v)
Called when a change in membership has occurred.-
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, isValidateRoot, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
disp
public RpcDispatcher disp
-
groupname
public static final java.lang.String groupname
- See Also:
- Constant Field Values
-
-
Method Detail
-
getState
public void getState(java.io.OutputStream ostream) throws java.lang.Exception
- Throws:
java.lang.Exception
-
setState
public void setState(java.io.InputStream istream) throws java.lang.Exception
- Throws:
java.lang.Exception
-
init
public void init()
- Overrides:
init
in classjava.applet.Applet
-
destroy
public void destroy()
- Overrides:
destroy
in classjava.applet.Applet
-
repaint
public void repaint()
- Overrides:
repaint
in classjava.awt.Component
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
viewAccepted
public void viewAccepted(View v)
Description copied from interface:MembershipListener
Called when a change in membership has occurred. No long running actions, sending of messages or anything that could block should be done in this callback. If some long running action needs to be performed, it should be done in a separate thread. Note that on reception of the first view (a new member just joined), the channel will not yet be in the connected state. This only happens whenJChannel.connect(String)
returns.- Specified by:
viewAccepted
in interfaceMembershipListener
-
suspect
public void suspect(Address obj)
Description copied from interface:MembershipListener
Called whenever a member is suspected of having crashed, but has not yet been excluded.- Specified by:
suspect
in interfaceMembershipListener
-
block
public void block()
Description copied from interface:MembershipListener
Called (usually by the FLUSH protocol), as an indication that the member should stop sending messages. Any messages sent after returning from this callback might get blocked by the FLUSH protocol. When the FLUSH protocol is done, and messages can be sent again, the FLUSH protocol will simply unblock all pending messages. If a callback for unblocking is desired, implementMembershipListener.unblock()
. Note that block() is the equivalent of reception of a BlockEvent in the pull mode.- Specified by:
block
in interfaceMembershipListener
-
unblock
public void unblock()
Description copied from interface:MembershipListener
Called after the FLUSH protocol has unblocked previously blocked senders, and messages can be sent again. This callback only needs to be implemented if we require a notification of that.Note that during new view installation we provide guarantee that unblock invocation strictly follows view installation at some node A belonging to that view . However, some other message M may squeeze in between view and unblock callbacks. For more details see https://jira.jboss.org/jira/browse/JGRP-986
- Specified by:
unblock
in interfaceMembershipListener
-
moveNode
public void moveNode(Node n)
-
addNode
public void addNode(java.lang.String lbl, Address addr, int xloc, int yloc)
-
removeNode
public void removeNode(java.lang.Object addr)
-
displayMessage
public void displayMessage(java.lang.String sender, java.lang.String msg)
-
componentResized
public void componentResized(java.awt.event.ComponentEvent e)
- Specified by:
componentResized
in interfacejava.awt.event.ComponentListener
-
componentMoved
public void componentMoved(java.awt.event.ComponentEvent e)
- Specified by:
componentMoved
in interfacejava.awt.event.ComponentListener
-
componentShown
public void componentShown(java.awt.event.ComponentEvent e)
- Specified by:
componentShown
in interfacejava.awt.event.ComponentListener
-
componentHidden
public void componentHidden(java.awt.event.ComponentEvent e)
- Specified by:
componentHidden
in interfacejava.awt.event.ComponentListener
-
focusGained
public void focusGained(java.awt.event.FocusEvent e)
- Specified by:
focusGained
in interfacejava.awt.event.FocusListener
-
focusLost
public void focusLost(java.awt.event.FocusEvent e)
- Specified by:
focusLost
in interfacejava.awt.event.FocusListener
-
main
public static void main(java.lang.String[] args)
-
-