avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/all/src/scratchpad/org/apache/avalon/excalibur/service ServiceFactory.java
Date Fri, 03 May 2002 05:00:37 GMT
mcconnell    02/05/02 22:00:37

  Modified:    all/src/scratchpad/org/apache/avalon/excalibur/service
                        ServiceFactory.java
  Log:
  no message
  
  Revision  Changes    Path
  1.10      +328 -292  jakarta-avalon-excalibur/all/src/scratchpad/org/apache/avalon/excalibur/service/ServiceFactory.java
  
  Index: ServiceFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/all/src/scratchpad/org/apache/avalon/excalibur/service/ServiceFactory.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ServiceFactory.java	2 May 2002 19:23:50 -0000	1.9
  +++ ServiceFactory.java	3 May 2002 05:00:37 -0000	1.10
  @@ -8,35 +8,51 @@
   package org.apache.avalon.excalibur.service;
   
   import java.io.File;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
   import java.util.Map;
  +import java.util.Hashtable;
  +import java.util.Enumeration;
   import java.util.Vector;
  -import org.apache.excalibur.mpool.Pool;
  -import org.apache.avalon.framework.activity.Disposable;
  -import org.apache.avalon.framework.activity.Initializable;
  -import org.apache.avalon.framework.activity.Startable;
  -import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.framework.component.Composable;
  +
  +import org.apache.log.Hierarchy;
  +import org.apache.log.Priority;
  +import org.apache.log.output.io.StreamTarget;
  +import org.apache.avalon.framework.logger.Logger;
  +import org.apache.avalon.framework.CascadingRuntimeException;
  +import org.apache.avalon.framework.CascadingException;
  +import org.apache.avalon.framework.logger.LogKitLogger;
  +import org.apache.avalon.framework.logger.AvalonFormatter;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.logger.LogEnabled;
  +import org.apache.avalon.framework.parameters.Parameterizable;
  +import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.configuration.DefaultConfiguration;
  +import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
   import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.avalon.framework.context.Contextualizable;
  -import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.avalon.framework.logger.LogEnabled;
  -import org.apache.avalon.framework.logger.Logger;
  -import org.apache.avalon.framework.parameters.Parameterizable;
  -import org.apache.avalon.framework.parameters.Parameters;
  -import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.context.ContextException;
  +import org.apache.avalon.framework.component.Component;
  +import org.apache.avalon.framework.component.Composable;
  +import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.service.Serviceable;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.activity.Startable;
  +import org.apache.avalon.framework.activity.Disposable;
  +
  +import org.apache.avalon.excalibur.configuration.CascadingConfiguration;
  +import org.apache.excalibur.mpool.Pool;
   
   /**
  - * The <code>ServiceFactory</code> class provides support for the
  + * The <code>ServiceFactory</code> class provides support for the 
    * instantiation of objects based on supplied service meta-info.
    */
  -class ServiceFactory extends AbstractLogEnabled implements Configurable, Disposable
  +class ServiceFactory extends AbstractLogEnabled implements Configurable, Initializable,
