com.isti.quakewatch.util
Class QWClientLauncher

java.lang.Object
  extended by com.isti.quakewatch.util.QWClientLauncher

public class QWClientLauncher
extends java.lang.Object

Class QWClientLauncher launches the QuakeWatch client.


Field Summary
static java.lang.String[] ALTERNATE_RUN_CLIENT_JAR_FILE_DIRS
          Alternate client jar file directories.
protected static java.lang.String baseWriteDirStr
           
static java.lang.String CLIENT_JAR_FILE
          Name for the client jar file.
static java.lang.String CLIENT_PROGRAM_SINGLETON_NAME
          Name for the "program singleton" object.
static java.lang.String DEFAULT_RUN_CLIENT_JAR_FILE_DIR
          Default client jar file directory.
protected static java.lang.String programRunDirStr
           
 
Constructor Summary
QWClientLauncher(LogFile logObj)
          Constructs a client launcher.
QWClientLauncher(LogFile logObj, java.io.File runClientJarFile)
          Constructs a client launcher.
QWClientLauncher(LogFile logObj, java.io.File runClientJarFile, java.lang.String progSingletonDirStr)
          Constructs a client launcher.
QWClientLauncher(LogFile logObj, java.lang.String clientDirectory)
          Constructs a client launcher.
QWClientLauncher(LogFile logObj, java.lang.String clientDirectory, java.lang.String progSingletonDirStr)
          Constructs a client launcher.
 
Method Summary
static ProgramSingleton detDirsAndCreateSingleton(java.lang.String sFileNameStr, boolean prgRunDirFlag, java.lang.String userHomeSubDirStr, java.lang.String userHomeDirPrefixStr)
          Determines the program-run directory and the base directory for write-access files, and creates a program singleton object.
protected static java.lang.String fetchJavaCmdFromFile(java.io.File fileObj)
          Returns the first "java" command from the given file.
static java.lang.String getBaseWriteDirStr()
          Returns the 'baseWriteDirStr' value entered by the method 'detDirsAndCreateSingleton()'.
static java.lang.String getLaunchClientCommand()
          Returns the launch command for the QWClient program.
static java.lang.String getLaunchClientCommand(java.io.File parent)
          Returns the launch command for the QWClient program.
static java.lang.String getProgramRunDirStr()
          Returns the 'programRunDirStr' value entered by the method 'detDirsAndCreateSingleton()'.
protected static java.io.File getRunClientJarFile(java.lang.String clientDirectory)
          Returns the client jar file for the specified client directory.
static void main(java.lang.String[] args)
           
 java.lang.String runClient()
          Runs the client.
 java.lang.String runClient(java.lang.String clientNameStr)
          Runs the client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLIENT_PROGRAM_SINGLETON_NAME

public static final java.lang.String CLIENT_PROGRAM_SINGLETON_NAME
Name for the "program singleton" object.

See Also:
Constant Field Values

CLIENT_JAR_FILE

public static final java.lang.String CLIENT_JAR_FILE
Name for the client jar file.

See Also:
Constant Field Values

DEFAULT_RUN_CLIENT_JAR_FILE_DIR

public static final java.lang.String DEFAULT_RUN_CLIENT_JAR_FILE_DIR
Default client jar file directory.

See Also:
Constant Field Values

ALTERNATE_RUN_CLIENT_JAR_FILE_DIRS

public static final java.lang.String[] ALTERNATE_RUN_CLIENT_JAR_FILE_DIRS
Alternate client jar file directories.


programRunDirStr

protected static java.lang.String programRunDirStr

baseWriteDirStr

protected static java.lang.String baseWriteDirStr
Constructor Detail

QWClientLauncher

public QWClientLauncher(LogFile logObj)
                 throws java.io.FileNotFoundException
Constructs a client launcher.

Parameters:
logObj - the log object.
Throws:
java.io.FileNotFoundException - if the client jar file could not be found.

QWClientLauncher

public QWClientLauncher(LogFile logObj,
                        java.lang.String clientDirectory,
                        java.lang.String progSingletonDirStr)
                 throws java.io.FileNotFoundException
Constructs a client launcher.

