Class HubRunner


  • public class HubRunner
    extends java.lang.Object
    Deprecated.
    use Hub instead
    Runs a SAMP hub using the SAMP Standard Profile. The start() method must be called to start it up.

    The main(java.lang.String[]) method can be used to launch a hub from the command line. Use the -help flag for more information.

    Since:
    15 Jul 2008
    Author:
    Mark Taylor
    • Constructor Detail

      • HubRunner

        public HubRunner​(SampXmlRpcClientFactory xClientFactory,
                         SampXmlRpcServerFactory xServerFactory,
                         HubService hub,
                         java.io.File lockfile)
        Deprecated.
        Constructor. If the supplied lockfile is null, no lockfile will be written at hub startup.
        Parameters:
        xClientFactory - XML-RPC client factory implementation
        xServerFactory - XML-RPC server implementation
        hub - object providing hub services
        lockfile - location to use for hub lockfile, or null
    • Method Detail

      • start

        public void start()
                   throws java.io.IOException
        Deprecated.
        Starts the hub and writes the lockfile.
        Throws:
        java.io.IOException - if a hub is already running or an error occurs
      • shutdown

        public void shutdown()
        Deprecated.
        Shuts down the hub and tidies up. May harmlessly be called multiple times.
      • getHub

        public HubService getHub()
        Deprecated.
        Returns the HubService object used by this runner.
        Returns:
        hub service
      • getLockInfo

        public LockInfo getLockInfo()
        Deprecated.
        Returns the lockfile information associated with this object. Only present after start() has been called.
        Returns:
        lock info
      • publishLockfile

        public java.net.URL publishLockfile()
                                     throws java.io.IOException
        Deprecated.
        Returns an HTTP URL at which the lockfile for this hub can be found. The first call to this method causes the lockfile to be published in this way; subsequent calls return the same value.

        Use this with care; publishing your lockfile means that other people can connect to your hub and potentially do disruptive things.

        Returns:
        lockfile information URL
        Throws:
        java.io.IOException
      • createSecret

        public java.lang.String createSecret()
        Deprecated.
        Used to generate the registration password. May be overridden.
        Returns:
        pasword
      • main

        public static void main​(java.lang.String[] args)
                         throws java.io.IOException
        Deprecated.
        Main method. Starts a hub. Use "-help" flag for more information.
        Parameters:
        args - command-line arguments
        Throws:
        java.io.IOException
      • runMain

        public static int runMain​(java.lang.String[] args)
                           throws java.io.IOException
        Deprecated.
        Does the work for running the main(java.lang.String[]) method. System.exit() is not called from this method. Use "-help" flag for more information.
        Parameters:
        args - command-line arguments
        Returns:
        0 means success, non-zero means error status
        Throws:
        java.io.IOException
      • runHub

        public static HubRunner runHub​(HubMode hubMode,
                                       XmlRpcKit xmlrpc)
                                throws java.io.IOException
        Deprecated.
        Static method which may be used to start a SAMP hub programmatically. The returned hub is running (start has been called).

        If the hub mode corresponds to one of the GUI options, one of two things will happen. An attempt will be made to install an icon in the "system tray"; if this is successful, the attached popup menu will provide options for displaying the hub window and for shutting it down. If no system tray is available, the hub window will be posted directly, and the hub will shut down when this window is closed. System tray functionality is only available when running under Java 1.6 or later, and when using a suitable display manager.

        Parameters:
        hubMode - hub mode
        xmlrpc - XML-RPC implementation; automatically determined if null
        Returns:
        running hub
        Throws:
        java.io.IOException
      • runHub

        public static HubRunner runHub​(HubMode hubMode,
                                       XmlRpcKit xmlrpc,
                                       java.lang.String secret,
                                       java.io.File lockfile)
                                throws java.io.IOException
        Deprecated.
        Static method which may be used to start a SAMP hub programmatically, with a supplied samp.secret string. The returned hub is running (start has been called).

        If the hub mode corresponds to one of the GUI options, one of two things will happen. An attempt will be made to install an icon in the "system tray"; if this is successful, the attached popup menu will provide options for displaying the hub window and for shutting it down. If no system tray is available, the hub window will be posted directly, and the hub will shut down when this window is closed. System tray functionality is only available when running under Java 1.6 or later, and when using a suitable display manager.

        Parameters:
        hubMode - hub mode
        xmlrpc - XML-RPC implementation; automatically determined if null
        secret - samp.secret string to be used for hub connection; chosen at random if null
        lockfile - location of lockfile to write, or null for lock to be provided by HTTP
        Returns:
        running hub
        Throws:
        java.io.IOException
      • runExternalHub

        public static void runExternalHub​(HubMode hubMode)
                                   throws java.io.IOException
        Deprecated.
        Static method which will attempt to start a hub running in an external JVM. The resulting hub can therefore outlast the lifetime of the current application. Because of the OS interaction required, it's hard to make this bulletproof, and it may fail without an exception, but we do our best.
        Parameters:
        hubMode - hub mode
        Throws:
        java.io.IOException
        See Also:
        checkExternalHubAvailability()
      • checkExternalHubAvailability

        public static void checkExternalHubAvailability()
                                                 throws java.io.IOException
        Deprecated.
        Attempts to determine whether an external hub can be started using runExternalHub(org.astrogrid.samp.xmlrpc.HubMode). If it can be determined that such an attempt would fail, this method will throw an exception with an informative message. This method succeeding is not a guarantee that an external hub can be started successfullly. The behaviour of this method is not expected to change over the lifetime of a given JVM.
        Throws:
        java.io.IOException