Disposable
   {
       private File m_root;
       private boolean m_verbose;
  @@ -52,9 +68,9 @@
       private Hashtable m_services = new Hashtable();
       private Hashtable m_lookup = new Hashtable();
   
  -    public ServiceFactory( File base, boolean verbose ) throws Exception
  +    public ServiceFactory( File root, boolean verbose ) throws Exception
       {
  -        m_root = base;
  +        m_root = root;
           m_verbose = verbose;
       }
   
  @@ -63,75 +79,85 @@
           m_config = config;
       }
   
  -    /**
  -     * Initialize the factory.
  -     */
  +    //=======================================================================
  +    // Initializable
  +    //=======================================================================
  +
  +   /**
  +    * Initialize the factory.
  +    */
       public void initialize() throws Exception
       {
           m_base_logger = getLogger();
           super.enableLogging( m_base_logger.getChildLogger( "loader" ).getChildLogger( "factory"
) );
  -        m_registry = new ServiceRegistry( m_verbose );
  -        m_registry.enableLogging( getLogger().getChildLogger( "registry" ) );
  +
  +        m_registry = new ServiceRegistry( m_root, m_verbose );
  +        m_registry.enableLogging( getLogger().getChildLogger("registry") );
           m_registry.configure( m_config );
           m_registry.initialize();
       }
   
  -    /**
  -     * Populates the set of available services based on a supplied
  -     * vector of jar files.  The implementation delegates registration
  -     * actions to the factories registry.
  -     * @param list a list of jar files
  -     */
  +    //=======================================================================
  +    // ServiceFactory
  +
  +    //=======================================================================
  +
  +   /**
  +    * Populates the set of available services based on a supplied 
  +    * vector of jar files.  The implementation delegates registration
  +    * actions to the factories registry.
  +    * @param list a list of jar files
  +    */
       public void register( Vector list ) throws PipelineException
       {
           m_registry.register( list );
       }
   
  -    /**
  -     * Validates that the set of dependecies declared for a given
  -     * implementation can be resolved and that all dependencies
  -     * can be validated.
  -     * @param info the <code>UnitInfo</code> to validate
  -     */
  +   /**
  +    * Validates that the set of dependecies declared for a given 
  +    * implementation can be resolved and that all dependencies 
  +    * can be validated.
  +    * @param info the <code>UnitInfo</code> to validate
  +    */
       public void validate( UnitInfo info ) throws Exception
       {
           DependencyInfo[] dependencies = info.getDependencies();
  -        for( int i = 0; i < dependencies.length; i++ )
  +        for( int i=0; i<dependencies.length; i++ )
           {
  -            DependencyInfo d = dependencies[ i ];
  -            if( m_registry.lookup( d ) == null )
  -                throw new Exception(
  -                    "Could not resolve dependent service " + d.getRole()
  -                    + " for block " + info.getName() );
  +            DependencyInfo d = dependencies[i];
  +            if( m_registry.lookup( d ) == null ) throw new Exception(
  +               "Could not resolve dependent service '" + d.getRole() 
  +                 + "' with service: '" + d.getService().getInterface().getName() 
  +                 + "' for block '" + info.getName() + "'"  );
           }
       }
   
  -    /**
  -     * Dynamic creation of a <code>ServiceManager</code> based on a set of
  -     * supplied dependencies and container configuration.
  -     */
  -    private ServiceManager createServiceManager( UnitInfo info, Logger base )
  -        throws ServiceException
  +   /**
  +    * Dynamic creation of a <code>ServiceManager</code> based on a set of 
  +    * supplied dependencies and container configuration.
  +    */
  +    private ServiceManager createServiceManager( UnitInfo info, Logger base ) 
  +      throws ServiceException
       {
           return new DefaultServiceManager( getProviders( info, base ) );
       }
   
  -    /**
  -     * Dynamic creation of a <code>ComponentManager</code> based on a set of
  -     * supplied dependencies and container configuration.
  -     */
  -    private ComponentManager createComponentManager( UnitInfo info, Logger base )
  -        throws ServiceException
  +   /**
  +    * Dynamic creation of a <code>ComponentManager</code> based on a set of

  +    * supplied dependencies and container configuration.
  +    */
  +    private ComponentManager createComponentManager( UnitInfo info, Logger base ) 
  +      throws ServiceException
       {
           return new DefaultComponentManager( getProviders( info, base ) );
       }
   
  -    /**
  -     * Returns a table of providers based on the supplied meta-info and
  -     * container configuration.
  -     * @param info meta-info about the container
  -     * @param composition the container composition configuration
  -     */
  +   /**
  +    * Returns a table of providers based on the supplied meta-info and 
  +    * container configuration.
  +    * @param info meta-info about the container
  +    * @param composition the container composition configuration
  +    */
       private Map getProviders( UnitInfo unit, Logger base ) throws ServiceException
       {
           DependencyInfo[] dependencies = unit.getDependencies();
  @@ -139,10 +165,10 @@
   
           try
           {
  -            for( int i = 0; i < dependencies.length; i++ )
  +            for( int i=0; i<dependencies.length; i++ )
               {
  -                DependencyInfo info = dependencies[ i ];
  -                providers.put( info.getRole(), getProvider( info, base ) );
  +                DependencyInfo info = dependencies[i];
  +                providers.put( info.getRole(), getProvider( unit, info, base ) );
               }
               return providers;
           }
  @@ -153,19 +179,17 @@
           }
       }
   
  -    /**
  -     * Create a provider implementation for a class identified by a
  -     * supplied met-info instance and a configuration.
  -     * @param info the dependecy declaration
  -     * @param profile the configuration profile
  -     */
  -    private Object getProvider( DependencyInfo info, Logger base ) throws Exception
  +   /**
  +    * Create a provider implementation.
  +    * @param info the dependecy declaration
  +    * @param profile the configuration profile
  +    */
  +    private Object getProvider( UnitInfo unit, DependencyInfo info, Logger base ) throws