Parameters:
logObj - the log object.
clientDirectory - the client directory or empty string for default.
progSingletonDirStr - directory for program-singleton file, or null or empty string for default directory.
Throws:
java.io.FileNotFoundException - if the client jar file could not be found.

QWClientLauncher

public QWClientLauncher(LogFile logObj,
                        java.lang.String clientDirectory)
                 throws java.io.FileNotFoundException
Constructs a client launcher.

Parameters:
logObj - the log object.
clientDirectory - the client directory or empty string for default.
Throws:
java.io.FileNotFoundException - if the client jar file could not be found.

QWClientLauncher

public QWClientLauncher(LogFile logObj,
                        java.io.File runClientJarFile,
                        java.lang.String progSingletonDirStr)
                 throws java.io.FileNotFoundException
Constructs a client launcher.

Parameters:
logObj - the log object.
runClientJarFile - the client jar file.
progSingletonDirStr - directory for program-singleton file, or null or empty string for default directory.
Throws:
java.io.FileNotFoundException - if the client jar file could not be found.

QWClientLauncher

public QWClientLauncher(LogFile logObj,
                        java.io.File runClientJarFile)
                 throws java.io.FileNotFoundException
Constructs a client launcher.

Parameters:
logObj - the log object.
runClientJarFile - the client jar file.
Throws:
java.io.FileNotFoundException - if the client jar file could not be found.
Method Detail

runClient

public java.lang.String runClient()
Runs the client.

Returns:
an error string or null if no error.

runClient

public java.lang.String runClient(java.lang.String clientNameStr)
Runs the client.

Parameters:
clientNameStr - the client name string.
Returns:
an error string or null if no error.

getLaunchClientCommand

public static java.lang.String getLaunchClientCommand()
Returns the launch command for the QWClient program. If possible the command is fetched from a batch/script file; if not then a default launch command is returned.

Returns:
The launch command for the QWClient program.

getLaunchClientCommand

public static java.lang.String getLaunchClientCommand(java.io.File parent)
Returns the launch command for the QWClient program. If possible the command is fetched from a batch/script file; if not then a default launch command is returned.

Parameters:
parent - the parent for the files.
Returns:
The launch command for the QWClient program.

fetchJavaCmdFromFile

protected static java.lang.String fetchJavaCmdFromFile(java.io.File fileObj)
Returns the first "java" command from the given file. The command should be in the form "java ... -jar JarName.jar" and may have characters before the command, additional parameters, and lines of data after the command. If a "%*" or "$*" string is found right after the command it is removed.

Parameters:
fileObj - the input file object.
Returns:
The "java" command string, or null if a valid command string could not be fetched from the file.

getRunClientJarFile

protected static java.io.File getRunClientJarFile(java.lang.String clientDirectory)
Returns the client jar file for the specified client directory.

Parameters:
clientDirectory - the client directory or empty string for default.
Returns:
the client jar file or null if not found.

main

public static void main(java.lang.String[] args)

detDirsAndCreateSingleton

public static ProgramSingleton detDirsAndCreateSingleton(java.lang.String sFileNameStr,
                                                         boolean prgRunDirFlag,
                                                         java.lang.String userHomeSubDirStr,
                                                         java.lang.String userHomeDirPrefixStr)
Determines the program-run directory and the base directory for write-access files, and creates a program singleton object. This method enters values into the static 'programRunDirStr' and 'baseWriteDirStr' variables.

Parameters:
sFileNameStr - program name to use with singleton file.
prgRunDirFlag - true if program-run directory should be used for write-access files; false if user-home directory should be used.
userHomeSubDirStr - user-home subdirectory name to use.
userHomeDirPrefixStr - prefix for secondary user-home directory name.
Returns:
A new program singleton object.

getProgramRunDirStr

public static java.lang.String getProgramRunDirStr()
Returns the 'programRunDirStr' value entered by the method 'detDirsAndCreateSingleton()'.

Returns:
The 'programRunDirStr' value entered by the method 'detDirsAndCreateSingleton()', or an empty string if none available.

getBaseWriteDirStr

public static java.lang.String getBaseWriteDirStr()
Returns the 'baseWriteDirStr' value entered by the method 'detDirsAndCreateSingleton()'.

Returns:
The 'baseWriteDirStr' value entered by the method 'detDirsAndCreateSingleton()', or an empty string if none available.