larryi      01/09/01 08:00:47

  Modified:    src/share/org/apache/tomcat/startup StopTomcat.java
  Log:
  Update usage information.
  
  Allow tomcat.home to be set from a command line argument.
  
  Add "help" option that displays the usage information.
  
  Revision  Changes    Path
  1.12      +27 -9     
jakarta-tomcat/src/share/org/apache/tomcat/startup/StopTomcat.java
  
  Index: StopTomcat.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/StopTomcat.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StopTomcat.java   2001/08/22 16:56:28     1.11
  +++ StopTomcat.java   2001/09/01 15:00:47     1.12
  @@ -76,7 +76,7 @@
       private static StringManager sm =
        StringManager.getManager("org.apache.tomcat.resources");
   
  -    String tomcatHome;
  +    String tomcatHome=null;
   
       String host=null;
       int port=-1;
  @@ -85,6 +85,7 @@
       boolean commandLineParams=false;
       String secretFile=null;
       String args[];
  +    boolean help=false;
       
       public StopTomcat() 
       {
  @@ -136,13 +137,21 @@
        commandLineParams=true;
       }
   
  +    public void setHelp( boolean b ) {
  +        help = b;
  +    }
  +
       // Generic properties / attributes
   
       public void setAttribute(String s, Object o ) {
  +     if( s.equals("args")  )
  +         setArgs((String [])o);
       }
   
       public void setProperty( String name, String v ) {
  -
  +     if( !name.equals("stop")  )
  +            // unknown property
  +            help = true;
       }
   
       public void setArgs( String args[] ) {
  @@ -154,6 +163,10 @@
       public void execute() throws Exception {
        if( args!=null )
            processArgs( args );
  +        if( help ) {
  +            printUsage();
  +            return;
  +        }
        System.out.println(sm.getString("tomcat.stop"));
        try {
            stopTomcat(); // stop serving
  @@ -217,6 +230,8 @@
       }
       
       public String getTomcatHome() {
  +        if (tomcatHome != null)
  +            return tomcatHome;
        // Try to establish install and home locations
        String tchome=IntrospectionUtils.guessInstall("tomcat.install",
                                "tomcat.home","stop-tomcat.jar");
  @@ -325,13 +340,16 @@
       }
   
       public static void printUsage() {
  -     System.out.println("Usage: java org.apache.tomcat.startup.StopTomcat 
{options}");
  -     System.out.println("  Options are:");
  -        System.out.println("    -ajpid file                Use this file instead of 
conf/ajp12.id");
  -     System.out.println("    -pass                      Password to use");
  -        System.out.println("    -host                      Host to send the 
shutdown command");
  -     System.out.println("    -port                      Port to send the shutdown 
command");
  -     System.out.println("    -home dir                  Use this directory as 
tomcat.home,to find ajp12.id");
  +        System.out.println("Usage: java org.apache.tomcat.startup.StopTomcat 
{options}");
  +        System.out.println("  Options are:");
  +        System.out.println("    -ajpid file (or -secretFile file) Use this file 
instead of conf/ajp12.id");
  +        System.out.println("    -help                             Show this usage 
report");
  +        System.out.println("    -host                             Host to send the 
shutdown command");
  +        System.out.println("    -home dir (or -h dir)             Use this 
directory as tomcat.home,");
  +        System.out.println("                                          to find 
ajp12.id");
  +        System.out.println("    -pass                             Password to use");
  +        System.out.println("    -port                             Port to send the 
shutdown command");
  +        System.out.println("Note: the '-' on the options is optional.");
           System.out.println();
       }
       
  
  
  

Reply via email to