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-core/src/java/org/apache/avalon/merlin/kernel/impl DefaultKernel.java
Date Tue, 24 Jun 2003 16:04:50 GMT
mcconnell    2003/06/24 09:04:50

  Modified:    merlin   project.xml
               merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl
                        DefaultAppliance.java
               merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl
                        SingletonLifestyleHandler.java
               merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl
                        StandardBlock.java
               merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl
                        DefaultKernel.java
  Log:
  Add thread startup error evaluation.
  
  Revision  Changes    Path
  1.18      +1 -1      avalon-sandbox/merlin/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/project.xml,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- project.xml	23 Jun 2003 02:04:30 -0000	1.17
  +++ project.xml	24 Jun 2003 16:04:49 -0000	1.18
  @@ -76,7 +76,7 @@
         <id>vinayc</id>
         <email>vinayc@apache.org</email>
         <roles>
  -        <role>Testing and bug reporting.</role>
  +        <role>Testing and bug reporting, migration of tutorials from ant to maven.</role>
         </roles>
       </developer>
       <developer>
  
  
  
  1.16      +2 -11     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/DefaultAppliance.java
  
  Index: DefaultAppliance.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/DefaultAppliance.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- DefaultAppliance.java	22 Jun 2003 00:30:55 -0000	1.15
  +++ DefaultAppliance.java	24 Jun 2003 16:04:49 -0000	1.16
  @@ -458,16 +458,7 @@
               }
           }
   
  -        try
  -        {
  -            return m_handler.resolve( source, ref );
  -        } 
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Resolution failure in appliance: " + this;
  -            throw new LocatorException( ref, error, e );
  -        }
  +        return m_handler.resolve( source, ref );
       }
   
       /**
  
  
  
  1.4       +2 -2      avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/SingletonLifestyleHandler.java
  
  Index: SingletonLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/SingletonLifestyleHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SingletonLifestyleHandler.java	21 Jun 2003 17:10:02 -0000	1.3
  +++ SingletonLifestyleHandler.java	24 Jun 2003 16:04:49 -0000	1.4
  @@ -105,7 +105,7 @@
           } 
           catch( Throwable e )
           {
  -            final String error = "Singleton object access failure.";
  +            final String error = "Singleton object access failure in: " + getAppliance();
               throw new LocatorException( error, e );
           }
       }
  
  
  
  1.14      +66 -13    avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/StandardBlock.java
  
  Index: StandardBlock.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/StandardBlock.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- StandardBlock.java	22 Jun 2003 00:35:33 -0000	1.13
  +++ StandardBlock.java	24 Jun 2003 16:04:49 -0000	1.14
  @@ -636,25 +636,61 @@
               {
                   if( appliance.getActivationPolicy() )
                   {
  -                    if( getLogger().isDebugEnabled() )
  -                    {
  -                        final String message =
  -                          "activating component ("
  -                          + (i+1) + ":" + n + ") : "
  -                          + appliance;
  -                        getLogger().debug( message );
  -                    }
  -
                       if( appliance instanceof StandardBlock )
                       {
  +                        if( getLogger().isDebugEnabled() )
  +                        {
  +                            final String message =
  +                              "activating nested block ("
  +                              + (i+1) + ":" + n + ") : "
  +                              + appliance;
  +                            getLogger().debug( message );
  +                        }
  +
                           StandardBlock block = (StandardBlock) appliance;
                           ClassLoader loader = block.getEngineClassLoader();
                           BlockThread thread = new BlockThread( loader, block );
                           m_components.put( appliance, thread );
                           thread.start();
  +
  +                        //
  +                        // wait for the thread to complete startup
  +                        //
  +
  +                        while( !thread.started() )
  +                        {
  +                            try
  +                            {
  +                                Thread.currentThread().sleep( 300 );
  +                            }
  +                            catch( Throwable e )
  +                            {
  +                                // wakeup
  +                            }
  +                        }
  + 
  +                        //
  +                        // check for any errors raised during startup
  +                        //
  +
  +                        if( thread.getError() != null )
  +                        {
  +                            final String error =
  +                              "Composite deployment failure in: " + this;
  +                            throw new BlockException( error, thread.getError() );  
  +                        }
                       }
                       else
                       {
  +                        if( getLogger().isDebugEnabled() )
  +                        {
  +                            final String message =
  +                              "activating nested component ("
  +                              + (i+1) + ":" + n + ") : "
  +                              + appliance;
  +                            getLogger().debug( message );
  +                        }
  +
                           try
                           {
                               Object object = appliance.resolve( this );
  @@ -663,10 +699,8 @@
                           catch( Throwable e )
                           {
                               final String error =
  -                              "Could not establish a subsidiary appliance: "
  -                              + appliance
  -                              + " in block: " + this;
  -                            throw new BlockException( error, e );
  +                              "Composite deployment failure in: " + this;
  +                            throw new BlockException( error, e );  
                           }
                       }
                   }
  @@ -846,6 +880,11 @@
           private boolean m_terminate = false;
   
          /**
  +        * Local flag signalling that thread has completed startup.
  +        */
  +        private boolean m_started = false;
  +
  +       /**
           * Create of a new block thread.
           * @param loader the classloader to assign as the threads context classloader
           * @param block the block
  @@ -866,6 +905,15 @@
           }
   
          /**
  +        * Returns true if the thread is alive.
  +        * @return the started state.
  +        */
  +        public boolean started()
  +        {
  +            return m_started;
  +        }
  +
  +       /**
           * Return the block.
           * @return the block
           */
  @@ -896,6 +944,10 @@
               {
                   m_error = e;
               }
  +            finally
  +            {
  +                m_started = true;
  +            }
   
               while( !m_terminate )
               {
  @@ -918,6 +970,7 @@
               {
                   m_block.release( m_instance, this );
               }
  +
           }
   
          /**
  
  
  
  1.24      +2 -3      avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernel.java
  
  Index: DefaultKernel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernel.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- DefaultKernel.java	24 Jun 2003 07:31:04 -0000	1.23
  +++ DefaultKernel.java	24 Jun 2003 16:04:50 -0000	1.24
  @@ -662,8 +662,7 @@
           catch( Throwable e )
           {
               final String error =
  -              "Unable to deploy block.\nBlock: " 
  -              + block.getName();
  +              "Root block deployment failure." ;
               throw new KernelException( error, e );
           }
   
  
  
  

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


Mime
View raw message