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/merlin/merlin-plugin/src/java/org/apache/avalon/merlin/tools MerlinBean.java
Date Wed, 20 Aug 2003 23:50:22 GMT
mcconnell    2003/08/20 16:50:22

  Modified:    merlin/merlin-plugin/src/java/org/apache/avalon/merlin/tools
                        MerlinBean.java
  Log:
  Add a shutdown hook to handle orderly decommissioning within Maven.
  
  Revision  Changes    Path
  1.13      +36 -9     avalon-sandbox/merlin/merlin-plugin/src/java/org/apache/avalon/merlin/tools/MerlinBean.java
  
  Index: MerlinBean.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-plugin/src/java/org/apache/avalon/merlin/tools/MerlinBean.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MerlinBean.java	19 Aug 2003 07:34:31 -0000	1.12
  +++ MerlinBean.java	20 Aug 2003 23:50:22 -0000	1.13
  @@ -99,7 +99,7 @@
      /**
       * The kernel configuration file.
       */
  -    private File m_kernelPath;
  +    private File m_kernel;
   
      /**
       * The directory against which extension directories are resolved
  @@ -128,10 +128,6 @@
       */
       private int m_wait = 0; // not used
   
  -   /**
  -    * the kernel
  -    */
  -    private Kernel m_kernel;
   
       //-----------------------------------------------------
       // bean pattern setters
  @@ -162,7 +158,7 @@
   
       public void setKernel( File kernel ) 
       {
  -        m_kernelPath = kernel;
  +        m_kernel = kernel;
       }
   
      /**
  @@ -246,9 +242,9 @@
       */
       private URL getKernelURL() throws Exception
       {
  -        if( m_kernelPath != null )
  +        if( m_kernel != null )
           {
  -            if( m_kernelPath.exists() ) return m_kernelPath.toURL();
  +            if( m_kernel.exists() ) return m_kernel.toURL();
           }
           return null;
       }
  @@ -310,7 +306,8 @@
                   getDebugFlag() 
                 );
   
  -            m_kernel = new DefaultKernel( context );
  +            Kernel kernel = new DefaultKernel( context );
  +            setShutdownHook( kernel );
           }
           catch( Throwable e )
           {
  @@ -321,5 +318,35 @@
               throw new KernelException( message, e );
           }
       }
  +
  +   /**
  +    * 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