avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/kernel/impl/src/java/org/apache/avalon/merlin/impl DefaultFactory.java
Date Fri, 05 Dec 2003 03:17:01 GMT
mcconnell    2003/12/04 19:17:01

  Modified:    kernel/impl/src/java/org/apache/avalon/merlin/impl
                        DefaultFactory.java
  Log:
  Add a shutdown hook in the factory.
  
  Revision  Changes    Path
  1.7       +31 -0     avalon-sandbox/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultFactory.java
  
  Index: DefaultFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultFactory.java	5 Dec 2003 01:29:05 -0000	1.6
  +++ DefaultFactory.java	5 Dec 2003 03:17:01 -0000	1.7
  @@ -393,6 +393,7 @@
   
           Kernel kernel = 
             createKernel( getLogger(), criteria, m_system, m_application );
  +        setShutdownHook( kernel );
           if( criteria.isAutostartEnabled() )
           {
               try
  @@ -791,6 +792,36 @@
       {
           String file = config.getAttribute( "location" );
           return new FileTargetProvider( file );
  +    }
  +
  +
  +   /**
  +    * Create a shutdown hook that will trigger shutdown of the supplied kernel.
  +    * @param kernel the kernel to be shutdown
  +    */
  +    private void setShutdownHook( final Kernel kernel )
  +    {
  +        //
  +        // Create a shutdown hook to trigger clean disposal of the
  +        // Merlin kernel
  +        //
  +
  +        Runtime.getRuntime().addShutdownHook(
  +          new Thread()
  +          {
  +              public void run()
  +              {
  +                  try
  +                  {
  +                      kernel.shutdown();
  +                  }
  +                  catch( Throwable e )
  +                  {
  +                      // ignore it
  +                  }
  +              }
  +          }
  +        );
       }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message