Yep, there's a class in the cvs repository that does command line shutdown
using the shutdown mbean.  Source below...


On (29/05/01 19:09), Jonas Bergstr�m wrote:
> Hi all.
> 
> Is it possible stop JBoss from the command line, just as it is with Tomcat?
> I want to schedule JBoss start and stop when running my tests.
> I guess it would be possible to do it on windows by using services, but I
> want to do it the same way both on windows and unix/linux/*.
> 
> 
> Thanks / Jonas


/*
 * JBoss, the OpenSource EJB server
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package org.jboss;

import java.io.*;
import java.net.*;
import java.util.*;

/**
  * 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 $
  */
public class 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
        }
    }
}


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

Reply via email to