Class HubServiceMode

  • Direct Known Subclasses:
    HubServiceMode.BrokenHubMode

    public abstract class HubServiceMode
    extends java.lang.Object
    Specifies a particular hub implementation for use with Hub.
    Since:
    20 Nov 2008
    Author:
    Mark Taylor
    • Field Detail

      • name_

        private final java.lang.String name_
      • isDaemon_

        private final boolean isDaemon_
      • logger_

        private static final java.util.logging.Logger logger_
      • NO_GUI

        public static final HubServiceMode NO_GUI
        Hub mode with no GUI representation of hub operations.
      • CLIENT_GUI

        public static final HubServiceMode CLIENT_GUI
        Hub mode with a GUI representation of connected clients.
      • MESSAGE_GUI

        public static HubServiceMode MESSAGE_GUI
        Hub mode with a GUI representation of clients and messages.
      • FACADE

        public static HubServiceMode FACADE
        Hub Mode which piggy-backs on an existing hub using the default client profile.
      • KNOWN_MODES

        private static final HubServiceMode[] KNOWN_MODES
        Array of available hub modes.
    • Constructor Detail

      • HubServiceMode

        HubServiceMode​(java.lang.String name,
                       boolean isDaemon)
        Constructor.
        Parameters:
        name - mode name
        isDaemon - true if the hub will start only daemon threads
    • Method Detail

      • createHubService

        abstract HubServiceMode.ServiceGui createHubService​(java.util.Random random,
                                                            HubProfile[] profiles,
                                                            Hub[] runners)
        Creates and returns a new hub service object.
        Parameters:
        random - random number generator
        profiles - hub profiles
        runners - 1-element array of Hubs - this should be populated with the runner once it has been constructed
        Returns:
        object containing the hub service and possibly a window
      • isDaemon

        boolean isDaemon()
        Indicates whether the hub service will start only daemon threads. If it returns true, the caller may need to make sure that the JVM doesn't stop too early.
        Returns:
        true iff no non-daemon threads will be started by the service
      • getName

        java.lang.String getName()
        Returns this mode's name.
        Returns:
        mode name
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getModeFromName

        public static HubServiceMode getModeFromName​(java.lang.String name)
        Returns one of the known modes which has a name as given.
        Parameters:
        name - mode name (case-insensitive)
        Returns:
        mode with given name, or null if none known
      • getAvailableModes

        public static HubServiceMode[] getAvailableModes()
        Returns an array of the hub modes which can actually be used.
        Returns:
        available mode list
      • configureHubWindow

        private static HubServiceMode.Tidier configureHubWindow​(javax.swing.JFrame frame,
                                                                HubProfile[] profiles,
                                                                Hub[] runners,
                                                                GuiHubService hubService)
        Used to perform common configuration of hub display windows for GUI-type hub modes.
        Parameters:
        frame - hub window
        profiles - profiles to run for hub
        runners - 1-element array which will contain an associated hub runner object if one exists
        hubService - object providing hub services
        Returns:
        object which should be shutdown when the hub stops running
      • createBasicHubMode

        private static HubServiceMode createBasicHubMode​(java.lang.String name)
        Constructs a mode for BasicHubService.
        Parameters:
        name - mode name
        Returns:
        non-gui mode
      • createGuiHubMode

        private static HubServiceMode createGuiHubMode​(java.lang.String name)
        Constructs a mode for GuiHubService.
        Returns:
        mode without message tracking
      • createMessageTrackerHubMode

        private static HubServiceMode createMessageTrackerHubMode​(java.lang.String name)
        Constructs a mode for MessageTrackerHubService.
        Returns:
        mode with message tracking
      • createFacadeHubMode

        private static HubServiceMode createFacadeHubMode​(java.lang.String name)
        Constructs a mode for FacadeHubService.
        Returns:
        mode based on the default client profile