leif        2002/07/11 18:41:43

  Modified:    src/java/org/apache/avalon/phoenix/launcher
                        DaemonLauncher.java
  Log:
  Add some additional state tracking so that Phoenix will shutdown cleanly with
  Wrapper version 2.2.7.  The Wrapper had some bug fixes with shutdown isses and
  it was showing an error because Phoenix was recursively calling its stop method.
  
  Revision  Changes    Path
  1.10      +54 -28    
jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/launcher/DaemonLauncher.java
  
  Index: DaemonLauncher.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/launcher/DaemonLauncher.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DaemonLauncher.java       3 Apr 2002 13:50:07 -0000       1.9
  +++ DaemonLauncher.java       12 Jul 2002 01:41:43 -0000      1.10
  @@ -23,6 +23,15 @@
   public class DaemonLauncher
       implements WrapperListener, Observer
   {
  +    /**
  +     * In order to avoid calling the Wrapper stop method recursively, we need
  +     *  to keep track of whether or not the Wrapper already knows we are
  +     *  stopping.  Necessary because of the way the shutdown process in
  +     *  Phoenix works.   Ideally, we would unregister this Observer with
  +     *  CLIMain but we can't do that for security reasons.
  +     */
  +    private boolean m_ignoreUpdates = false;
  +    
       public Integer start( final String[] args )
       {
           Integer exitCodeInteger = null;
  @@ -65,6 +74,9 @@
   
       public int stop( final int exitCode )
       {
  +        // To avoid recursive calls, start ignoring updates.
  +        m_ignoreUpdates = true;
  +        
           Main.shutdown();
           return exitCode;
       }
  @@ -103,44 +115,58 @@
        */
       public void update( final Observable observable, final Object arg )
       {
  -        final String command = ( null != arg ) ? arg.toString() : "";
  -        if( command.equals( "restart" ) )
  +        if ( m_ignoreUpdates )
           {
  +            // Ignore this update
               if( WrapperManager.isDebugEnabled() )
               {
  -                System.out.println( "DaemonLauncher: restart requested." );
  -                System.out.flush();
  -            }
  -
  -            WrapperManager.restart();
  -
  -            if( WrapperManager.isDebugEnabled() )
  -            {
  -                //Should never get here???
  -                System.out.println( "DaemonLauncher: restart completed." );
  +                System.out.println( "DaemonLauncher: " + arg +
  +                    " request ignored because stop already called." );
                   System.out.flush();
               }
           }
  -        else if( command.equals( "shutdown" ) )
  +        else
           {
  -            if( WrapperManager.isDebugEnabled() )
  -            {
  -                System.out.println( "DaemonLauncher: shutdown requested." );
  -                System.out.flush();
  +            Thread.dumpStack();
  +            final String command = ( null != arg ) ? arg.toString() : "";
  +            if( command.equals( "restart" ) )
  +            {
  +                if( WrapperManager.isDebugEnabled() )
  +                {
  +                    System.out.println( "DaemonLauncher: restart requested." );
  +                    System.out.flush();
  +                }
  +    
  +                WrapperManager.restart();
  +    
  +                if( WrapperManager.isDebugEnabled() )
  +                {
  +                    //Should never get here???
  +                    System.out.println( "DaemonLauncher: restart completed." );
  +                    System.out.flush();
  +                }
  +            }
  +            else if( command.equals( "shutdown" ) )
  +            {
  +                if( WrapperManager.isDebugEnabled() )
  +                {
  +                    System.out.println( "DaemonLauncher: shutdown requested." );
  +                    System.out.flush();
  +                }
  +    
  +                WrapperManager.stop( 0 );
  +    
  +                if( WrapperManager.isDebugEnabled() )
  +                {
  +                    //Should never get here???
  +                    System.out.println( "DaemonLauncher: shutdown completed." );
  +                    System.out.flush();
  +                }
               }
  -
  -            WrapperManager.stop( 0 );
  -
  -            if( WrapperManager.isDebugEnabled() )
  +            else
               {
  -                //Should never get here???
  -                System.out.println( "DaemonLauncher: shutdown completed." );
  -                System.out.flush();
  +                throw new IllegalArgumentException( "Unknown action " + command );
               }
  -        }
  -        else
  -        {
  -            throw new IllegalArgumentException( "Unknown action " + command );
           }
       }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to