org.astrogrid.samp.xmlrpc
Class HubRunner

java.lang.Object
  extended byorg.astrogrid.samp.xmlrpc.HubRunner

public class HubRunner
extends Object

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
HubRunner(SampXmlRpcClientFactory xClientFactory, SampXmlRpcServerFactory xServerFactory, HubService hub, File lockfile)
          Constructor.
 
Method Summary
 String createSecret()
          Used to generate the registration password.
 HubService getHub()
          Returns the HubService object used by this runner.
 LockInfo getLockInfo()
          Returns the lockfile information associated with this object.
static void main(String[] args)
          Main method.
static void runExternalHub(boolean gui)
          Static method which will attempt to start a hub running in an external JVM.
static void runHub(boolean gui, XmlRpcKit xmlrpc)
          Static method which may be used to start a SAMP hub programmatically.
static int runMain(String[] args)
          Does the work for running the main(java.lang.String[]) method.
 void shutdown()
          Shuts down the hub and tidies up.
 void start()
          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 Detail

HubRunner

public HubRunner(SampXmlRpcClientFactory xClientFactory,
                 SampXmlRpcServerFactory xServerFactory,
                 HubService hub,
                 File lockfile)
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 IOException
Starts the hub and writes the lockfile.

Throws:
IOException - if a hub is already running or an error occurs

shutdown

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


getHub

public HubService getHub()
Returns the HubService object used by this runner.

Returns:
hub service

getLockInfo

public LockInfo getLockInfo()
Returns the lockfile information associated with this object. Only present after start() has been called.

Returns:
lock info

createSecret

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

Returns:
pasword

main

public static void main(String[] args)
                 throws IOException
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
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 void runHub(boolean gui,
                          XmlRpcKit xmlrpc)
                   throws IOException
Static method which may be used to start a SAMP hub programmatically. If the gui flag is set, a window will be posted which displays the current status of the hub. When this window is disposed, the hub will stop.

Parameters:
gui - if true, display a window showing hub status
xmlrpc - XML-RPC implementation; automatically determined if null
Throws:
IOException

runExternalHub

public static void runExternalHub(boolean gui)
                           throws IOException
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:
gui - if true, display a window showing hub status
Throws:
IOException


Copyright © 2008 AstroGrid. All Rights Reserved.