Example usage for org.apache.commons.launcher LaunchCommand getWaitforchild

List of usage examples for org.apache.commons.launcher LaunchCommand getWaitforchild

Introduction

In this page you can find the example usage for org.apache.commons.launcher LaunchCommand getWaitforchild.

Prototype

public boolean getWaitforchild() 

Source Link

Document

Get the waitForChild flag.

Usage

From source file:org.apache.catalina.launcher.CatalinaLaunchFilter.java

/**
 * This method allows dynamic configuration and error checking of the
 * attributes and nested elements in a "launch" task that is launching a
 * Catalina application. This method evaluates the nested command line
 * arguments and, depending on which class is specified in the task's
 * "classname" attribute, may force the application to run
 * in the foreground by forcing the "waitforchild" attribute to "true".
 *
 * @param launchCommand a configured instance of the {@link LaunchTask}
 *  class//from   www  .j  av a2  s  .com
 * @throws BuildException if any errors occur
 */
public void filter(LaunchCommand launchCommand) throws BuildException {

    // Get attributes
    String mainClassName = launchCommand.getClassname();
    boolean waitForChild = launchCommand.getWaitforchild();
    ArrayList argsList = launchCommand.getArgs();
    String[] args = (String[]) argsList.toArray(new String[argsList.size()]);

    // Evaluate main class
    if (CatalinaLaunchFilter.CATALINA_BOOTSTRAP_CLASS_NAME.equals(mainClassName)) {
        // If "start" is not the last argument, make "waitforchild" true
        if (args.length == 0 || !"start".equals(args[args.length - 1])) {
            launchCommand.setWaitforchild(true);
            return;
        }

        // If "start" is the last argument, make sure that all of the
        // preceding arguments are OK for running in the background
        for (int i = 0; i < args.length - 1; i++) {
            if ("-config".equals(args[i])) {
                // Skip next argument since it should be a file
                if (args.length > i + 1) {
                    i++;
                } else {
                    launchCommand.setWaitforchild(true);
                    return;
                }
            } else if ("-debug".equals(args[i])) {
                // Do nothing
            } else if ("-nonaming".equals(args[i])) {
                // Do nothing
            } else {
                launchCommand.setWaitforchild(true);
                return;
            }
        }
    }

}