You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2003/06/18 13:16:15 UTC

cvs commit: avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/engine EngineTestCase.java FactoryTestCase.java

mcconnell    2003/06/18 04:16:15

  Modified:    merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl
                        DefaultAppliance.java DefaultApplianceContext.java
                        DefaultApplianceFactory.java
               merlin/assembly/src/java/org/apache/avalon/assembly/engine/impl
                        EngineClassLoader.java
               merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl
                        DefaultDeploymentService.java
                        StandardServiceManager.java
               merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl
                        AbstractLifestyleHandler.java
                        DefaultLifestyleService.java
                        PooledLifestyleHandler.java
                        SingletonLifestyleHandler.java
                        ThreadLocalLifestyleHandler.java
                        TransientLifestyleHandler.java
               merlin/assembly/src/java/org/apache/avalon/assembly/logging/impl
                        DefaultLoggingManager.java
               merlin/assembly/src/test/config block.xml
               merlin/assembly/src/test/org/apache/avalon/assembly/engine
                        EngineTestCase.java FactoryTestCase.java
  Log:
  1. updated appliance creation arguments in factory interface
  2. changed setEnabled on DefaultAppliance to private
  3. added deploy and decommissionlogic to DefaultAppliance
  4. added enforcement for explict assembly stage execution
  5. added error handling to appliance string representation
  6. added pooled lifestyle pach from Christian Meier
  7. improved internal logging categories for appliances building appliances
  8. added support for decommissioning phase for lifecycle handlers
  9. improved logging category value filtering
  
  Revision  Changes    Path
  1.12      +121 -34   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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultAppliance.java	15 Jun 2003 18:22:29 -0000	1.11
  +++ DefaultAppliance.java	18 Jun 2003 11:16:13 -0000	1.12
  @@ -123,6 +123,7 @@
    *    {@link Appliance} appliance = engine.createAppliance( context );
    *    {@link DependencyGraph} graph = new DependencyGraph();
    *    appliance.assemble( graph );
  + *    appliance.deploy();
    *    Object object = appliance.resolve( this );
    *
    *    //
  @@ -244,25 +245,30 @@
       private ArrayList m_visited = new ArrayList();
   
       /**
  -     * Flag holding the dissasembled state of the block.
  -     */
  -    private boolean m_disassembled = false;
  -
  -    /**
        * The appliance manager.
        */
       private ApplianceRepository m_repository;
   
       /**
  -     * Flag holding the contextualized state of the block.
  +     * Flag holding the contextualized state of the appliance.
        */
       private boolean m_contextualized = false;
   
       /**
  -     * Flag holding the initialized state of the block.
  +     * Flag holding the initialized state of the appliance.
        */
       private boolean m_initialized = false;
   
  +    /**
  +     * Flag holding the deployed state of the appliance.
  +     */
  +    private boolean m_deployed = false;
  +
  +    /**
  +     * Flag holding the terminated state of the appliance.
  +     */
  +    private boolean m_terminated = false;
  +
       //=====================================================================
       // Contextualizable
       //=====================================================================
  @@ -274,7 +280,6 @@
        */
       public void contextualize( Locator context ) throws ContextException
       {
  -        getLogger().debug( "appliance contextualization" );
           m_applianceContext = (ApplianceContext) context.get( ApplianceContext.KEY );
           m_lifestyle = (LifestyleService) context.get( LifestyleService.KEY );
           m_engine = (EngineClassLoader) context.get( APPLIANCE_ENGINE_KEY );
  @@ -289,8 +294,6 @@
   
       public void initialize() throws Exception
       {
  -        getLogger().debug( "appliance initialization" );
  -      
           if( !m_contextualized )
           {
               throw new IllegalStateException( "contextualization" );
  @@ -312,6 +315,7 @@
   
           m_name = m_applianceContext.getName();
           m_path = m_applianceContext.getPartitionName() + m_name;
  +        m_initialized = true;
   
           //
           // finally, create the lifestyle handler
  @@ -335,7 +339,6 @@
               getLogger().debug( message );
           }
   
  -        m_initialized = true;
       }
   
       //=====================================================================
  @@ -368,26 +371,17 @@
       public Object resolve( Object source, String ref )
               throws LocatorException
       {
  -        if( !m_initialized )
  +        if( !m_deployed )
           {
  -            throw new IllegalStateException( "initialization" );
  -        }
  -
  -        if( !m_assembled )
  -        {
  -            final String message =
  -                    "invoking self assembly in appliance: " + this;
  -            getLogger().debug( message );
               try
               {
  -                assemble();
  -            } 
  -            catch( ApplianceException ae )
  +                deploy();
  +            }
  +            catch( Throwable e )
               {
  -                final String error =
  -                  "Unable to resolve service due to a self assembly failure in appliance: "
  -                  + this;
  -                throw new LocatorException( error, ref, ae );
  +                final String error = 
  +                  "Internal implementation deployment failure in appliance: " + this;
  +                throw new LocatorException( error, e );
               }
           }
   
  @@ -492,13 +486,21 @@
        */
       public URL getURL()
       {
  +        if( !m_initialized ) 
  +        {
  +            final String error = 
  +              "URL cannot been accessed before initialization.";
  +            throw new IllegalStateException( error );
  +        }
  +
           if( m_url == null )
           {
               try
               {
                   URL base = m_repository.getURL();
                   m_url = new URL( base, base.getPath() + m_name );
  -            } catch( Throwable e )
  +            } 
  +            catch( Throwable e )
               {
                   final String error =
                           "Unexpected url creation error in appliance: " + this;
  @@ -630,7 +632,7 @@
        * @param value the enabled status - TRUE or FALSE
        * @see #isEnabled()
        */
  -    public void setEnabled( boolean value )
  +    private void setEnabled( boolean value )
       {
           m_enabled = value;
       }
  @@ -651,7 +653,7 @@
        */
       public void assemble() throws ApplianceException
       {
  -        assemble( new DependencyGraph() );
  +        assemble( getDependencyGraph() );
       }
   
       /**
  @@ -718,7 +720,7 @@
        */
       public void disassemble()
       {
  -        if( m_disassembled )
  +        if( !m_assembled )
           {
               return;
           }
  @@ -734,10 +736,17 @@
               Appliance consumer = consumers[i];
               m_graph.remove( consumer );
           }
  +        m_assembled = false;
       }
   
       protected DependencyGraph getDependencyGraph()
       {
  +        if( m_graph == null )
  +        {
  +            final String error = 
  +              "Missing assembly graph.";
  +            throw new IllegalStateException( error );
  +        }
           return m_graph;
       }
   
  @@ -934,7 +943,78 @@
       */
       public String toString()
       {
  -        return "[appliance:/" + getURL().getPath() + "]";
  +        try
  +        {
  +            return "[appliance:/" + getURL().getPath() + "]";
  +        }
  +        catch( Throwable e )
  +        {
  +            return "[appliance:/?]";
  +        }
  +    }
  +
  +   /**
  +    * Deploy the appliance. If the deployment policy is startup
  +    * an initial instance of a component will be deployed.
  +    *
  +    * @exception Exception if a deployment error occurs
  +    */
  +    public void deploy() throws Exception
  +    {
  +        if( m_deployed )
  +        {
  +            return;
  +        }
  +
  +        if( !m_assembled )
  +        {
  +            final String message =
  +              "invoking self assembly in appliance: " + this;
  +            getLogger().debug( message );
  +            try
  +            {
  +                assemble();
  +            } 
  +            catch( ApplianceException e )
  +            {
  +                final String error =
  +                  "Unable to resolve service due to a self assembly failure in appliance: "
  +                  + this;
  +                throw new ApplianceException( error, e );
  +            }
  +        }
  +
  +        m_deployed = true;
  +    }
  +
  +   /**
  +    * Decommission the appliance.  Under the decommissioning phase, 
  +    * all active components will be taken down.
  +    */
  +    public void decommission()
  +    {
  +        if( !m_deployed )
  +        {
  +            return;
  +        }
  +
  +        if( getLogger().isDebugEnabled() )
  +        {
  +            getLogger().debug( "decommissioning: " + this );
  +        }
  +
  +        try
  +        {
  +            m_handler.decommission();
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Unexpected error while attempting to decommission the handler in appliance: "
  +              + this;
  +            getLogger().warn( error, e );
  +        }
  +        m_deployed = false;
       }
   
       /**
  @@ -942,11 +1022,17 @@
        */
       public void terminate()
       {
  +        if( !m_initialized )
  +        {
  +            return;
  +        }
  +
           if( getLogger().isDebugEnabled() )
           {
               getLogger().debug( "termination: " + this );
           }
           m_handler.terminate();
  +        m_initialized = false;
       }
   
       private void executeAssembly( DependencyGraph graph ) throws ApplianceException
  @@ -1022,7 +1108,8 @@
                   try
                   {
                       supplier = m_engine.resolve( graph, dependency, getURL().getPath() );
  -                } catch( Throwable e )
  +                } 
  +                catch( Throwable e )
                   {
                       setEnabled( false );
                       final String error =
  
  
  
  1.5       +2 -1      avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/DefaultApplianceContext.java
  
  Index: DefaultApplianceContext.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/DefaultApplianceContext.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultApplianceContext.java	15 Jun 2003 18:22:29 -0000	1.4
  +++ DefaultApplianceContext.java	18 Jun 2003 11:16:13 -0000	1.5
  @@ -366,6 +366,7 @@
       public void setActivationPolicy( final boolean policy )
       {
           checkWriteable();
  +System.out.println( "SETTING ACTIVATION POLICY from: " + m_activation + " to " + policy );
           m_activation = policy;
       }
   
  
  
  
  1.8       +14 -16    avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/DefaultApplianceFactory.java
  
  Index: DefaultApplianceFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/DefaultApplianceFactory.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultApplianceFactory.java	8 May 2003 03:02:39 -0000	1.7
  +++ DefaultApplianceFactory.java	18 Jun 2003 11:16:13 -0000	1.8
  @@ -181,7 +181,8 @@
               context.makeReadOnly();
   
               Appliance appliance = loader.createAppliance( context, true );
  -            appliance.assemble();
  +            appliance.assemble( new DependencyGraph() );
  +            appliance.deploy();
               Object factory = appliance.resolve( loader );
               if( factory instanceof ApplianceFactory )
               {
  @@ -318,7 +319,7 @@
        * @return the appliance
        */
       public Appliance createAppliance(
  -            Locator system, Engine engine, ApplianceContext context, Logger logger )
  +            Locator system, Engine engine, ApplianceContext context )
               throws ApplianceException
       {
           if( engine == null )
  @@ -329,15 +330,10 @@
           {
               throw new NullPointerException( "context" );
           }
  -        if( logger == null )
  -        {
  -            throw new NullPointerException( "logger" );
  -        }
   
           if( m_repository == null )
           {
  -            final String error = 
  -              "Appliance factory has not been contextualized.";
  +            final String error = "repository";
               throw new IllegalStateException( error );
           }
   
  @@ -363,13 +359,13 @@
           catch( Throwable e )
           {
               final String error =
  -                    "Unexpected error while building appliance context.";
  +              "Unexpected error while building appliance context.";
               throw new ApplianceException( error, e );
           }
   
           String classname = context.getApplianceClassname();
           if( (classname == null)
  -                || (classname.equals( DefaultAppliance.class.getName() )) )
  +           || (classname.equals( DefaultAppliance.class.getName() )) )
           {
               getLogger().debug( "creating a classic appliance" );
   
  @@ -378,7 +374,9 @@
               //
   
               DefaultAppliance appliance = new DefaultAppliance();
  -            appliance.enableLogging( logger );
  +            final String path = context.getPartitionName() + context.getName();
  +            appliance.enableLogging( m_logging.getSystemLoggerForCategory( path ) );
  +
               try
               {
                   appliance.contextualize( locator );
  @@ -397,7 +395,7 @@
               getLogger().debug( "custom appliance using: " + classname );
   
               //
  -            // its a custom appliance so in this case we use an apppliance to
  +            // its a custom appliance so in this case we use an appliance to
               // construct the appliance
               //
   
  @@ -413,6 +411,8 @@
   
                   DefaultApplianceContext cntx =
                     new DefaultApplianceContext( profile, map );
  +                cntx.setName( context.getName() + "$bootstrap" );
  +                cntx.setPartitionName( context.getPartitionName() );
                   cntx.put( LifestyleService.KEY, lifestyle );
                   cntx.put( ApplianceContext.KEY, context );
                   cntx.put( ApplianceRepository.KEY, m_repository );
  @@ -422,11 +422,9 @@
                   cntx.makeReadOnly();
   
                   Appliance appliance = engine.createAppliance( cntx, false );
  -
                   appliance.assemble( new DependencyGraph() );
  -
  +                appliance.deploy();
                   Object object = appliance.resolve( this );
  -
                   if( object instanceof Appliance )
                   {
                       return (Appliance) object;
  
  
  
  1.8       +17 -13    avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/engine/impl/EngineClassLoader.java
  
  Index: EngineClassLoader.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/engine/impl/EngineClassLoader.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- EngineClassLoader.java	15 Jun 2003 18:22:30 -0000	1.7
  +++ EngineClassLoader.java	18 Jun 2003 11:16:14 -0000	1.8
  @@ -953,7 +953,7 @@
   
           if( getLogger().isDebugEnabled() )
           {
  -            getLogger().debug( "resolve: " + dependency );
  +            getLogger().debug( "resolving appliance for: " + dependency );
           }
   
           Appliance appliance = m_manager.getAppliance( dependency );
  @@ -965,7 +965,8 @@
               {
                   final String error = REZ.getString( "resolve.fail", dependency );
                   throw new EngineException( error );
  -            } else
  +            } 
  +            else
               {
                   DefaultApplianceContext context =
                           new DefaultApplianceContext( profile );
  @@ -979,7 +980,8 @@
           try
           {
               appliance.assemble( graph );
  -        } catch( Throwable e )
  +        }
  +        catch( Throwable e )
           {
               throw new ApplianceException(
                       "Unresolvable assembly graph for appliance: " + appliance, e );
  @@ -1036,14 +1038,14 @@
                   context.makeReadOnly();
                   appliance = createAppliance( 
                         context, !profile.getMode().equals( Mode.IMPLICIT ) );
  -                //appliance = createAppliance( context, true );
               }
           }
   
           try
           {
               appliance.assemble( graph );
  -        } catch( Throwable e )
  +        } 
  +        catch( Throwable e )
           {
               throw new ApplianceException(
                       "Unresolvable assembly graph for appliance: " + appliance );
  @@ -1067,7 +1069,7 @@
        * Create a new appliance.
        * @param context the appliance creation context
        * @param shared TRUE if this appliance can be shared
  -     * @param nested if TRUE the return appliance is assigned a child logging channel
  +     * @param system if TRUE the appliance is bootstrapping another appliance
        * @return the appliance
        */
       public Appliance createAppliance(
  @@ -1078,22 +1080,24 @@
               throw new NullPointerException( "context" );
           }
   
  -        Logger logger = getLogger().getChildLogger( context.getName() );
  -
  -        String classname = context.getApplianceFactoryClassname();
  +        final String path = context.getPartitionName() + context.getName();
  +        final Logger logger = getLoggingManager().getSystemLoggerForCategory( path );
  +        final String classname = context.getApplianceFactoryClassname();
           ApplianceFactory factory;
           if( classname == null )
           {
               factory = m_factory;
  -        } 
  +        }
           else
           {
               factory =
                 DefaultApplianceFactory.createApplianceFactory(
  -                this, classname, logger, getLoggingManager(), m_manager, getSystemContext() );
  +                this, classname, logger, getLoggingManager(), 
  +                m_manager, getSystemContext() );
           }
   
  -        Appliance appliance = factory.createAppliance( getSystemContext(), this, context, logger );
  +        Appliance appliance = 
  +          factory.createAppliance( getSystemContext(), this, context );
           if( shared )
           {
               m_manager.addAppliance( appliance );
  
  
  
  1.14      +47 -3     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl/DefaultDeploymentService.java
  
  Index: DefaultDeploymentService.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl/DefaultDeploymentService.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- DefaultDeploymentService.java	15 Jun 2003 18:22:30 -0000	1.13
  +++ DefaultDeploymentService.java	18 Jun 2003 11:16:14 -0000	1.14
  @@ -50,6 +50,9 @@
   
   package org.apache.avalon.assembly.lifecycle.impl;
   
  +import java.net.URL;
  +import java.net.URLClassLoader;
  +
   import org.apache.avalon.assembly.appliance.Appliance;
   import org.apache.avalon.assembly.lifecycle.DeploymentException;
   import org.apache.avalon.assembly.lifecycle.DeploymentService;
  @@ -57,6 +60,7 @@
   import org.apache.avalon.assembly.locator.Locator;
   import org.apache.avalon.assembly.locator.impl.DefaultLocator;
   import org.apache.avalon.assembly.logging.LoggingManager;
  +import org.apache.avalon.framework.CascadingException;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Executable;
   import org.apache.avalon.framework.activity.Initializable;
  @@ -296,6 +300,24 @@
   
               return instance;
           }
  +        catch( CascadingException ce )
  +        {
  +            if( ce.getCause() instanceof ClassNotFoundException )
  +            {
  +                throw buildDeploymentException( ce, (ClassNotFoundException) ce.getCause() );
  +            }
  +            else
  +            {
  +                final String error =
  +                  "Component deployment failure in appliance: "
  +                  + appliance;
  +                throw new DeploymentException( error, ce );
  +            }
  +        }
  +        catch( ClassNotFoundException cnfe )
  +        {
  +            throw buildDeploymentException( cnfe, cnfe );
  +        }
           catch( Throwable e )
           {
               final String error =
  @@ -305,6 +327,24 @@
           }
       }
   
  +    private DeploymentException buildDeploymentException( Throwable e, ClassNotFoundException cnfe ) 
  +    {
  +        final StringBuffer buffer = new StringBuffer(
  +          "Class not found: " + cnfe.getMessage() );
  +        ClassLoader loader = Thread.currentThread().getContextClassLoader();
  +        if( loader instanceof URLClassLoader )
  +        {
  +            buffer.append( " in classloader containing: " );
  +            URL[] urls = ((URLClassLoader)loader).getURLs();
  +            for( int i=0; i<urls.length; i++ )
  +            {
  +                buffer.append( "\n  " + urls[i] );
  +            }
  +        }
  +        final String error = buffer.toString();
  +        return new DeploymentException( error, e );
  +    }
  +
       /**
        * Destroy an appliance.
        * @param appliance the object's appliance
  @@ -417,14 +457,18 @@
       */
       private void handleLogging( Appliance appliance, LogEnabled object ) throws Exception
       {
  -        String path = appliance.getPath();
           LoggingDirective logging = appliance.getLoggingDirective();
  +        String path = appliance.getPath();
           if( object instanceof Appliance )
           {
  +            if( path.endsWith( "$bootstrap" ) )
  +            {
  +                path = path.substring( 0, path.length() - 10 );
  +            }
               if( getLogger().isDebugEnabled() )
               {
                   getLogger().debug( "logging (sys): " + appliance + " on path: " + path );
  -            } 
  +            }
               m_logging.addSystemCategories( path, logging );
               Logger logger = m_logging.getSystemLoggerForCategory( path );
              ((LogEnabled)object).enableLogging( logger );
  
  
  
  1.3       +11 -2     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl/StandardServiceManager.java
  
  Index: StandardServiceManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl/StandardServiceManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StandardServiceManager.java	4 May 2003 17:21:05 -0000	1.2
  +++ StandardServiceManager.java	18 Jun 2003 11:16:14 -0000	1.3
  @@ -75,7 +75,7 @@
       //========================================================================
   
       /**
  -     * The appliance from which provide appliances are resolved.
  +     * The appliance from which provider appliances are resolved.
        */
       private Appliance m_appliance;
   
  @@ -129,12 +129,21 @@
   
           DependencyDescriptor dependency =
                   m_appliance.getType().getDependency( role );
  +
  +        if( dependency == null )
  +        {
  +            final String error = 
  +              "Component: '" + m_appliance 
  +              + "' is requesting an unknown role'";
  +            throw new ServiceException( role, error );
  +        }
  +
           Appliance provider = m_appliance.getServiceProvider( role );
           if( provider == null )
           {
               final String error =
                       "Internal error - incorrect assembly in appliance: " + m_appliance
  -                    + ". A null provider was retured for the dependency: " + dependency;
  +                    + ". A null provider was returned for the dependency: " + dependency;
               throw new ServiceException( role, error );
           }
   
  
  
  
  1.5       +10 -3     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/AbstractLifestyleHandler.java
  
  Index: AbstractLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/AbstractLifestyleHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractLifestyleHandler.java	7 Jun 2003 21:12:47 -0000	1.4
  +++ AbstractLifestyleHandler.java	18 Jun 2003 11:16:14 -0000	1.5
  @@ -191,8 +191,9 @@
        * Release an a service or handler established by the appliance.  The
        * default implementation irreversably decommissions the supplied object.
        * @param object the service to be released
  +     * @param source the object releasing the reference
        */
  -    public void release( Object object, Object partition )
  +    public void release( Object object, Object source )
       {
           if( getLogger().isDebugEnabled() )
           {
  @@ -360,7 +361,13 @@
       }
   
       /**
  -     * Terminate the appliance.
  +     * Decommission all active objects maintained by the handler.
  +     * @exception Exception if an error occurs while decommissioning
  +     */
  +    public abstract void decommission() throws Exception;
  +
  +    /**
  +     * Terminate the handler.
        */
       public void terminate()
       {
  
  
  
  1.4       +22 -3     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/DefaultLifestyleService.java
  
  Index: DefaultLifestyleService.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/DefaultLifestyleService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultLifestyleService.java	8 May 2003 03:02:39 -0000	1.3
  +++ DefaultLifestyleService.java	18 Jun 2003 11:16:14 -0000	1.4
  @@ -217,7 +217,8 @@
                     "Internal error while attempting to establish the transient lifestyle handler.";
                   throw new LifestyleRuntimeException( error, e );
               }
  -        } else if( policy.equals( "thread" ) )
  +        } 
  +        else if( policy.equals( "thread" ) )
           {
               try
               {
  @@ -232,7 +233,25 @@
                     "Internal error while attempting to establish the transient lifestyle handler.";
                   throw new LifestyleRuntimeException( error, e );
               }
  -        } else
  +         } 
  +         else if( policy.equals( "pooled" ) )
  +         {
  +             try
  +             {
  +                 PooledLifestyleHandler pooled = new PooledLifestyleHandler();
  +                 pooled.enableLogging( getLogger() );
  +                 pooled.contextualize( context );
  +                 pooled.initialize();
  +                 return pooled;
  +             } 
  +             catch( Throwable e )
  +             {
  +                 final String error =
  +                   "Internal error while attempting to establish the pooled lifestyle handler.";
  +                 throw new LifestyleRuntimeException( error, e );
  +             }
  +        }
  +        else
           {
               final String error =
                 "Lifestyle policy argument '" + policy + "' within appliance: "
  
  
  
  1.3       +28 -5     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/PooledLifestyleHandler.java
  
  Index: PooledLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/PooledLifestyleHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PooledLifestyleHandler.java	9 Jun 2003 01:11:17 -0000	1.2
  +++ PooledLifestyleHandler.java	18 Jun 2003 11:16:14 -0000	1.3
  @@ -107,7 +107,7 @@
       /**
        * The object pool size.
        */
  -    private int m_size;
  +    private int m_size = 5;
   
       /**
        * The class of object managed by the pool.
  @@ -129,7 +129,10 @@
           {
               throw new NullPointerException( "config" );
           }
  -        m_size = config.getAttributeAsInteger( "size", 5 );
  +        else
  +        {
  +            m_size = config.getAttributeAsInteger( "size", 5 );
  +        }
       }
   
       //==============================================================
  @@ -161,7 +164,6 @@
       public void initialize() throws Exception
       {
           super.initialize();
  -        m_pool = m_poolManager.getManagedPool( this, m_size );
           m_appliance = (Appliance) m_context.get( "urn:assembly:appliance.target" );
           ClassLoader classloader = (ClassLoader) m_context.get( "urn:avalon:classloader" );
           m_class = classloader.loadClass( m_appliance.getType().getInfo().getClassname() );
  @@ -192,7 +194,17 @@
       {
           try
           {
  -            Object object = m_pool.acquire();
  +            if( m_pool == null )
  +	      {
  +	          synchronized( m_poolManager )
  +	          {
  +		        if( m_pool == null )
  +		        {
  +		            m_pool = m_poolManager.getManagedPool( this, m_size );
  +                    }
  +                }
  +            }
  +	      Object object = m_pool.acquire();
               super.processAccessStage( object );
               return object;
           } 
  @@ -229,6 +241,17 @@
               }
           }
       }
  +
  +    /**
  +     * Decommission all active objects maintained by the handler.
  +     * @exception Exception if an error occurs while decommissioning
  +     */
  +    public void decommission() throws Exception
  +    {
  +        // What to do - the principal is that a pool maintains a 
  +        // a pool - so what does decommissioning in this context mean?
  +    }
  +
   
       //==============================================================
       // ObjectFactory
  
  
  
  1.2       +4 -8      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SingletonLifestyleHandler.java	26 Apr 2003 12:37:47 -0000	1.1
  +++ SingletonLifestyleHandler.java	18 Jun 2003 11:16:14 -0000	1.2
  @@ -121,21 +121,17 @@
           // consumers
       }
   
  -    //==============================================================
  -    // Disposable
  -    //==============================================================
  -
       /**
  -     * Request for disposal of the handler.
  +     * Decommission all active objects maintained by the handler.
  +     * @exception Exception if an error occurs while decommissioning
        */
  -    public void dispose()
  +    public void decommission() throws Exception
       {
           if( m_instance != null )
           {
               super.release( m_instance, this );
               m_instance = null;
           }
  -        super.dispose();
       }
   
       //==============================================================
  
  
  
  1.2       +5 -1      avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/ThreadLocalLifestyleHandler.java
  
  Index: ThreadLocalLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/ThreadLocalLifestyleHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ThreadLocalLifestyleHandler.java	26 Apr 2003 12:37:47 -0000	1.1
  +++ ThreadLocalLifestyleHandler.java	18 Jun 2003 11:16:14 -0000	1.2
  @@ -150,7 +150,11 @@
           }
       }
   
  -    public void terminate()
  +    /**
  +     * Decommission all active objects maintained by the handler.
  +     * @exception Exception if an error occurs while decommissioning
  +     */
  +    public void decommission() throws Exception
       {
           if( m_instance != null )
           {
  
  
  
  1.2       +8 -11     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/TransientLifestyleHandler.java
  
  Index: TransientLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/TransientLifestyleHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TransientLifestyleHandler.java	26 Apr 2003 12:37:47 -0000	1.1
  +++ TransientLifestyleHandler.java	18 Jun 2003 11:16:14 -0000	1.2
  @@ -102,7 +102,8 @@
               }
               super.processAccessStage( object );
               return object;
  -        } catch( Throwable e )
  +        } 
  +        catch( Throwable e )
           {
               final String error =
                       "Transient object establishment error.";
  @@ -124,14 +125,11 @@
           }
       }
   
  -    //==============================================================
  -    // Disposable
  -    //==============================================================
  -
  -    /**
  -     * Request for disposal of the handler.
  -     */
  -    public void dispose()
  +   /**
  +    * Decommission the block.  Under the decommissioning phase, 
  +    * all active components will be taken down.
  +    */
  +    public void decommission() throws Exception
       {
           synchronized( m_instances )
           {
  @@ -141,6 +139,5 @@
                   release( iterator.next(), null );
               }
           }
  -        super.dispose();
       }
   }
  
  
  
  1.2       +11 -3     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/logging/impl/DefaultLoggingManager.java
  
  Index: DefaultLoggingManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/logging/impl/DefaultLoggingManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultLoggingManager.java	26 Apr 2003 12:37:47 -0000	1.1
  +++ DefaultLoggingManager.java	18 Jun 2003 11:16:14 -0000	1.2
  @@ -221,7 +221,8 @@
           Category bootstrap = m_descriptor.getBootstrapCategory();
   
           m_logger = new LogKitLogger(
  -                addCategory( bootstrap.getName(), bootstrap.getPriority(), bootstrap.getTarget(), false ) );
  +          addCategory( 
  +            bootstrap.getName(), bootstrap.getPriority(), bootstrap.getTarget(), false ) );
           m_logger.debug( "setting default priority: " + priority );
   
           //
  @@ -245,7 +246,8 @@
               if( target != null )
               {
                   getHierarchy().setDefaultLogTarget( target );
  -            } else
  +            } 
  +            else
               {
                   throw new LoggerException(
                           "Supplied default logging target: '"
  @@ -410,7 +412,8 @@
           try
           {
               logger = getHierarchy().getLoggerFor( name );
  -        } catch( Throwable e )
  +        } 
  +        catch( Throwable e )
           {
               throw new RuntimeException( "Bad category: " + path + " or trans: " + name );
           }
  @@ -454,6 +457,11 @@
           if( path.startsWith( "." ) )
           {
               path = path.substring( 1 );
  +            return filter( path );
  +        }
  +        if( path.endsWith( "." ) )
  +        {
  +            path = path.substring( 0, path.length() -1 );
               return filter( path );
           }
           return path;
  
  
  
  1.5       +2 -0      avalon-sandbox/merlin/assembly/src/test/config/block.xml
  
  Index: block.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/test/config/block.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- block.xml	15 Apr 2003 03:12:04 -0000	1.4
  +++ block.xml	18 Jun 2003 11:16:15 -0000	1.5
  @@ -17,6 +17,8 @@
   
      <implementation>
   
  +     <categories priority="DEBUG"/>
  +
        <component name="basic"
             class="org.apache.avalon.playground.basic.BasicComponent"
             activation="startup">
  
  
  
  1.10      +1 -0      avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/engine/EngineTestCase.java
  
  Index: EngineTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/engine/EngineTestCase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- EngineTestCase.java	8 May 2003 03:02:39 -0000	1.9
  +++ EngineTestCase.java	18 Jun 2003 11:16:15 -0000	1.10
  @@ -254,6 +254,7 @@
               context.makeReadOnly();
               Appliance appliance = m_engine.createAppliance( context, false );
               appliance.assemble( graph );
  +            appliance.deploy();
               assertTrue( appliance.resolve( this ) != null );
           } catch( Throwable e )
           {
  
  
  
  1.10      +1 -0      avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/engine/FactoryTestCase.java
  
  Index: FactoryTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/engine/FactoryTestCase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FactoryTestCase.java	8 May 2003 03:02:39 -0000	1.9
  +++ FactoryTestCase.java	18 Jun 2003 11:16:15 -0000	1.10
  @@ -125,6 +125,7 @@
               context.makeReadOnly();
               Appliance appliance = m_engine.createAppliance( context, false );
               appliance.assemble( graph );
  +            appliance.deploy();
               assertTrue( appliance.resolve( this ) != null );
           } 
           catch( Throwable e )
  
  
  

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