You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by do...@apache.org on 2002/02/01 13:47:15 UTC

cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor DefaultEmbeddor.java

donaldp     02/02/01 04:47:15

  Modified:    src/java/org/apache/avalon/phoenix/components/embeddor
                        DefaultEmbeddor.java
  Log:
  Made it so that the embeddor will stop running if there are zero applications in the kernel. It will wake up once a second to check for this condition.
  
  Revision  Changes    Path
  1.41      +25 -10    jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/DefaultEmbeddor.java
  
  Index: DefaultEmbeddor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/DefaultEmbeddor.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- DefaultEmbeddor.java	11 Dec 2001 10:13:33 -0000	1.40
  +++ DefaultEmbeddor.java	1 Feb 2002 12:47:15 -0000	1.41
  @@ -182,20 +182,35 @@
           deployDefaultApplications();
   
           // loop until <code>Shutdown</code> is created.
  -        while( !m_shutdown )
  +        while( true )
           {
               // wait() for shutdown() to take action...
  -            try
  +            if( m_shutdown || emptyKernel() )
               {
  -                synchronized( this )
  -                {
  -                    wait();
  -                }
  +                break;
               }
  -            catch( final InterruptedException e )
  +            gotoSleep();
  +        }
  +    }
  +
  +    private boolean emptyKernel()
  +    {
  +        final String[] names = m_kernel.getApplicationNames();
  +        return ( 0 == names.length );
  +    }
  +
  +    private void gotoSleep()
  +    {
  +        try
  +        {
  +            synchronized( this )
               {
  +                wait( 1000 );
               }
           }
  +        catch( final InterruptedException e )
  +        {
  +        }
       }
   
       /**
  @@ -246,7 +261,7 @@
   
       /**
        * Ask the embeddor to restart itself if this operation is supported.
  -     * 
  +     *
        * @exception UnsupportedOperationException if restart not supported
        */
       public void restart()
  @@ -254,10 +269,10 @@
       {
           try
           {
  -            //Pass a message back to original invoker. 
  +            //Pass a message back to original invoker.
               //We use an ActionListener rather than operating on some more meaningful
               //event system as ActionListener and friends can be loaded from system
  -            //ClassLoader and thus the Embeddor does not have to share a common 
  +            //ClassLoader and thus the Embeddor does not have to share a common
               //classloader ancestor with invoker
               final ActionListener listener =
                   (ActionListener)m_context.get( ActionListener.class.getName() );
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>