Hub
insteadpublic class HubRunner
extends java.lang.Object
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.
Modifier and Type | Field and Description |
---|---|
private HubService |
hub_
Deprecated.
|
private HubXmlRpcHandler |
hubHandler_
Deprecated.
|
private java.io.File |
lockfile_
Deprecated.
|
private LockInfo |
lockInfo_
Deprecated.
|
private java.net.URL |
lockUrl_
Deprecated.
|
private static java.util.logging.Logger |
logger_
Deprecated.
|
private static java.util.Random |
random_
Deprecated.
|
private SampXmlRpcServer |
server_
Deprecated.
|
private boolean |
shutdown_
Deprecated.
|
private static ProfileToken |
STANDARD_PROFILE
Deprecated.
|
private SampXmlRpcClientFactory |
xClientFactory_
Deprecated.
|
private SampXmlRpcServerFactory |
xServerFactory_
Deprecated.
|
Constructor and Description |
---|
HubRunner(SampXmlRpcClientFactory xClientFactory,
SampXmlRpcServerFactory xServerFactory,
HubService hub,
java.io.File lockfile)
Deprecated.
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static void |
checkExternalHubAvailability()
Deprecated.
Attempts to determine whether an external hub can be started using
runExternalHub(org.astrogrid.samp.xmlrpc.HubMode) . |
java.lang.String |
createSecret()
Deprecated.
Used to generate the registration password.
|
private static void |
discardBytes(java.io.InputStream in)
Deprecated.
Ensures that any bytes from a given input stream are discarded.
|
private static void |
execBackground(java.lang.String[] cmdarray)
Deprecated.
Executes a command in a separate process, and discards any stdout
or stderr output generated by it.
|
HubService |
getHub()
Deprecated.
Returns the HubService object used by this runner.
|
LockInfo |
getLockInfo()
Deprecated.
Returns the lockfile information associated with this object.
|
private static boolean |
isHubAlive(SampXmlRpcClientFactory xClientFactory,
java.io.File lockfile)
Deprecated.
Attempts to determine whether a given lockfile corresponds to a hub
which is still alive.
|
static void |
main(java.lang.String[] args)
Deprecated.
Main method.
|
java.net.URL |
publishLockfile()
Deprecated.
Returns an HTTP URL at which the lockfile for this hub can be found.
|
private static LockInfo |
readLockFile(java.io.File lockFile)
Deprecated.
Reads lockinfo from a file.
|
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,
java.lang.String secret,
java.io.File lockfile)
Deprecated.
Static method which may be used to start a SAMP hub programmatically,
with a supplied samp.secret string.
|
static int |
runMain(java.lang.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.
|
private static void |
writeLockInfo(LockInfo info,
java.io.OutputStream out)
Deprecated.
Writes lockfile information to a given output stream.
|
private final SampXmlRpcClientFactory xClientFactory_
private final SampXmlRpcServerFactory xServerFactory_
private final HubService hub_
private final java.io.File lockfile_
private java.net.URL lockUrl_
private LockInfo lockInfo_
private SampXmlRpcServer server_
private HubXmlRpcHandler hubHandler_
private boolean shutdown_
private static final ProfileToken STANDARD_PROFILE
private static final java.util.logging.Logger logger_
private static final java.util.Random random_
public HubRunner(SampXmlRpcClientFactory xClientFactory, SampXmlRpcServerFactory xServerFactory, HubService hub, java.io.File lockfile)
lockfile
is null, no lockfile will
be written at hub startup.xClientFactory
- XML-RPC client factory implementationxServerFactory
- XML-RPC server implementationhub
- object providing hub serviceslockfile
- location to use for hub lockfile, or nullpublic void start() throws java.io.IOException
java.io.IOException
- if a hub is already running or an error occurspublic void shutdown()
public HubService getHub()
public LockInfo getLockInfo()
start()
has been called.public java.net.URL publishLockfile() throws java.io.IOException
Use this with care; publishing your lockfile means that other people can connect to your hub and potentially do disruptive things.
java.io.IOException
public java.lang.String createSecret()
private static boolean isHubAlive(SampXmlRpcClientFactory xClientFactory, java.io.File lockfile)
xClientFactory
- XML-RPC client factory implementationlockfile
- lockfile locationlockfile
appears
to be alive and wellprivate static LockInfo readLockFile(java.io.File lockFile) throws java.io.IOException
lockFile
- filejava.io.IOException
private static void writeLockInfo(LockInfo info, java.io.OutputStream out) throws java.io.IOException
info
- lock info to writeout
- destination streamjava.io.IOException
public static void main(java.lang.String[] args) throws java.io.IOException
args
- command-line argumentsjava.io.IOException
public static int runMain(java.lang.String[] args) throws java.io.IOException
main(java.lang.String[])
method.
System.exit() is not called from this method.
Use "-help" flag for more information.args
- command-line argumentsjava.io.IOException
public static HubRunner runHub(HubMode hubMode, XmlRpcKit xmlrpc) throws java.io.IOException
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.
hubMode
- hub modexmlrpc
- XML-RPC implementation;
automatically determined if nulljava.io.IOException
public static HubRunner runHub(HubMode hubMode, XmlRpcKit xmlrpc, java.lang.String secret, java.io.File lockfile) throws java.io.IOException
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.
hubMode
- hub modexmlrpc
- XML-RPC implementation;
automatically determined if nullsecret
- samp.secret string to be used for hub connection;
chosen at random if nulllockfile
- location of lockfile to write,
or null for lock to be provided by HTTPjava.io.IOException
public static void runExternalHub(HubMode hubMode) throws java.io.IOException
hubMode
- hub modejava.io.IOException
checkExternalHubAvailability()
public static void checkExternalHubAvailability() throws java.io.IOException
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.java.io.IOException
private static void execBackground(java.lang.String[] cmdarray) throws java.io.IOException
Runtime.exec
can block the process
until its output is consumed.cmdarray
- array containing the command to call and its argsjava.io.IOException
private static void discardBytes(java.io.InputStream in)
in
- input stream