/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2009 Sun Microsystems, Inc.
* Portions Copyright 2013-2015 ForgeRock AS.
*/
/**
* Responsible for providing initial evaluation of command line arguments
* and determining whether to launch a CLI, GUI, or print a usage statement.
*/
public abstract class Launcher {
/** Arguments with which this launcher was invoked. */
/**
* Creates a Launcher.
* @param args String[] of argument passes from the command line
*/
throw new IllegalArgumentException("args cannot be null");
}
}
/**
* Gets the arguments with which this launcher was invoked.
* @return String[] args from the CLI invocation
*/
return this.args;
}
/**
* Gets an argument parser appropriate for this CLI launcher.
*
* @return ArgumentParser for parsing args
*/
/**
* Indicates whether or not the launcher should print a usage
* statement based on the content of the arguments passed into
* the constructor.
* @return boolean where true indicates usage should be printed
*/
protected boolean shouldPrintUsage() {
return true;
}
}
}
return false;
}
/**
* Indicates whether or not the launcher should print a usage
* statement based on the content of the arguments passed into
* the constructor.
* @return boolean where true indicates usage should be printed
*/
protected boolean isQuiet() {
return true;
}
}
}
return false;
}
/**
* Indicates whether or not the launcher should print a version
* statement based on the content of the arguments passed into
* the constructor.
* @return boolean where true indicates version should be printed
*/
protected boolean shouldPrintVersion() {
{
{
{
return true;
}
}
}
return false;
}
/**
* Indicates whether the launcher will launch a command line versus
* a graphical application based on the contents of the arguments
* passed into the constructor.
*
* @return boolean where true indicates that a CLI application
* should be launched
*/
protected boolean isCli() {
return true;
}
}
return false;
}
/**
* Prints a usage message to the terminal.
* @param i18nMsg localized user message that will be printed to the terminal.
* @param toStdErr whether the message must be printed to the standard error
* or the standard output.
*/
if (toStdErr)
{
}
else
{
}
}
/**
* 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).
*
* @param args String[] the arguments used to call the SplashWindow main
* method
* @return 0 if everything worked fine, or 1 if we could not display properly
* the SplashWindow.
*/
{
// Setup MacOSX native menu bar before AWT is loaded.
final int[] returnValue =
{ -1 };
{
public void run()
{
try
{
}
catch (Throwable t)
{
if (QuickSetupLog.isInitialized())
{
while (t != null)
{
}
t = t.getCause();
if (t != null)
{
}
}
}
}
}
});
/*
* This is done to avoid displaying the stack that might occur if there are
* problems with the display environment.
*/
t.start();
try
{
t.join();
}
catch (InterruptedException ie)
{
/* An error occurred, so the return value will be -1. We got nothing to
do with this exception. */
}
return returnValue[0];
}
/**
* Gets the frame title of the GUI application that will be used
* in some operating systems.
* @return internationalized String representing the frame title
*/
/**
* Launches the command line based uninstall.
*
* @param cliApp the CLI application to launch
* @return 0 if everything worked fine, and an error code if something wrong
* occurred.
*/
{
{
printUsage(true);
}
{
}
{
}
return returnValue.getReturnCode();
}
/**
* Prints the version statement to standard output terminal.
*/
protected void printVersion()
{
}
/**
* Prints a usage statement to terminal and exits with an error
* code.
* @param toStdErr whether the message must be printed to the standard error
* or the standard output.
*/
try
{
}
}
catch (Throwable t)
{
t.printStackTrace();
}
}
/**
* Creates a CLI application that will be run if the
* launcher needs to launch a CLI application.
* @return CliApplication that will be run
*/
/**
* 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.
*/
protected abstract void willLaunchGui();
/**
* Called if launching of the GUI failed. Here
* subclasses can so application specific things
* like print a message.
* @param logFileName the log file containing more information about why
* the launch failed.
*/
/**
* The main method which is called by the command lines.
*/
public void launch() {
if (shouldPrintVersion()) {
printVersion();
}
}
else if (shouldPrintUsage()) {
printUsage(false);
}
} else if (isCli()) {
} else {
if (exitCode != 0) {
{
}
else
{
}
}
}
}
// Add an extra space systematically
}
}
}
}
}