Package org.astrogrid.samp.hub
Class HubServiceMode
- java.lang.Object
-
- org.astrogrid.samp.hub.HubServiceMode
-
- Direct Known Subclasses:
HubServiceMode.BrokenHubMode
public abstract class HubServiceMode extends java.lang.ObjectSpecifies a particular hub implementation for use withHub.- Since:
- 20 Nov 2008
- Author:
- Mark Taylor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classHubServiceMode.BasicWindowConfigClass to configure a window for use as a hub control.private static classHubServiceMode.BrokenHubModeHubServiceMode implementation for modes which cannot be used because they rely on classes unavailable at runtime.private static classHubServiceMode.ProfileTogglerManages a toggle button for starting/stopping profiles.(package private) static classHubServiceMode.ServiceGuiAggregates a HubService and an associated monitor/control window.private static classHubServiceMode.SysTrayWindowConfigTakes care of hub display window configuration with system tray functionality.private static interfaceHubServiceMode.TidierUtility abstract class to define an object which can be tidied up on hub shutdown.
-
Field Summary
Fields Modifier and Type Field Description static HubServiceModeCLIENT_GUIHub mode with a GUI representation of connected clients.static HubServiceModeFACADEHub Mode which piggy-backs on an existing hub using the default client profile.private booleanisDaemon_private static HubServiceMode[]KNOWN_MODESArray of available hub modes.private static java.util.logging.Loggerlogger_static HubServiceModeMESSAGE_GUIHub mode with a GUI representation of clients and messages.private java.lang.Stringname_static HubServiceModeNO_GUIHub mode with no GUI representation of hub operations.
-
Constructor Summary
Constructors Constructor Description HubServiceMode(java.lang.String name, boolean isDaemon)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private static HubServiceMode.TidierconfigureHubWindow(javax.swing.JFrame frame, HubProfile[] profiles, Hub[] runners, GuiHubService hubService)Used to perform common configuration of hub display windows for GUI-type hub modes.private static HubServiceModecreateBasicHubMode(java.lang.String name)Constructs a mode for BasicHubService.private static HubServiceModecreateFacadeHubMode(java.lang.String name)Constructs a mode for FacadeHubService.private static HubServiceModecreateGuiHubMode(java.lang.String name)Constructs a mode for GuiHubService.(package private) abstract HubServiceMode.ServiceGuicreateHubService(java.util.Random random, HubProfile[] profiles, Hub[] runners)Creates and returns a new hub service object.private static HubServiceModecreateMessageTrackerHubMode(java.lang.String name)Constructs a mode for MessageTrackerHubService.static HubServiceMode[]getAvailableModes()Returns an array of the hub modes which can actually be used.static HubServiceModegetModeFromName(java.lang.String name)Returns one of the known modes which has a name as given.(package private) java.lang.StringgetName()Returns this mode's name.(package private) booleanisDaemon()Indicates whether the hub service will start only daemon threads.java.lang.StringtoString()
-
-
-
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.
-
-
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 generatorprofiles- hub profilesrunners- 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:
toStringin classjava.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 windowprofiles- profiles to run for hubrunners- 1-element array which will contain an associated hub runner object if one existshubService- 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
-
-