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

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

Introduction

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

Prototype

public String getClassname() 

Source Link

Document

Get the class name.

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  w  ww.  j av  a  2 s  .co  m*/
 * @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;
            }
        }
    }

}