Exception
       {
   
           UnitInfo block_info = m_registry.lookup( info );
  -        if( block_info == null )
  -            throw new IllegalStateException(
  -                "Registry returned a null block info." );
  +        if( block_info == null ) throw new IllegalStateException(
  +          "Registry returned a null block info.");
   
           //
           // Establish the type of object.
  @@ -183,72 +207,66 @@
   
           switch( policy )
           {
  -            case UnitInfo.SINGLETON_LIFETIME_POLICY:
  -
  -                //
  -                // return a singleton instance
  -                //
  -
  -                provider = m_singletons.get( provider_class );
  -                if( provider == null )
  -                {
  -                    if( m_verbose )
  -                        if( getLogger().isDebugEnabled() )
  -                            getLogger().debug(
  -                                "generating singleton provider" );
  -
  -                    // create and pipeline the singleton instance and
  -                    // add it to the list of singletons
  -
  -                    Object object = execute( block_info, info.getRole(), base );
  -                    provider = new SingletonProvider( object, info.getRole() );
  -                    m_singletons.put( provider_class, provider );
  -                }
  -                return provider;
  +            case UnitInfo.SINGLETON_LIFETIME_POLICY :
   
  -            case UnitInfo.POOLED_LIFETIME_POLICY:
  -
  -                provider = m_pools.get( provider_class );
  -                if( provider == null )
  -                {
  -                    if( m_verbose )
  -                        if( getLogger().isDebugEnabled() )
  -                            getLogger().debug(
  -                                "generating pooled provider" );
  -
  -                    // create and pipeline the singleton instance and
  -                    // add it to the list of singletons
  -
  -                    Object object = execute( block_info, info.getRole(), base );
  -                    provider = new PooledProvider( (Pool)object, info.getRole() );
  -                    m_pools.put( provider_class, provider );
  -                }
  -                return provider;
  +              //
  +              // return a singleton instance
  +              //
  +
  +              provider = m_singletons.get( provider_class );
  +              if( provider == null )
  +              {
  +                  if( m_verbose ) if( getLogger().isDebugEnabled() ) getLogger().debug(

  +                    "generating singleton provider" );
  +
  +                  // create and pipeline the singleton instance and 
  +                  // add it to the list of singletons
  +
  +                  Object object = execute( unit, block_info, info.getRole(), base );
  +                  provider = new SingletonProvider( object, info.getRole() );
  +                  m_singletons.put( provider_class, provider );
  +              }
  +              return provider;
  +
  +            case UnitInfo.POOLED_LIFETIME_POLICY :
  +
  +              provider = m_pools.get( provider_class );
  +              if( provider == null )
  +              {
  +                  if( m_verbose ) if( getLogger().isDebugEnabled() ) getLogger().debug(

  +                    "generating pooled provider" );
  +
  +                  // create and pipeline the singleton instance and 
  +                  // add it to the list of singletons
  +
  +                  Object object = execute( unit, block_info, info.getRole(), base );
  +                  provider = new PooledProvider( (Pool) object, info.getRole() );
  +                  m_pools.put( provider_class, provider );
  +              }
  +              return provider;
   
               default :
   
  -                //
  -                // UnitInfo.TRANSIENT_LIFETIME_POLICY :
  -                // new service instances are always created on invocation of
  -                // a service lookup
  -                //
  -
  -                provider = m_transients.get( provider_class );
  -                if( provider == null )
  -                {
  -                    if( m_verbose )
  -                        if( getLogger().isDebugEnabled() )
  -                            getLogger().debug(
  -                                "generating transient provider" );
  -
  -                    // create and pipeline the singleton instance and
  -                    // add it to the list of singletons
  -
  -                    provider = new TransientProvider( this, block_info, info.getRole()
);
  -                    m_transients.put( provider_class, provider );
  -                }
  -                return provider;
  -        }
  +              //
  +              // UnitInfo.TRANSIENT_LIFETIME_POLICY :
  +              // new service instances are always created on invocation of
  +              // a service lookup
  +              //
  +
  +              provider = m_transients.get( provider_class );
  +              if( provider == null )
  +              {
  +                  if( m_verbose ) if( getLogger().isDebugEnabled() ) getLogger().debug(

  +                    "generating transient provider" );
  +
  +                  // create and pipeline the singleton instance and 
  +                  // add it to the list of singletons
  +
  +                  provider = new TransientProvider( this, block_info, info.getRole() );
  +                  m_transients.put( provider_class, provider );
  +              }
  +              return provider;
  +         }
       }
   
       public Object pipeline( UnitInfo info ) throws Exception
  @@ -258,34 +276,27 @@
   
       public Object pipeline( UnitInfo info, String role ) throws Exception
       {
  -        Logger logger = getLogger();
  -
  -        try
  -        {
  -            return execute( info, role, m_base_logger );
  -        }
  -        catch( Exception e )
  -        {
  -            enableLogging( logger );
  -            throw e;
  -        }
  -        finally
  -        {
  -            enableLogging( logger );
  -        }
  +        return execute( null, info, role, m_base_logger ); 
       }
   
  -    private Object execute( UnitInfo info, String role, Logger logger ) throws Exception
  +    private Object execute( UnitInfo container, UnitInfo info, String role, Logger logger
) throws Exception
       {
   
  -        if( m_verbose )
  -            if( getLogger().isDebugEnabled() )
  -                getLogger().debug(
  -                    "pipelining " + role + " (" + info.getClassName() + ")" );
  +        if( m_verbose ) if( getLogger().isDebugEnabled() ) getLogger().debug(
  +          "pipelining " + role + " (" + info.getClassName() + ")");
   
  -        enableLogging( getLogger().getChildLogger( role ) );
  +        //enableLogging( getLogger().getChildLogger( role ) );
   
  -        Configuration config = info.getConfiguration();
  +        Configuration config = null;
  +        if( container != null )
  +        {
  +            config = new CascadingConfiguration( 
  +              container.getConfiguration().getChild(role), info.getConfiguration());
  +        }
  +        else
  +        {
  +            config = info.getConfiguration();
  +        }
   
           //
           // create and pipeline the new instance
  @@ -307,154 +318,177 @@
           //
   
           Logger base = logger.getChildLogger( role );
  -        if( m_object instanceof LogEnabled )
  -            try
  -            {
  -                if( m_verbose ) getLogger().debug( "applying logger" );
  -                ( (LogEnabled)m_object ).enableLogging( base );
  -            }
  -            catch( Throwable e )
  -            {
  -                final String error = "Failed to assign a logger channel.";
  -                throw new PipelineException( error, e );
  -            }
  +        if( m_object instanceof LogEnabled ) try
  +        {
  +            if( m_verbose ) getLogger().debug( "applying logger" );
  +            ((LogEnabled)m_object).enableLogging( base );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Failed to assign a logger channel.";
  +            getLogger().error( error, e );
  +            handleDisposal( m_object );
  +            throw new PipelineException( error, e );
  +        }
   
           //
           // configure the object
           //
   
  -        if( m_object instanceof Configurable )
  -            try
  -            {
  -                if( m_verbose ) getLogger().debug( "configuration" );
  -                ( (Configurable)m_object ).configure( config );
  -            }
  -            catch( Throwable e )
  -            {
  -                final String error = "Failed to configure an object.";
  -                throw new PipelineException( error, e );
  -            }
  -        else if( m_object instanceof Parameterizable )
  -            try
  -            {
  -                if( m_verbose ) getLogger().debug( "parameterization" );
  -                ( (Parameterizable)m_object ).parameterize(
  -                    Parameters.fromConfiguration( config ) );
  -            }
  -            catch( Throwable e )
  -            {
  -                final String error = "Failed to parameterize an object.";
  -                throw new PipelineException( error, e );
  -            }
  +        if( m_object instanceof Configurable ) try
  +        {
  +            if( m_verbose ) getLogger().debug(
  +              "applying configuration to " + info.getName() + "\n"
  +              + CascadingConfiguration.list( config ));
  +            if( m_verbose ) getLogger().debug( "configuration" );
  +            ((Configurable)m_object).configure( config );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Failed to configure an object.";
  +            getLogger().error( error, e );
  +            handleDisposal( m_object );
  +            throw new PipelineException( error, e );
  +        }
  +        else if( m_object instanceof Parameterizable ) try
  +        {
  +            if( m_verbose ) getLogger().debug( "parameterization" );
  +            ((Parameterizable)m_object).parameterize( 
  +                Parameters.fromConfiguration( config ) );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Failed to parameterize an object.";
  +            getLogger().error( error, e );
  +            handleDisposal( m_object );
  +            throw new PipelineException( error, e );
  +        }
   
           //
           // contextualize the server
           // [need to update this to handle an args sequence]
           //
   
  -        if( m_object instanceof Contextualizable )
  -            try
  -            {
  -                if( m_verbose ) getLogger().debug( "contextualization" );
  -                Context context = new ServiceContext(
  -                    new String[ 0 ], m_root, info.getClassName() );
  -                ( (Contextualizable)m_object ).contextualize( context );
  -            }
  -            catch( Throwable e )
  -            {
  -                final String error = "Failed to contextualize the object.";
  -                throw new PipelineException( error, e );
  -            }
  +        if( m_object instanceof Contextualizable ) try
  +        {
  +            if( m_verbose ) getLogger().debug( "contextualization" );
  +            ((Contextualizable)m_object).contextualize( info.getContext() );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Failed to contextualize the object.";
  +            getLogger().error( error, e );
  +            handleDisposal( m_object );
  +            throw new PipelineException( error, e );
  +        }
   
           //
           // get the blocks required to support the dependencies
           //
   
  -        if( m_object instanceof Serviceable )
  -            try
  -            {
  -                if( m_verbose ) getLogger().debug( "composition" );
  -                ServiceManager manager = createServiceManager( info, base );
  -                ( (Serviceable)m_object ).service( manager );
  -            }
  -            catch( Throwable e )
  -            {
  -                final String error = "Failed to service the object.";
  -                throw new PipelineException( error, e );
  -            }
  -        else if( m_object instanceof Composable )
  -            try
  -            {
  -                if( m_verbose ) getLogger().debug( "composition" );
  -                ComponentManager manager = createComponentManager( info, base );
  -                ( (Composable)m_object ).compose( manager );
  -            }
  -            catch( Throwable e )
  -            {
  -                final String error = "Failed to compose the object.";
  -                throw new PipelineException( error, e );
  -            }
  +        if( m_object instanceof Serviceable ) try
  +        {
  +            if( m_verbose ) getLogger().debug( "composition" );
  +            ServiceManager manager = createServiceManager( info, base );
  +            ((Serviceable)m_object).service( manager );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Failed to service the object.";
  +            getLogger().error( error, e );
  +            handleDisposal( m_object );
  +            throw new PipelineException( error, e );
  +        }
  +        else if( m_object instanceof Composable ) try
  +        {
  +            if( m_verbose ) getLogger().debug( "composition" );
  +            ComponentManager manager = createComponentManager( info, base );
  +            ((Composable)m_object).compose( manager );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Failed to compose the object.";
  +            getLogger().error( error, e );
  +            handleDisposal( m_object );
  +            throw new PipelineException( error, e );
  +        }
   
           //
           // initialize the object
           //
   
  -        if( m_object instanceof Initializable )
  -            try
  -            {
  -                if( m_verbose ) getLogger().debug( "initilization" );
  -                ( (Initializable)m_object ).initialize();
  -            }
  -            catch( Throwable e )
  -
  -            {
  -                final String error = "Failed to initilize the object.";
  -                throw new PipelineException( error, e );
  -            }
  +        if( m_object instanceof Initializable ) try
  +        {
  +            if( m_verbose ) getLogger().debug( "initilization" );
  +            ((Initializable)m_object).initialize();
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Failed to initilize the object.";
  +            getLogger().error( error, e );
  +            handleDisposal( m_object );
  +            throw new PipelineException( error, e );
  +        }
   
           //
           // start the object
           //
   
  -        if( m_object instanceof Startable )
  +        if( m_object instanceof Startable ) try
  +        {
  +            if( m_verbose ) getLogger().debug( "starting" );
  +            ((Startable)m_object).start();
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Failed to start the service.";
  +            getLogger().error( error, e );
  +            handleDisposal( m_object );
  +            throw new PipelineException( error, e );
  +        }
  +
  +        return m_object;
  +    }
  +
  +    private void handleDisposal( Object object )
  +    {
  +        if( object instanceof Disposable )
  +        {
               try
               {
  -                if( m_verbose ) getLogger().debug( "starting" );
  -                ( (Startable)m_object ).start();
  +                ((Disposable)object).dispose();
               }
               catch( Throwable e )
               {
  -                final String error = "Failed to start the service.";
  -                throw new PipelineException( error, e );
  +                if( getLogger().isDebugEnabled() ) getLogger().debug("ignoring disposal
error", e );
               }
  -
  -        return m_object;
  +        }
       }
   
  -    /**
  -     * Notification by the controlling application to dispose of the
  -     * service factory.
  -     */
  +   /**
  +    * Notification by the controlling application to dispose of the 
  +    * service factory.
  +    */
       public void dispose()
       {
           //
           // dispose of all of the service pools
           //
   
  -        if( m_verbose )
  -            if( getLogger().isDebugEnabled() )
  -                getLogger().debug(
  -                    "pool disposal (" + m_pools.size() + ")" );
           Enumeration pools = m_pools.elements();
           while( pools.hasMoreElements() )
           {
  -
  -            Object pool = pools.nextElement();
  +            
  +            ServiceProvider pool = (ServiceProvider) pools.nextElement();
               if( pool instanceof Disposable )
               {
                   try
                   {
  -                    ( (Disposable)pool ).dispose();
  +                     if( m_verbose ) if( getLogger().isDebugEnabled() ) getLogger().debug(

  +                       "pool entry disposal (" + pool.getRole() + ")");
  +                    ((Disposable)pool).dispose();
  +                     if( m_verbose ) if( getLogger().isDebugEnabled() ) getLogger().debug(

  +                       "pool entry disposal (" + pool.getRole() + ") complete");
                   }
                   catch( Throwable e )
                   {
  @@ -468,19 +502,19 @@
           // dispose of all of the service singletons
           //
   
  -        if( m_verbose )
  -            if( getLogger().isDebugEnabled() )
  -                getLogger().debug(
  -                    "singleton disposal (" + m_singletons.size() + ")" );
           Enumeration singletons = m_singletons.elements();
           while( singletons.hasMoreElements() )
           {
  -            Object singleton = singletons.nextElement();
  +            ServiceProvider  singleton = (ServiceProvider) singletons.nextElement();
               if( singleton instanceof Disposable )
               {
                   try
                   {
  -                    ( (Disposable)singleton ).dispose();
  +                     if( m_verbose ) if( getLogger().isDebugEnabled() ) getLogger().debug(

  +                       "singleton entry disposal (" + singleton.getRole() + ")");
  +                    ((Disposable)singleton).dispose();
  +                     if( m_verbose ) if( getLogger().isDebugEnabled() ) getLogger().debug(

  +                       "singleton entry disposal complete");
                   }
                   catch( Throwable e )
                   {
  @@ -494,19 +528,19 @@
           // dispose of all of the transient service providers
           //
   
  -        if( m_verbose )
  -            if( getLogger().isDebugEnabled() )
  -                getLogger().debug(
  -                    "transient disposal (" + m_transients.size() + ")" );
           Enumeration transients = m_transients.elements();
           while( transients.hasMoreElements() )
           {
  -            Object object = transients.nextElement();
  +            ServiceProvider object = (ServiceProvider) transients.nextElement();
               if( object instanceof Disposable )
               {
                   try
                   {
  -                    ( (Disposable)object ).dispose();
  +                     if( m_verbose ) if( getLogger().isDebugEnabled() ) getLogger().debug(

  +                       "transient entry disposal (" + object.getRole() + ")");
  +                    ((Disposable)object).dispose();
  +                     if( m_verbose ) if( getLogger().isDebugEnabled() ) getLogger().debug(

  +                       "transient entry disposal complete");
                   }
                   catch( Throwable e )
                   {
  @@ -521,34 +555,36 @@
       // configuration
       //==========================================================
   
  -    /**
  -     * Creates a hashtable of configurations keyed by the block implmentation
  -     * class name.  The configuration children are assumed to be in the following form.
  -     * <pre>
  -     *     <font color="blue"><i>&lt;--
  -     *     Modify/suppliment the ReferralBlock default configuration.
  -     *     --&gt;</i></font>
  -     *
  -     *     &lt;block class="org.apache.ReferralBlock"&gt;
  -     *        &lt;profile name="directory"&gt;
  -     *           &lt;policy value="COUNT"/&gt;
  -     *        &lt;/profile&gt;
  -     *        &lt;any-child some-value="red"/&gt;
  -     *     &lt;/block&gt;
  -     *
  -     *     &lt;k class="org.apache.demo.MySecondBlock"/&gt;
  -     * </pre>
  -     */
  +   /**
  +    * Creates a hashtable of configurations keyed by the block implmentation
  +    * class name.  The configuration children are assumed to be in the following form.
  +    * <pre>
  +    *     <font color="blue"><i>&lt;--
  +    *     Modify/suppliment the ReferralBlock default configuration.
  +    *     --&gt;</i></font>
  +    *
  +    *     &lt;block class="org.apache.ReferralBlock"&gt;
  +    *        &lt;profile name="directory"&gt;
  +    *           &lt;policy value="COUNT"/&gt;
  +    *        &lt;/profile&gt;
  +    *        &lt;any-child some-value="red"/&gt;
  +    *     &lt;/block&gt;
  +    * 
  +    *     &lt;k class="org.apache.demo.MySecondBlock"/&gt;
  +    * </pre>
  +    */
       private Hashtable getComposition( Configuration config ) throws ConfigurationException
       {
           Hashtable table = new Hashtable();
  -        Configuration[] profiles = config.getChildren( "profile" );
  -        for( int i = 0; i < profiles.length; i++ )
  +        Configuration[] profiles = config.getChildren("profile");
  +        for( int i=0; i<profiles.length; i++ )
           {
  -            final String key = profiles[ i ].getAttribute( "role" );
  -            table.put( key, profiles[ i ] );
  +            final String key = profiles[i].getAttribute("role");
  +            table.put( key, profiles[i] );
           }
           return table;
       }
  +
   }
  +
   
  
  
  

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


Mime
View raw message