Package org.astrogrid.samp.xmlrpc

# Class HubRunner

java.lang.Object
org.astrogrid.samp.xmlrpc.HubRunner

public class HubRunner extends 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 Summary

Constructors
Constructor
Description
`HubRunner(SampXmlRpcClientFactory xClientFactory, SampXmlRpcServerFactory xServerFactory, HubService hub, File lockfile)`
Deprecated.
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static void`
`checkExternalHubAvailability()`
Deprecated.
Attempts to determine whether an external hub can be started using `runExternalHub(org.astrogrid.samp.xmlrpc.HubMode)`.
`String`
`createSecret()`
Deprecated.
Used to generate the registration password.
`HubService`
`getHub()`
Deprecated.
Returns the HubService object used by this runner.
`LockInfo`
`getLockInfo()`
Deprecated.
Returns the lockfile information associated with this object.
`static void`
`main(String[] args)`
Deprecated.
Main method.
`URL`
`publishLockfile()`
Deprecated.
Returns an HTTP URL at which the lockfile for this hub can be found.
`static void`
`runExternalHub(HubMode hubMode)`
Deprecated.
Static method which will attempt to start a hub running in an external JVM.
`static HubRunner`
`runHub(HubMode hubMode, XmlRpcKit xmlrpc)`
Deprecated.
Static method which may be used to start a SAMP hub programmatically.
`static HubRunner`
`runHub(HubMode hubMode, XmlRpcKit xmlrpc, String secret, File lockfile)`
Deprecated.
Static method which may be used to start a SAMP hub programmatically, with a supplied samp.secret string.
`static int`
`runMain(String[] args)`
Deprecated.
Does the work for running the `main(java.lang.String[])` method.
`void`
`shutdown()`
Deprecated.
Shuts down the hub and tidies up.
`void`
`start()`
Deprecated.
Starts the hub and writes the lockfile.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### HubRunner

public HubRunner(SampXmlRpcClientFactory xClientFactory, SampXmlRpcServerFactory xServerFactory, HubService hub, 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 Details

### start

public void start() throws IOException
Deprecated.
Starts the hub and writes the lockfile.

Throws:
  `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 URL publishLockfile() throws 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:
  `IOException`

### createSecret

public String createSecret()
Deprecated.
Used to generate the registration password. May be overridden.

Returns:
  pasword

### main

public static void main(String[] args) throws IOException
Deprecated.
Main method. Starts a hub. Use "-help" flag for more information.

Parameters:
  `args` - command-line arguments
Throws:
  `IOException`

### runMain

public static int runMain(String[] args) throws 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:
  `IOException`

### runHub

public static HubRunner runHub(HubMode hubMode, XmlRpcKit xmlrpc) throws 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:
  `IOException`

### runHub

public static HubRunner runHub(HubMode hubMode, XmlRpcKit xmlrpc, String secret, File lockfile) throws 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:
  `IOException`

### runExternalHub

public static void runExternalHub(HubMode hubMode) throws 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:
  `IOException`
See Also:
  - `checkExternalHubAvailability()`

### checkExternalHubAvailability

public static void checkExternalHubAvailability() throws 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:
  `IOException`