Package org.opends.quicksetup
Class Launcher
- java.lang.Object
-
- org.opends.quicksetup.Launcher
-
- Direct Known Subclasses:
SetupLauncher,UninstallLauncher
public abstract class Launcher extends Object
Responsible for providing initial evaluation of command line arguments and determining whether to launch a CLI, GUI, or print a usage statement.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract CliApplicationcreateCliApplication()Creates a CLI application that will be run if the launcher needs to launch a CLI application.abstract ArgumentParsergetArgumentParser()Gets an argument parser appropriate for this CLI launcher.String[]getArguments()Gets the arguments with which this launcher was invoked.protected abstract org.forgerock.i18n.LocalizableMessagegetFrameTitle()Gets the frame title of the GUI application that will be used in some operating systems.protected TempLogFilegetTempLogFile()The temporary log file of this launcher, created the first time it is asked for.protected abstract voidguiLaunchFailed()Called if launching of the GUI failed.protected booleanhasTempLogFile()Whether there is a log to name, without creating one to answer.protected booleanisCli()Indicates whether the launcher will launch a command line versus a graphical application based on the contents of the arguments passed into the constructor.protected booleanisQuiet()Indicates whether the launcher should print a usage statement based on the content of the arguments passed into the constructor.voidlaunch()The main method which is called by the command lines.protected intlaunchGui(String[] args)Launches the graphical uninstall.protected booleanshouldPrintUsage()Indicates whether the launcher should print a usage statement based on the content of the arguments passed into the constructor.protected booleanshouldPrintVersion()Indicates whether the launcher should print a version statement based on the content of the arguments passed into the constructor.protected abstract voidwillLaunchGui()Called before the launcher launches the GUI.
-
-
-
Field Detail
-
args
protected final String[] args
Arguments with which this launcher was invoked.
-
-
Constructor Detail
-
Launcher
public Launcher(String[] args, String tempLogFilePrefix)
Creates a Launcher.- Parameters:
args- String[] of argument passes from the command linetempLogFilePrefix- temporary log file path where messages will be logged
-
Launcher
public Launcher(String[] args, String tempLogFilePrefix, File tempLogFileDirectory)
Creates a Launcher whose temporary log file lives in the given directory.- Parameters:
args- String[] of argument passes from the command linetempLogFilePrefix- temporary log file path where messages will be loggedtempLogFileDirectory- the directory to create the temporary log file in, ornullfor the OS temporary directory
-
-
Method Detail
-
getTempLogFile
protected TempLogFile getTempLogFile()
The temporary log file of this launcher, created the first time it is asked for.Creating it costs a file - and, with a directory of the caller's choosing, the directory as well - that nothing removes afterwards unless the operation succeeds. So it is created on the first road that can fail an operation and not before:
--help,--version, a usage error and the other roads that attempt nothing leave no log behind (issue #1030).- Returns:
- the temporary log file, creating it if this is the first call.
-
hasTempLogFile
protected boolean hasTempLogFile()
Whether there is a log to name, without creating one to answer.- Returns:
trueif a temporary log file has been created and can be used to log messages.
-
getArguments
public String[] getArguments()
Gets the arguments with which this launcher was invoked.- Returns:
- String[] args from the CLI invocation
-
getArgumentParser
public abstract ArgumentParser getArgumentParser()
Gets an argument parser appropriate for this CLI launcher.- Returns:
- ArgumentParser for parsing args
-
shouldPrintUsage
protected boolean shouldPrintUsage()
Indicates whether the launcher should print a usage statement based on the content of the arguments passed into the constructor.- Returns:
- boolean where true indicates usage should be printed
-
isQuiet
protected boolean isQuiet()
Indicates whether the launcher should print a usage statement based on the content of the arguments passed into the constructor.- Returns:
- boolean where true indicates usage should be printed
-
shouldPrintVersion
protected boolean shouldPrintVersion()
Indicates whether the launcher should print a version statement based on the content of the arguments passed into the constructor.- Returns:
- boolean where true indicates version should be printed
-
isCli
protected boolean isCli()
Indicates whether the launcher will launch a command line versus a graphical application based on the contents of the arguments passed into the constructor.- Returns:
- boolean where true indicates that a CLI application should be launched
-
launchGui
protected int launchGui(String[] args)
Launches the graphical uninstall. The graphical uninstall is launched in a different thread that the main thread because if we have a problem with the graphical system (for instance the DISPLAY environment variable is not correctly set) the native libraries will call exit. However if we launch this from another thread, the thread will just be killed. This code also assumes that if the call to SplashWindow.main worked (and the splash screen was displayed) we will never get out of it (we will call a System.exit() when we close the graphical uninstall dialog).- Parameters:
args- String[] the arguments used to call the SplashWindow main method- Returns:
- 0 if everything worked fine, or 1 if we could not display properly the SplashWindow.
-
getFrameTitle
protected abstract org.forgerock.i18n.LocalizableMessage getFrameTitle()
Gets the frame title of the GUI application that will be used in some operating systems.- Returns:
- internationalized String representing the frame title
-
createCliApplication
protected abstract CliApplication createCliApplication()
Creates a CLI application that will be run if the launcher needs to launch a CLI application.- Returns:
- CliApplication that will be run
-
willLaunchGui
protected abstract void willLaunchGui()
Called before the launcher launches the GUI. Here subclasses can do any application specific things like set system properties of print status messages that need to be done before the GUI launches.
-
guiLaunchFailed
protected abstract void guiLaunchFailed()
Called if launching of the GUI failed.
-
launch
public void launch()
The main method which is called by the command lines.
-
-