isSuccess = false; System.err.print( "failed with error: " + t.getMessage() );
try { new InitialLdapContext( env, null ); isSuccess = false; System.err.print( "shutdown request failed with error: " + t.getMessage() ); } catch( CommunicationException e ) { isSuccess = true; }
    public void execute( CommandLine cmd ) throws Exception    {        executeThread = Thread.currentThread();        processOptions( cmd );        if ( isDebugEnabled() )        {            System.out.println( "Parameters for GracefulShutdown extended request:" );            System.out.println( "port = " + port );            System.out.println( "host = " + host );            System.out.println( "password = " + password );            System.out.println( "delay = " + delay );            System.out.println( "timeOffline = " + timeOffline );        }        Hashtable env = new Hashtable();        env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );        env.put( "java.naming.provider.url", "ldap://" + host + ":" + port );        env.put( "java.naming.security.principal", "uid=admin,ou=system" );        env.put( "java.naming.security.credentials", password );        env.put( "java.naming.security.authentication", "simple" );        LdapContext ctx = new InitialLdapContext( env, null );        if ( !isQuietEnabled() )        {            System.out.println( "Connection to the server established.\n"                + "Sending extended request and blocking for shutdown:" );            isWaiting = true;            Thread t = new Thread( new Ticker() );            t.start();        }        try        {            ctx.extendedOperation( new GracefulShutdownRequest( 0, timeOffline, delay ) );            isSuccess = true;        }        catch ( Throwable t )        {            isSuccess = false;            System.err.print( "failed with error: " + t.getMessage() );        }        isWaiting = false;        ctx.close();    }