Home » geronimo-2.2-source-release » org.apache.geronimo.cli.daemon » [javadoc | source]

    1   /**
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   package org.apache.geronimo.cli.daemon;
   18   
   19   import java.io.OutputStream;
   20   
   21   import org.apache.commons.cli.Option;
   22   import org.apache.commons.cli.OptionBuilder;
   23   import org.apache.commons.cli.OptionGroup;
   24   import org.apache.geronimo.cli.BaseCLParser;
   25   import org.apache.geronimo.cli.PrintHelper;
   26   
   27   
   28   /**
   29    * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
   30    */
   31   public class DaemonCLParser extends BaseCLParser {
   32       private final static String ARGUMENT_NO_PROGRESS_SHORTFORM = "q";
   33       private final static String ARGUMENT_NO_PROGRESS = "quiet";
   34       
   35       private final static String ARGUMENT_LONG_PROGRESS_SHORTFORM = "l";
   36       private final static String ARGUMENT_LONG_PROGRESS = "long";
   37       
   38       private final static String ARGUMENT_MODULE_OVERRIDE_SHORTFORM = "o";
   39       private final static String ARGUMENT_MODULE_OVERRIDE = "override";
   40       
   41       public DaemonCLParser(OutputStream out) {
   42           super(out);
   43           addProgressOptions();
   44           addOverride();
   45       }
   46   
   47       public boolean isNoProgress() {
   48           return commandLine.hasOption(ARGUMENT_NO_PROGRESS_SHORTFORM);
   49       }
   50   
   51       public boolean isLongProgress() {
   52           return commandLine.hasOption(ARGUMENT_LONG_PROGRESS_SHORTFORM);
   53       }
   54   
   55       public String[] getOverride() {
   56           return commandLine.getOptionValues(ARGUMENT_MODULE_OVERRIDE_SHORTFORM);
   57       }
   58       
   59       public void displayHelp() {
   60           PrintHelper printHelper = new PrintHelper(out);
   61           printHelper.printHelp("java -jar bin/server.jar $options",
   62                   "\nThe following options are available:",
   63                   options,
   64                   "\nIn addition you may specify a replacement for var/config/config.xml by setting the property "
   65                           + "-Dorg.apache.geronimo.config.file=var/config/<my-config.xml>. "
   66                           + "This is resolved relative to the geronimo base directory.\n",
   67                   true);
   68       }
   69       
   70       protected void addOverride() {
   71           OptionBuilder optionBuilder = OptionBuilder.hasArgs().withArgName("moduleId ...");
   72           optionBuilder = optionBuilder.withLongOpt(ARGUMENT_MODULE_OVERRIDE);
   73           optionBuilder = optionBuilder.withDescription("USE WITH CAUTION!  Overrides the modules in "
   74                   + "var/config/config.xml such that only the modules listed on "
   75                   + "the command line will be started.  Note that many J2EE "
   76                   + "features depend on certain modules being started, so you "
   77                   + "should be very careful what you omit.  Any arguments after "
   78                   + "this are assumed to be module names.");
   79           Option option = optionBuilder.create(ARGUMENT_MODULE_OVERRIDE_SHORTFORM);
   80           options.addOption(option);
   81       }
   82   
   83       protected void addProgressOptions() {
   84           OptionGroup optionGroup = new OptionGroup();
   85   
   86           Option option = new Option(ARGUMENT_NO_PROGRESS_SHORTFORM,
   87                   ARGUMENT_NO_PROGRESS,
   88                   false,
   89                   "Suppress the normal startup progress bar. This is typically "
   90                           + "used when redirecting console output to a file, or starting "
   91                           + "the server from an IDE or other tool.");
   92           optionGroup.addOption(option);
   93   
   94           option = new Option(ARGUMENT_LONG_PROGRESS_SHORTFORM,
   95                   ARGUMENT_LONG_PROGRESS,
   96                   false,
   97                   "Write startup progress to the console in a format that is "
   98                           + "suitable for redirecting console output to a file, or starting "
   99                           + "the server from an IDE or other tool (doesn't use linefeeds to "
  100                           + "update the progress information that is used by default if you " + "don't specify "
  101                           + ARGUMENT_NO_PROGRESS + " or " + ARGUMENT_LONG_PROGRESS + ").");
  102           optionGroup.addOption(option);
  103   
  104           options.addOptionGroup(optionGroup);
  105       }
  106   
  107   }

Home » geronimo-2.2-source-release » org.apache.geronimo.cli.daemon » [javadoc | source]