User: user57  
  Date: 01/07/12 18:22:58

  Modified:    src/main/org/jboss Shutdown.java
  Log:
   o re-indented & using different URL contructor
  
  Revision  Changes    Path
  1.2       +55 -41    jboss/src/main/org/jboss/Shutdown.java
  
  Index: Shutdown.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/Shutdown.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Shutdown.java     2001/03/27 16:32:39     1.1
  +++ Shutdown.java     2001/07/13 01:22:58     1.2
  @@ -7,50 +7,64 @@
   
   package org.jboss;
   
  -import java.io.*;
  -import java.net.*;
  -import java.util.*;
  +import java.net.URL;
   
   /**
  -  * Provides an OS-independent way of shutting down JBoss.  This
  -  * works by accessing the JMX server and giving it the shutdown
  -  * command.  The host to the JMX server can be passed in as well
  -  * as the port number.  If neither is supplied, the defaults of
  -  * localhost and 8082 are used.
  -  * <br>
  -  * <br>
  -  * Usage:  java org.jboss.Shutdown [host] [port]
  -  * <br>
  -  * <br>
  -  *
  -  * @author Dewayne McNair ([EMAIL PROTECTED])
  -  * @version $Revision: 1.1 $
  -  */
  + * Provides an OS-independent way of shutting down JBoss.  This
  + * works by accessing the JMX server and giving it the shutdown
  + * command.  The host to the JMX server can be passed in as well
  + * as the port number.  If neither is supplied, the defaults of
  + * <tt>localhost</tt> and <tt>8082</tt> are used.
  + * 
  + * <h3>Usage:</h3>
  + * <pre>
  + * java org.jboss.Shutdown [host] [port]
  + * </pre>
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Dewayne McNair</a>
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
  + * @version $Revision: 1.2 $
  + */
   public class Shutdown
   {
  -    private static final String command =
  -         
"/InvokeAction//DefaultDomain%3Atype%3DShutdown/action=shutdown?action=shutdown";
  +   private static final String COMMAND =
  +      
"/InvokeAction//DefaultDomain%3Atype%3DShutdown/action=shutdown?action=shutdown";
   
  -    public static void main (String argv[])
  -    {
  -        String host = "localhost";
  -        String port = "8082";
  -
  -        if (argv.length == 1)
  -            host = argv[0];
  -
  -        if (argv.length == 2)
  -            port = argv[1];
  -
  -        try
  -        {
  -            URL url = new URL ("http://"; + host + ":" + port + command);
  -            url.getContent();
  -        }
  -        catch (Exception e)
  -        {
  -            // we do nothing because even if everything went
  -            // right, ie JBoss is shutdown, we'd get an exception
  -        }
  -    }
  +   /**
  +    * Parse the command line and shutdown the remote server.
  +    *
  +    * @param argv       Comamne line arguments.
  +    *
  +    * @throws Exception         Invalid port number.
  +    */
  +   public static void main(final String argv[]) throws Exception
  +   {
  +      String host = "localhost";
  +      int port = 8082;
  +
  +      if (argv.length == 1) {
  +         host = argv[0];
  +      }
  +
  +      if (argv.length == 2) {
  +         port = Integer.parseInt(argv[1]);
  +      }
  +
  +      shutdown(host, port);
  +   }
  +
  +   /**
  +    * Connect to the JBoss servers HTML JMX adapter and invoke the
  +    * shutdown service.
  +    */
  +   public static void shutdown(final String host, final int port) {
  +      try {
  +         URL url = new URL("http", host, port, COMMAND);
  +         url.getContent();
  +      }
  +      catch (Exception ignore) {
  +         // we do nothing because even if everything went
  +         // right, ie JBoss is shutdown, we'd get an exception
  +      }
  +   }
   }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to