sg.edu.nus.gui.bootstrap
Class BootstrapGUI

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by sg.edu.nus.gui.AbstractMainFrame
                          extended by sg.edu.nus.gui.bootstrap.BootstrapGUI
All Implemented Interfaces:
java.awt.event.ComponentListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants, LogEventWatcher

public class BootstrapGUI
extends AbstractMainFrame

Implement a bootstrap server that provides the entrance point of register, sign in and depart from the PeerDB system. In other words, only through the bootstrap server, each user or peer can know where is the system and how to join the network.

The basic functionality of the bootstrap server is to monitor all online peers. modified by Han Xixian 2008-6-3

Version:
1.0 2005-12-29
Author:
Xu Linhao
See Also:
Serialized Form

Field Summary
 java.sql.Connection conn
           
static java.lang.String DB_DRIVER
           
static java.lang.String DB_NAME
           
static java.lang.String DB_PASSWORD
           
static java.lang.String DB_URL
           
static boolean DB_USER_CHECK
           
static java.lang.String DB_USERNAME
           
static PeerLog inputLog
           
static PeerLog outputLog
           
static int RUN_PORT
          Define an obscure port to test whether an instance has existed.
 
Fields inherited from class sg.edu.nus.gui.AbstractMainFrame
EVENT_TABLE_WIDTH, HIGH_FREQ, LOW_FREQ, NORM_FREQ, SRC_PATH
 
Fields inherited from class javax.swing.JFrame
EXIT_ON_CLOSE
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
BootstrapGUI()
          Construct a bootstrap server.
 
Method Summary
 void addMsg2StatusBar(java.lang.String str)
          Add the message to the status bar.
 void createDbConnection()
           
 Pane getPane()
          Get the instance of the tabbed pane.
 void log(java.lang.String type, java.lang.String desp, java.lang.String host, java.lang.String src, java.lang.String dest)
          Add a log event for displaying to users.
 void logout(boolean toBoot, boolean toServer, boolean toClient)
          Execute logout operation and broadcast MsgType.TROUBLESHOOT message to all relevant peers.
static void main(java.lang.String[] args)
          Run the bootstrap server.
 AbstractPeer peer()
          Returns the handler of Bootstrap.
 void scheduleUDPSender(long period)
          Re-schedule the UDP Sender with a new time interval.
 void sendSchema(java.lang.String schema)
           
 boolean startServer()
          Start the bootstrap service.
 boolean stopServer()
          Stop the bootstrap server.
 
Methods inherited from class sg.edu.nus.gui.AbstractMainFrame
componentHidden, componentMoved, componentResized, componentShown, processWindowEvent
 
Methods inherited from class javax.swing.JFrame
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

RUN_PORT

public static final int RUN_PORT
Define an obscure port to test whether an instance has existed.

See Also:
Constant Field Values

inputLog

public static PeerLog inputLog

outputLog

public static PeerLog outputLog

conn

public java.sql.Connection conn

DB_USER_CHECK

public static boolean DB_USER_CHECK

DB_URL

public static java.lang.String DB_URL

DB_DRIVER

public static java.lang.String DB_DRIVER

DB_NAME

public static java.lang.String DB_NAME

DB_USERNAME

public static java.lang.String DB_USERNAME

DB_PASSWORD

public static java.lang.String DB_PASSWORD
Constructor Detail

BootstrapGUI

public BootstrapGUI()
Construct a bootstrap server.

Method Detail

createDbConnection

public void createDbConnection()

getPane

public Pane getPane()
Get the instance of the tabbed pane.

Returns:
the instance of the tabbed pane

peer

public AbstractPeer peer()
Returns the handler of Bootstrap.

Specified by:
peer in class AbstractMainFrame
Returns:
the handler of Bootstrap

startServer

public boolean startServer()
Start the bootstrap service.

Returns:
if success, return true; otherwise, return false

stopServer

public boolean stopServer()
Stop the bootstrap server.

Returns:
if success, return true; otherwise, return false

scheduleUDPSender

public void scheduleUDPSender(long period)
Description copied from class: AbstractMainFrame
Re-schedule the UDP Sender with a new time interval.

Specified by:
scheduleUDPSender in class AbstractMainFrame
Parameters:
period - the new period for disseminating UDP packets

addMsg2StatusBar

public void addMsg2StatusBar(java.lang.String str)
Add the message to the status bar.

Parameters:
str - the message

log

public void log(java.lang.String type,
                java.lang.String desp,
                java.lang.String host,
                java.lang.String src,
                java.lang.String dest)
Description copied from interface: LogEventWatcher
Add a log event for displaying to users. The format of the log event is defined by LogEvent.

Parameters:
type - the event type
desp - the event description
host - the host name who sends requests
src - the IP address of the requester
dest - the IP address of the receiver

logout

public void logout(boolean toBoot,
                   boolean toServer,
                   boolean toClient)
Description copied from class: AbstractMainFrame
Execute logout operation and broadcast MsgType.TROUBLESHOOT message to all relevant peers.

Specified by:
logout in class AbstractMainFrame
Parameters:
toBoot - if true, send messages to bootstrapper
toServer - if true, send messages to server peers
toClient - if true, send messages to client peers

sendSchema

public void sendSchema(java.lang.String schema)

main

public static void main(java.lang.String[] args)
Run the bootstrap server.

Parameters:
args -