avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/handler ComponentFactory.java
Date Thu, 08 May 2003 21:24:46 GMT
bloritsch    2003/05/08 14:24:46

  Modified:    fortress/src/java/org/apache/avalon/fortress/impl
                        AbstractContainer.java
               fortress/src/java/org/apache/avalon/fortress/impl/handler
                        ComponentFactory.java
  Log:
  handle lengage errors on initialization, and convert them to regular exceptions
  
  Revision  Changes    Path
  1.25      +16 -5     avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/AbstractContainer.java
  
  Index: AbstractContainer.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/AbstractContainer.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- AbstractContainer.java	2 May 2003 04:15:20 -0000	1.24
  +++ AbstractContainer.java	8 May 2003 21:24:46 -0000	1.25
  @@ -622,7 +622,7 @@
               try
               {
                   final ComponentHandler handler = entry.getHandler();
  -                
  +
                   // Depending on the activation policy of the component decide
                   //  how to initialize the component.  Make sure that we can
                   //  perform the specified activation policy, if not modify it.
  @@ -635,7 +635,7 @@
                           activation = ComponentHandlerMetaData.ACTIVATION_INLINE;
                       }
                   }
  -                
  +
                   // We now have an activation policy we can handle.
                   switch ( activation )
                   {
  @@ -647,12 +647,12 @@
                           new PrepareHandlerCommand( handler, getLogger() );
                       m_commandQueue.enqueue( element );
                       break;
  -                    
  +
                   case ComponentHandlerMetaData.ACTIVATION_INLINE:
                       // Initialize the component now.
                       handler.prepareHandler();
                       break;
  -                    
  +
                   default: // ComponentHandlerMetaData.ACTIVATION_LAZY
                       if ( getLogger().isDebugEnabled() )
                       {
  @@ -674,6 +674,17 @@
                       getLogger().warn( message, e );
                   }
                   buffer.add( e );
  +            }
  +            catch ( final LinkageError le )
  +            {
  +                final String cName = entry.getMetaData().getName();
  +
  +                if ( getLogger().isWarnEnabled() )
  +                {
  +                    final String message = "Could not initialize component " + cName;
  +                    getLogger().warn( message, le );
  +                }
  +                buffer.add( le );
               }
           }
   
  
  
  
  1.24      +47 -37    avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/handler/ComponentFactory.java
  
  Index: ComponentFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/handler/ComponentFactory.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- ComponentFactory.java	25 Apr 2003 13:31:03 -0000	1.23
  +++ ComponentFactory.java	8 May 2003 21:24:46 -0000	1.24
  @@ -64,6 +64,7 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.CascadingException;
   import org.apache.excalibur.instrument.AbstractLogEnabledInstrumentable;
   import org.apache.excalibur.instrument.CounterInstrument;
   import org.apache.excalibur.mpool.ObjectFactory;
  @@ -171,47 +172,56 @@
       public Object newInstance()
           throws Exception
       {
  -        final Object component = m_componentClass.newInstance();
  +        final Object component;
   
  -        if ( getLogger().isDebugEnabled() )
  +        try
           {
  -            final String message =
  -                "ComponentFactory creating new instance of " +
  -                m_componentClass.getName() + ".";
  -            getLogger().debug( message );
  -        }
  -
  -        ContainerUtil.enableLogging( component, m_componentLogger );
  +            component = m_componentClass.newInstance();
   
  -        if ( component instanceof Loggable )
  -        {
  -            final org.apache.log.Logger logkitLogger =
  -                LogKit2AvalonLoggerAdapter.createLogger( m_componentLogger );
  -            ( (Loggable) component ).setLogger( logkitLogger );
  +            if ( getLogger().isDebugEnabled() )
  +            {
  +                final String message =
  +                    "ComponentFactory creating new instance of " +
  +                    m_componentClass.getName() + ".";
  +                getLogger().debug( message );
  +            }
  +
  +            ContainerUtil.enableLogging( component, m_componentLogger );
  +
  +            if ( component instanceof Loggable )
  +            {
  +                final org.apache.log.Logger logkitLogger =
  +                    LogKit2AvalonLoggerAdapter.createLogger( m_componentLogger );
  +                ( (Loggable) component ).setLogger( logkitLogger );
  +            }
  +
  +            ContainerUtil.contextualize( component, m_context );
  +            if ( component instanceof Composable )
  +            {
  +                ContainerUtil.compose( component, new WrapperComponentManager( m_serviceManager
) );
  +            }
  +            ContainerUtil.service( component, m_serviceManager );
  +            ContainerUtil.configure( component, m_configuration );
  +
  +            if ( component instanceof Parameterizable )
  +            {
  +                ContainerUtil.parameterize( component, Parameters.fromConfiguration( m_configuration
) );
  +            }
  +
  +            m_extManager.executeCreationExtensions( component, m_context );
  +
  +            ContainerUtil.initialize( component );
  +
  +            ContainerUtil.start( component );
  +
  +            if ( m_newInstance.isActive() )
  +            {
  +                m_newInstance.increment();
  +            }
           }
  -
  -        ContainerUtil.contextualize( component, m_context );
  -        if ( component instanceof Composable )
  -        {
  -            ContainerUtil.compose( component, new WrapperComponentManager( m_serviceManager
) );
  -        }
  -        ContainerUtil.service( component, m_serviceManager );
  -        ContainerUtil.configure( component, m_configuration );
  -
  -        if ( component instanceof Parameterizable )
  -        {
  -            ContainerUtil.parameterize( component, Parameters.fromConfiguration( m_configuration
) );
  -        }
  -
  -        m_extManager.executeCreationExtensions( component, m_context );
  -
  -        ContainerUtil.initialize( component );
  -
  -        ContainerUtil.start( component );
  -
  -        if ( m_newInstance.isActive() )
  +        catch (LinkageError le)
           {
  -            m_newInstance.increment();
  +            throw new CascadingException("Could not load component", le);
           }
   
           return component;
  
  
  

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


Mime
View raw message