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/assembly/src/test/org/apache/avalon/assembly/engine EngineTestCase.java
Date Wed, 15 Jan 2003 09:09:27 GMT
mcconnell    2003/01/15 01:09:27

  Modified:    assembly STATUS-README-ITS-RELEVANT.TXT
               assembly/src/java/org/apache/avalon/assembly/appliance
                        Appliance.java ApplianceFactory.java
                        ContextBuilder.java DefaultAppliance.java
                        DefaultApplianceContext.java
                        DefaultApplianceFactory.java DependencyGraph.java
               assembly/src/java/org/apache/avalon/assembly/engine
                        DefaultRepositoryManager.java Engine.java
                        EngineClassLoader.java
               assembly/src/java/org/apache/avalon/assembly/lifecycle
                        DefaultAssemblyService.java
                        DefaultDeploymentService.java
               assembly/src/java/org/apache/avalon/assembly/lifecycle/composition
                        DefaultCompositionService.java
                        StandardServiceManager.java
               assembly/src/java/org/apache/avalon/assembly/lifecycle/context
                        DefaultContextualizationService.java
               assembly/src/java/org/apache/avalon/assembly/lifecycle/disposal
                        ExtendedDisposalService.java
               assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization
                        ExtendedInitializationService.java
               assembly/src/java/org/apache/avalon/assembly/lifestyle
                        AbstractLifestyleHandler.java
                        DefaultLifestyleService.java LifestyleHandler.java
                        PooledLifestyleHandler.java
                        SingletonLifestyleHandler.java
                        ThreadLocalLifestyleHandler.java
                        TransientLifestyleHandler.java
               assembly/src/java/org/apache/avalon/assembly/locator
                        DefaultLocator.java Reclaimable.java
                        Resolvable.java
               assembly/src/java/org/apache/avalon/assembly/util
                        ExceptionHelper.java
               assembly/src/test/config block.xml
               assembly/src/test/org/apache/avalon/assembly/engine
                        EngineTestCase.java
  Added:       assembly/src/java/org/apache/avalon/assembly/appliance
                        ApplianceHolder.java
               assembly/src/java/org/apache/avalon/assembly/lifecycle/composition
                        ComponentInvocationHandler.java
                        WrapperComponentManager.java
                        WrapperComponentSelector.java
  Log:
  Enhancements to logging and error messages, refactoring the appliance
  resolution mechanisms to use a common resolver interface, bug fix concerning
  dissassembly of components.
  
  Revision  Changes    Path
  1.3       +0 -11     avalon-sandbox/assembly/STATUS-README-ITS-RELEVANT.TXT
  
  Index: STATUS-README-ITS-RELEVANT.TXT
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/STATUS-README-ITS-RELEVANT.TXT,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- STATUS-README-ITS-RELEVANT.TXT	17 Dec 2002 10:20:58 -0000	1.2
  +++ STATUS-README-ITS-RELEVANT.TXT	15 Jan 2003 09:09:23 -0000	1.3
  @@ -2,17 +2,6 @@
   
   The avalon-sandbox/assembly package is a evolving in response to discusions and ideas about profiles based containers thats been going on within the avalon-dev list recently.  Much of the content here has been ripped out of the Avalon Excalibur Merlin packaged and refactored to be more cleanly component based.  
   
  -There is still a few things to be done:
  -
  -  * revision of the context management to plug in context provider component that can be applied to a componet implementing the following operation pattern:
  -
  -      void contextualize( <your-custom-context> ) throws ContextException;
  -
  -  * review of the Appliance interface to support container specific supplimentation services, parameters and  configuration on appliance creation.
  -
  -  * getting service engine subsystem configuration in place - everything currently works without configuration which is nice for the dyncamic deployment scanarios, but getting full propergation of custom configuration will be a big plus in moving forward on the notion of profile driven containment
  -
  -
   To see the API in action:
   
   $ ant test
  
  
  
  1.21      +8 -29     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/Appliance.java
  
  Index: Appliance.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/Appliance.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Appliance.java	9 Jan 2003 15:08:09 -0000	1.20
  +++ Appliance.java	15 Jan 2003 09:09:23 -0000	1.21
  @@ -62,6 +62,7 @@
   import org.apache.avalon.assembly.lifestyle.LifestyleException;
   import org.apache.avalon.assembly.lifecycle.AssemblyException;
   import org.apache.avalon.assembly.locator.Contextualizable;
  +import org.apache.avalon.assembly.locator.Reclaimable;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.meta.model.LoggingDirective;
  @@ -78,7 +79,7 @@
    * @version $Revision$ $Date$
    */ 
   
  -public interface Appliance extends LogEnabled, Contextualizable, Initializable
  +public interface Appliance extends LogEnabled, Contextualizable, Initializable, Reclaimable
   {
      /**
       * Meta-info attribute name under which an alternative appliance class may be declared.
  @@ -93,7 +94,6 @@
       static final String APPLIANCE_FACTORY_KEY = 
         "urn:assembly:appliance.factory";
   
  -
      /**
       * Get the appliance name.
       */
  @@ -174,13 +174,6 @@
       Context getContext();
   
       /**
  -     * Set the context provider.
  -     *
  -     * @param applaince the appliance to be mapped as provider of the context
  -     */
  -    void setContextProvider( Appliance appliance );
  -
  -    /**
        * Return the context provider.
        *
        * @return the appliance mapped as provider of the context
  @@ -188,13 +181,6 @@
       Appliance getContextProvider();
   
       /**
  -     * Add the appliance that will acts as provider for a named dependency.
  -     * @param role the role against which the supplied appliance is to be associated
  -     * @param appliance the appliance that will fulfill the provider dependency
  -     */
  -    void addServiceProvider( String role, Appliance appliance );
  -
  -    /**
        * Return the dependency associations for component type with specified role.
        *
        * @param role the dependency role name
  @@ -209,13 +195,6 @@
       Appliance[] getServiceProviders();
   
       /**
  -     * Add a lifecycle stage extension.
  -     * @param stage the identifier of the stage to assign the manager to
  -     * @param appliance the appliance that will handle the stage
  -     */
  -    void addExtensionProvider( StageDescriptor stage, Appliance appliance );
  -
  -    /**
        * Returns the appliace assigned to handle the components lifecycle stage.
        * @param stage the lifecycle stage specification
        * @return a reference to the stage extension
  @@ -233,7 +212,7 @@
       * Assemble the appliance.
       * @exception AssemblyException if an error occurs during appliance assembly
       */
  -    void assemble() throws AssemblyException;
  +    void assemble( DependencyGraph graph ) throws AssemblyException;
   
      /**
       * Disassemble the appliance.
  @@ -246,24 +225,24 @@
       *
       * @return the implementation object
       */
  -    Object access() throws LifestyleException;
  +    //Object access() throws LifestyleException;
   
      /**
       * Activate a service provided by the appliance.
       * @param dependency the service dependecy decsriptor
       */
  -    Object access( DependencyDescriptor dependency ) throws LifestyleException;
  +    //Object access( DependencyDescriptor dependency ) throws LifestyleException;
   
      /**
       * Activate an extension handler provided by the appliance.
       * @param appliance the appliance to deploy
       */
  -    Object access( StageDescriptor stage ) throws LifestyleException;
  +    //Object access( StageDescriptor stage ) throws LifestyleException;
   
      /**
       * Release a reference to a service provided by this appliance.
       */
  -    void release( Object object );
  +    //void release( Object object );
   
      /**
       * Terminate the appliance.
  
  
  
  1.4       +6 -2      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceFactory.java
  
  Index: ApplianceFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ApplianceFactory.java	9 Jan 2003 15:09:37 -0000	1.3
  +++ ApplianceFactory.java	15 Jan 2003 09:09:23 -0000	1.4
  @@ -56,10 +56,12 @@
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.assembly.lifestyle.LifestyleException;
   import org.apache.avalon.assembly.lifecycle.AssemblyException;
   import org.apache.avalon.assembly.engine.EngineClassLoader;
  +import org.apache.avalon.assembly.locator.Locator;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.meta.model.LoggingDirective;
  @@ -87,12 +89,14 @@
   
      /**
       * Create a new appliance.
  +    * @param system the system context
       * @param engine the engine classloader
       * @param context the appliance creation context
  +    * @param logger the logging channel to assign to the appliance
       * @return the appliance
       * @exception ApplianceException if an appliance creation failure occurs
       */
       Appliance createAppliance( 
  -      EngineClassLoader engine, ApplianceContext context ) 
  +      Locator system, EngineClassLoader engine, ApplianceContext context, Logger logger ) 
         throws ApplianceException;
   }
  
  
  
  1.4       +15 -8     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/ContextBuilder.java
  
  Index: ContextBuilder.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/ContextBuilder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ContextBuilder.java	9 Jan 2003 15:08:09 -0000	1.3
  +++ ContextBuilder.java	15 Jan 2003 09:09:23 -0000	1.4
  @@ -56,7 +56,6 @@
   
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.context.Context;
  -import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.service.ServiceManager;
  @@ -67,6 +66,8 @@
   import org.apache.avalon.assembly.engine.RepositoryManager;
   import org.apache.avalon.assembly.engine.EngineClassLoader;
   import org.apache.avalon.assembly.engine.service.UnknownServiceException;
  +import org.apache.avalon.assembly.locator.DefaultLocator;
  +import org.apache.avalon.assembly.locator.Locator;
   import org.apache.avalon.meta.model.Entry;
   import org.apache.avalon.meta.model.Import;
   import org.apache.avalon.meta.model.Profile;
  @@ -109,10 +110,16 @@
           //
           // Create a new empty map that we will populate based on the descriptor
           // criteria, with assistance from the supplied directive, using the supplied 
  -        // context as the source
  +        // context as the source.  The initial map is populated with a set of default
  +        // values irrespective of meta declarations.  This is primarily to deal with 
  +        // legacy container assumptions.
           //
   
           Map map = new HashMap();
  +        map.put( "app.name", context.get( "urn:avalon:name" ) );
  +        map.put( "app.home", context.get( "urn:avalon:home" ) );
  +        map.put( "urn:avalon:name", context.get( "urn:avalon:name" ) );
  +        map.put( "urn:avalon:home", context.get( "urn:avalon:home" ) );
   
           //
           // get the entries declared by the context descriptor plus and 
  @@ -338,10 +345,10 @@
        * @exception ContextException if a required context value cannot be resolved or an error
        *   occurs during context value creation
        */
  -    static Context createContextInstance( ClassLoader classloader, ContextDirective directive, Map map ) 
  +    static Context createContextInstance( 
  +      ClassLoader classloader, ContextDescriptor descriptor, ContextDirective directive, Map map ) 
         throws ContextException
       {
  -
           //
           // check for meta-data about how to create a specialized context type
           // and if its present then create it using the standard constructor 
  @@ -350,7 +357,7 @@
   
           if( directive != null )
           {
  -            final String classname = directive.getClassname();
  +            String classname = directive.getClassname();
               Class clazz;
               try
               {
  @@ -380,7 +387,7 @@
               {
                   final String error = 
                     "Custom context class: [" + classname 
  -                  + "] does not implement the required constructor pattern <init>( Map, Context ).";
  +                  + "] does not implement the required constructor pattern <init>( Map, Locator ).";
    
                   throw new ContextException( error, e );
               }
  @@ -393,7 +400,7 @@
           }
           else
           {
  -            return new DefaultContext( map );
  +            return new DefaultLocator( map );
           }
           
       }
  
  
  
  1.23      +258 -77   avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java
  
  Index: DefaultAppliance.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- DefaultAppliance.java	9 Jan 2003 15:08:09 -0000	1.22
  +++ DefaultAppliance.java	15 Jan 2003 09:09:23 -0000	1.23
  @@ -77,10 +77,12 @@
   import org.apache.avalon.assembly.lifecycle.AssemblyException;
   import org.apache.avalon.assembly.locator.Locator;
   import org.apache.avalon.assembly.locator.Contextualizable;
  +import org.apache.avalon.assembly.locator.LocatorException;
   import org.apache.avalon.meta.info.ContextDescriptor;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.LoggerDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
  +import org.apache.avalon.meta.info.ReferenceDescriptor;
   import org.apache.avalon.meta.info.Type;
   import org.apache.avalon.meta.model.ContextDirective;
   import org.apache.avalon.meta.model.LoggingDirective;
  @@ -110,7 +112,7 @@
       //=====================================================================
   
       /**
  -     * The profile.
  +     * The apliance context.
        */
       private ApplianceContext m_applianceContext;
   
  @@ -122,7 +124,6 @@
       /**
        * The lifestyle service from which the appliance lifestyle handler is established.
        */
  -    private AssemblyService m_assembly;
   
       /**
        * The system context.
  @@ -197,6 +198,15 @@
   
       private LifestyleService m_lifestyle;
   
  +    private DependencyGraph m_graph;
  +
  +    private ArrayList m_visited = new ArrayList();
  +
  +   /**
  +    * Flag holding the dissasembled state of the block.
  +    */ 
  +    private boolean m_disassembled = false;
  +
       //=====================================================================
       // Contextualizable
       //=====================================================================
  @@ -209,7 +219,6 @@
       public void contextualize( Locator context ) throws ContextException
       {
           m_engine = (EngineClassLoader) context.get( "urn:assembly:engine" );
  -        m_assembly = (AssemblyService) context.get( "urn:assembly:assembly.service" );
           m_lifestyle = (LifestyleService) context.get( "urn:assembly:lifestyle.service" );
           m_applianceContext = (ApplianceContext) context.get( "urn:assembly:appliance.context" );
           m_system = (Locator) context.get( "urn:assembly:appliance.system" );
  @@ -264,7 +273,48 @@
                 "Unexpected lifestyle handler establishment failure in appliance: " + this;
               throw new ApplianceException( error, e );
           }
  +    }
  +
  +    //=====================================================================
  +    // Reclaimable
  +    //=====================================================================
  +
  +
  +    /**
  +     * Resolve a object to a value.
  +     *
  +     * @param partition the context within the the resolution is applied
  +     * @return the resolved object
  +     * @throws ContextException if an error occurs
  +     */
  +    public Object resolve( Object partition )
  +        throws LocatorException
  +    {
  +        if( !m_assembled )
  +        {
  +            throw new IllegalStateException( "Appliance has not been assembled: " + this );
  +        }
  +        return m_handler.resolve( partition );
  +    }
   
  +    /**
  +     * Release an object
  +     *
  +     * @param the object to be reclaimed
  +     * @param partition the context with respect the reclaimed object is qualified
  +     */
  +    public void release( Object object, Object partition )
  +    {
  +        try
  +        {
  +            m_handler.release( object, partition );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Lifestyle handler raised a release error in appliance: " + this;
  +            throw new ApplianceRuntimeException( error, e );
  +        }
       }
   
       //=====================================================================
  @@ -404,14 +454,24 @@
       * Assemble the appliance.
       * @exception AssemblyException if an error occurs during appliance assembly
       */
  -    public void assemble() throws AssemblyException
  +    public void assemble( DependencyGraph graph ) throws AssemblyException
       {
           if( m_assembled )
           {
               return;
           }
   
  -        m_assembly.assemble( this );
  +        m_graph = graph;
  +        synchronized( graph )
  +        {
  +            executeAssembly( graph );
  +        }
  +
  +        if( getLogger().isDebugEnabled() )
  +        {
  +            getLogger().debug( "assembly complete" );
  +        }
  +
           if( isContextEnabled() )
           {
               Map map = buildContextMap();
  @@ -420,6 +480,45 @@
   
           setEnabled( true );
           m_assembled = true;
  +
  +        if( getLogger().isDebugEnabled() )
  +        {
  +            Appliance[] providers = graph.getProviderGraph( this );
  +            StringBuffer buffer = new StringBuffer( "providers: " );
  +            for( int k=0; k<providers.length; k++ )
  +            {
  +               buffer.append( ", " + providers[k] );
  +            }
  +            getLogger().debug( buffer.toString() );
  +        }
  +    }
  +
  +   /**
  +    * Disassemble the appliance.
  +    */
  +    public void disassemble()
  +    {
  +        if( m_disassembled )
  +        {
  +            return;
  +        }
  +
  +        if( getLogger().isDebugEnabled() )
  +        {
  +            getLogger().debug( "disassemble" );
  +        }
  +
  +        Appliance[] consumers = getDependencyGraph().getConsumerGraph( this );
  +        for( int i=0; i<consumers.length; i++ )
  +        {
  +            Appliance consumer = consumers[i];
  +            m_graph.remove( consumer );
  +        }
  +    }
  +
  +    protected DependencyGraph getDependencyGraph()
  +    {
  +        return m_graph;
       }
   
       private boolean isContextEnabled()
  @@ -481,6 +580,14 @@
   
               m_deployment = map;
   
  +            //
  +            // ## NEXT 2 lines should be reviewed - is it needed ?
  +            // ## should not be required if alias is working properly
  +            //
  +
  +            map.put( "block.name", m_name );
  +            map.put( "app.home", new File( home, m_path ) );
  +
           }
           catch( Throwable e )
           {
  @@ -516,10 +623,11 @@
       */
       private Context buildContextObject( Map map ) throws AssemblyException
       {
  +        ContextDescriptor descriptor = m_applianceContext.getType().getContext();
           ContextDirective directive = m_applianceContext.getContextDirective();
           try
           {
  -            return BUILDER.createContextInstance( m_engine, directive, map );
  +            return BUILDER.createContextInstance( m_engine, descriptor, directive, map );
           }
           catch( Throwable e )
           {
  @@ -529,14 +637,6 @@
           }
       }
   
  -   /**
  -    * Disassemble the appliance.
  -    */
  -    public void disassemble()
  -    {
  -        m_assembly.disassemble( this );
  -    }
  -
       /**
        * Return the context provider.
        *
  @@ -553,7 +653,7 @@
        * @param applaince the appliance to be mapped as provider of the context
        * @exception IllegalStateException if the provider is already set
        */
  -    public void setContextProvider( Appliance appliance )
  +    private void setContextProvider( Appliance appliance )
       {
           if( m_contextProvider != null )
           {
  @@ -588,7 +688,7 @@
        * @param role the role against which the supplied resource is to be associated
        * @param appliance the appliance that will fulfill the dependency
        */
  -    public void addServiceProvider( String role, Appliance appliance )
  +    private void addServiceProvider( String role, Appliance appliance )
       {
           m_providers.put( role, appliance );
       }
  @@ -598,7 +698,7 @@
        * @param stage the identifier of the stage to assign the manager to
        * @param appliance the appliance that will handle the stage
        */
  -    public void addExtensionProvider( StageDescriptor stage, Appliance appliance )
  +    private void addExtensionProvider( StageDescriptor stage, Appliance appliance )
       {
           m_managers.put( stage, appliance );
       }
  @@ -624,82 +724,163 @@
           return (Appliance)m_managers.get( stage );
       }
   
  -   /**
  -    * Activate a service provided by the appliance.
  -    * @param appliance the appliance to deploy
  -    */
  -    public Object access( DependencyDescriptor dependency ) throws LifestyleException
  +    public String toString()
       {
  -        if( !m_assembled )
  -        {
  -            throw new IllegalStateException( "assembly" );
  -        }
  -        return m_handler.access( dependency );
  +        return "[" + getName() + "/" + System.identityHashCode( this ) + "]";
       }
   
      /**
  -    * Activate of the appliance.
  +    * Terminate the appliance.
       */
  -    public Object access() throws LifestyleException
  +    public void terminate()
       {
  -        if( !m_assembled )
  +        if( getLogger().isDebugEnabled() )
           {
  -            throw new IllegalStateException( "assembly" );
  +            getLogger().debug( "appliance termination" );
           }
  -        return m_handler.access();
  +        m_handler.terminate();
       }
   
  -   /**
  -    * Activate an extension handler provided by the appliance.
  -    * @param appliance the appliance to deploy
  -    */
  -    public Object access( StageDescriptor stage ) throws LifestyleException
  +    private void executeAssembly( DependencyGraph graph ) throws AssemblyException
       {
  -        if( !m_assembled )
  -        {
  -            throw new IllegalStateException( "assembly" );
  +        getLogger().debug( "assembly" );
  +        m_visited.add( this );
  +        ContextDescriptor context = getType().getContext();
  +        String ext = context.getAttribute( "urn:assembly:lifecycle.context.strategy" );
  +        if(( ext != null ) && ( getContextProvider() == null ))
  +        {
  +            final String message = "resolving context handler for: " + this ;
  +            getLogger().debug( message );
  +            Appliance supplier;
  +            ReferenceDescriptor ref = ReferenceDescriptor.newInstance( ext );
  +            StageDescriptor stage = new StageDescriptor( ref );
  +
  +            try
  +            {
  +                supplier = 
  +                  m_engine.resolve( graph, stage, getPartitionName() );
  +            }
  +            catch( Throwable e )
  +            {
  +                setEnabled( false );
  +                final String error =
  +                   "Unable to resolve a supplier for a context stage: " + ext
  +                   + " in appliance: " + this;
  +                throw new AssemblyException( error, e );
  +            }
  +            if( supplier == null )
  +            {
  +                final String error =
  +                  "Unresolved context strategy handler: " + ext;
  +                setEnabled( false );
  +                throw new AssemblyException( error );
  +            }
  +            else
  +            {
  +                setContextProvider( supplier );
  +                graph.add( supplier );
  +                getLogger().debug( "assigning context strategy handler: " + supplier );
  +            }
           }
  -        return m_handler.access( stage );
  -    }
   
  -   /**
  -    * Release a reference to a service provided by this appliance.
  -    * @param object the object to release
  -    * @exception ApplianceRuntimeException if the lifestyle release error occurs 
  -    */
  -    public void release( Object object ) throws ApplianceRuntimeException
  -    {
  -        try
  +        //
  +        // for all of the declared dependencies - make sure the
  +        // dependency is satisfied
  +        //
  +
  +        DependencyDescriptor[] dependencies = getType().getDependencies();
  +        for( int i = 0; i < dependencies.length; i++ )
           {
  -            m_handler.release( object );
  +            DependencyDescriptor dependency = dependencies[ i ];
  +            String role = dependency.getRole();
  +            if( getServiceProvider( role ) == null )
  +            {
  +
  +                getLogger().debug( "resolving role: [" + role + "] ");
  +
  +                //
  +                // select the preferred provider for the dependency - the dependency
  +                // argument contains the selection policy to apply
  +                //
  +
  +                Appliance supplier = null;
  +
  +                try
  +                {
  +                    supplier = m_engine.resolve( graph, dependency, getPartitionName() );
  +                }
  +                catch( Throwable e )
  +                {
  +                    setEnabled( false );
  +                    final String error =
  +                      "Unable to deploy a supplier for a service dependency: " + dependency;
  +                    throw new AssemblyException( error, e );
  +                }
  +
  +                if( supplier == null )
  +                {
  +                    final String message =
  +                        "Unresolved supplied for the dependency: "
  +                        + dependency.getReference() 
  +                        + ", for the role: " + dependency.getRole();
  +
  +                    setEnabled( false );
  +                    throw new AssemblyException( message );
  +                }
  +
  +                //
  +                // associate the supplier to the appliance
  +                //
  +
  +                addServiceProvider( role, supplier );
  +                getLogger().debug(
  +                  "associated supplier: " + supplier.getName()
  +                  + " under the key: " + role );
  +                graph.add( supplier );
  +            }
           }
  -        catch( Throwable e )
  +
  +        //
  +        // for all of the lifecycle phases - make sure we assign an extension
  +        // manager
  +        //
  +
  +        StageDescriptor[] stages = getType().getStages();
  +        for( int i = 0; i < stages.length; i++ )
           {
  -            final String error = 
  -              "Lifestyle handler raised a release error in appliance: " + this;
  -            throw new ApplianceRuntimeException( error, e );
  -        }
  -    }
  +            StageDescriptor stage = stages[ i ];
  +            if( getExtensionProvider( stage ) == null )
  +            {
   
  -    public String toString()
  -    {
  -        return "[" + getName() + "/" + System.identityHashCode( this ) + "]";
  -    }
  +                Appliance supplier = null;
   
  -   /**
  -    * Terminate the appliance.
  -    */
  -    public void terminate()
  -    {
  -        m_handler.terminate();
  +                try
  +                {
  +                    supplier = m_engine.resolve( graph, stage, getPartitionName() );
  +                }
  +                catch( Throwable e )
  +                {
  +                    final String error =
  +                      "Unable to resolve a supplier for a stage: " + stage;
  +                    throw new AssemblyException( error, e );
  +                }
  +
  +                if( supplier == null )
  +                {
  +                    final String message =
  +                      "Unresolved supplied for the stage: " + stage;
  +                    setEnabled( false );
  +                    throw new AssemblyException( message );
  +                }
  +
  +                //
  +                // associate the supplier to the appliance
  +                //
  +
  +                addExtensionProvider( stage, supplier );
  +                getLogger().debug( "associated extension provider: " + supplier );
  +                graph.add( supplier );
  +            }
  +        }
       }
  -
  -   /**
  -    * Return the loging channel for the appliance.
  -    * @return the logging channel
  -    */
  -    //protected Logger getLogger()
  -    //{
  -    //    return m_logger;
  -    //}
   }
  
  
  
  1.7       +3 -3      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceContext.java
  
  Index: DefaultApplianceContext.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceContext.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultApplianceContext.java	9 Jan 2003 15:08:09 -0000	1.6
  +++ DefaultApplianceContext.java	15 Jan 2003 09:09:23 -0000	1.7
  @@ -117,7 +117,7 @@
       /**
        * The activation policy - TRUE if activation on startup, FALSE to activate on request.
        */
  -    private boolean m_activation = true;
  +    private boolean m_activation = false;
   
      /**
       * The base path for the appliance.
  @@ -164,7 +164,6 @@
        */
       private String m_factory;
   
  -
       //==============================================================
       // constructor
       //==============================================================
  @@ -182,6 +181,7 @@
           }
           m_map = getData();
           m_profile = profile;
  +        m_activation = profile.getActivationPolicy();
       }
   
       //==============================================================
  
  
  
  1.5       +9 -60     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceFactory.java
  
  Index: DefaultApplianceFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultApplianceFactory.java	9 Jan 2003 15:09:37 -0000	1.4
  +++ DefaultApplianceFactory.java	15 Jan 2003 09:09:23 -0000	1.5
  @@ -191,7 +191,7 @@
       * @return the appliance
       */
       public Appliance createAppliance( 
  -      EngineClassLoader engine, ApplianceContext context ) 
  +      Locator system, EngineClassLoader engine, ApplianceContext context, Logger logger ) 
         throws ApplianceException
       {
           if( engine == null )
  @@ -202,20 +202,22 @@
           {
               throw new NullPointerException( "context" );
           }
  +        if( logger == null )
  +        {
  +            throw new NullPointerException( "logger" );
  +        }
   
           Appliance appliance = getApplianceInstance( engine, context );
   
  -        appliance.enableLogging( 
  -              getLogger().getChildLogger( context.getName() ) );
  +        appliance.enableLogging( logger );
   
           try
           {
  -            DefaultLocator locator = new DefaultLocator();
  +            DefaultLocator locator = new DefaultLocator( context );
               locator.put( "urn:assembly:engine", engine );
               locator.put( "urn:assembly:lifestyle.service", createLifestyleService( engine ) );
  -            locator.put( "urn:assembly:assembly.service", createAssemblyService( engine ) );
               locator.put( "urn:assembly:appliance.context", context );
  -            locator.put( "urn:assembly:appliance.system", m_system );
  +            locator.put( "urn:assembly:appliance.system", system );
               locator.makeReadOnly();
               appliance.contextualize( locator );
               appliance.initialize();
  @@ -258,60 +260,13 @@
       }
   
      /**
  -    * Utility to create the default assembly service.
  -    * @param manager a service manager
  -    * @return the bootstrap assembly service
  -    */
  -    private AssemblyService createAssemblyService( EngineClassLoader engine ) 
  -      throws ApplianceException
  -    {
  -        if( getLogger().isDebugEnabled() )
  -        {
  -            getLogger().debug( "creating assembly service" );
  -        }
  -
  -
  -        try
  -        {
  -            DependencyGraph graph = (DependencyGraph) m_system.get( "urn:assembly:dependency.graph" );
  -
  -            DefaultAssemblyService assembly = new DefaultAssemblyService();
  -            assembly.enableLogging( getLogger().getChildLogger( "assembly" ) );
  -            //MappedServiceManager manager = new MappedServiceManager( new Hashtable() );
  -            //manager.put("urn:assembly:engine.classloader", engine );
  -            //assembly.service( manager );
  -            DefaultLocator context = new DefaultLocator();
  -            if( graph != null )
  -            {
  -                context.put( "urn:assembly:dependency-map", graph );
  -                context.put( "urn:assembly:engine.classloader", engine );
  -            }
  -            assembly.contextualize( context );
  -            assembly.initialize();
  -            return assembly;
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = "Internal error while preparing boostrap assembly service.";
  -            throw new ApplianceException( error, e );
  -        }
  -    }
  -
  -
  -   /**
       * Utility to create the default lifestyle service.
       * @param manager a service manager
       * @return the bootstrap lifestyle service
       */
       private LifestyleService createLifestyleService( EngineClassLoader engine ) throws Exception
       {
  -        if( getLogger().isDebugEnabled() )
  -        {
  -            getLogger().debug( "creating lifestyle service" );
  -        }
  -
           DeploymentService deployment = createDeploymentService();
  -
           DefaultLifestyleService lifestyle = new DefaultLifestyleService();
           lifestyle.enableLogging( getLogger().getChildLogger( "lifestyle" ) );
           DefaultLocator context = new DefaultLocator();
  @@ -330,7 +285,6 @@
           try
           {
               LoggingManager logging = (LoggingManager) m_system.get( "urn:assembly:logging" );
  -
               DefaultDeploymentService deployment = new DefaultDeploymentService();
               deployment.enableLogging( getLogger() );
               DefaultLocator locator = new DefaultLocator();
  @@ -350,11 +304,6 @@
   
       private PoolManager getPoolManager( ) throws ApplianceException
       {
  -        if( getLogger().isDebugEnabled() )
  -        {
  -            getLogger().debug( "bootstrap pool manager" );
  -        }
  -
           try
           {
               //
  
  
  
  1.6       +40 -7     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DependencyGraph.java
  
  Index: DependencyGraph.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DependencyGraph.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DependencyGraph.java	21 Dec 2002 05:17:22 -0000	1.5
  +++ DependencyGraph.java	15 Jan 2003 09:09:23 -0000	1.6
  @@ -165,7 +165,15 @@
        */
       public Appliance[] getStartupGraph()
       {
  -        return walkGraph( true );
  +        try
  +        {
  +            return walkGraph( true );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Unexpect error while resolving startup graph.";
  +            throw new ApplianceRuntimeException( error, e );
  +        }
       }
   
       /**
  @@ -178,7 +186,15 @@
        */
       public Appliance[] getShutdownGraph()
       {
  -        return walkGraph( false );
  +        try
  +        {
  +            return walkGraph( false );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Unexpect error while resolving shutdown graph.";
  +            throw new ApplianceRuntimeException( error, e );
  +        }
       }
   
       /**
  @@ -190,7 +206,16 @@
        */
       public Appliance[] getConsumerGraph( final Appliance appliance )
       {
  -        return referencedAppliances( appliance, getComponentGraph( appliance, false ) );
  +        try
  +        {
  +            return referencedAppliances( appliance, getComponentGraph( appliance, false ) );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Unexpect error while resolving consumer graph for appliance: " + appliance;
  +            throw new ApplianceRuntimeException( error, e );
  +        }
       }
   
       /**
  @@ -202,7 +227,16 @@
        */
       public Appliance[] getProviderGraph( final Appliance appliance )
       {
  -        return referencedAppliances( appliance, getComponentGraph( appliance, true ) );
  +        try
  +        {
  +            return referencedAppliances( appliance, getComponentGraph( appliance, true ) );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Unexpect error while resolving provider graph for: " + appliance;
  +            throw new ApplianceRuntimeException( error, e );
  +        }
       }
   
       /**
  @@ -325,7 +359,7 @@
           }
   
           //
  -        // get all of the extensions the provide extension
  +        // get all of the extensions that provide extension
           // support to the subject appliance
           //
   
  @@ -350,7 +384,6 @@
   
           for( int i = 0; i < descriptors.length; i++ )
           {
  -
               DependencyDescriptor dependency = descriptors[ i ];
               Appliance provider = appliance.getServiceProvider( dependency.getRole() );
   
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceHolder.java
  
  Index: ApplianceHolder.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.appliance;
  
  import org.apache.avalon.assembly.locator.Resolvable;
  
  /**
   * Utility class used dereference resolution of a reolvable object. 
   * 
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/01/15 09:09:23 $
   */
  public class ApplianceHolder implements Resolvable
  {
      private Appliance m_appliance;
  
      public ApplianceHolder( Appliance appliance )
      {
          m_appliance = appliance;
      }
  
      public Object resolve( Object context )
      {
          return m_appliance;
      }
  }
  
  
  
  1.9       +28 -6     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/DefaultRepositoryManager.java
  
  Index: DefaultRepositoryManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/DefaultRepositoryManager.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultRepositoryManager.java	9 Jan 2003 15:08:10 -0000	1.8
  +++ DefaultRepositoryManager.java	15 Jan 2003 09:09:24 -0000	1.9
  @@ -77,6 +77,7 @@
   import org.apache.avalon.assembly.engine.profile.ProfileManager;
   import org.apache.avalon.assembly.engine.service.ServiceRepository;
   import org.apache.avalon.assembly.engine.model.*;
  +import org.apache.avalon.assembly.util.ExceptionHelper;
   import org.apache.avalon.excalibur.extension.Extension;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  @@ -106,11 +107,11 @@
       // static
       //===================================================================
   
  -    private static final String X_INFO = "xinfo";
  +    private static final String X_INFO = ".xinfo";
   
  -    private static final String X_TYPE = "xtype";
  +    private static final String X_TYPE = ".xtype";
   
  -    private static final String X_SERVICE = "xservice";
  +    private static final String X_SERVICE = ".xservice";
   
       private static final String AVALON_BLOCK_KEY = "Avalon-Block";
   
  @@ -243,6 +244,16 @@
           {
               final URL resource = new URL( "jar:" + url.toString() + "!/" );
               final JarURLConnection jar = (JarURLConnection)resource.openConnection();
  +
  +            /*
  +
  +            //
  +            // commented out the manifest checking bacause Phoenix distributions 
  +            // no longer provide manifest level declaration of that fact that the 
  +            // jar is a componetn container wehich means that we need to scan 
  +            // everything
  +            //
  +
               Manifest manifest = jar.getManifest();
               if( manifest == null )
               {
  @@ -256,6 +267,7 @@
                   m_scanned.add( url );
                   return;
               }
  +            */
   
               //
               // we are dealing with an Avalon Block so we need to scan the classes
  @@ -305,7 +317,12 @@
                       final String error = 
                         "Could not create type from classname: " + classname 
                         + " in the jar: " + base.getName();
  -                    throw new EngineRuntimeException( error, e );
  +                    if( getLogger().isWarnEnabled() )
  +                    {
  +                        final String warning = 
  +                          ExceptionHelper.packException( error, e, false );
  +                        getLogger().warn( warning );
  +                    }
                   }
               }
               else if( name.endsWith( X_INFO ) )
  @@ -322,7 +339,12 @@
                       final String error = 
                         "Could not create type from classname: " + classname 
                         + " in the jar: " + base.getName();
  -                    throw new EngineRuntimeException( error, e );
  +                    if( getLogger().isWarnEnabled() )
  +                    {
  +                        final String warning = 
  +                          ExceptionHelper.packException( error, e, false );
  +                        getLogger().warn( warning );
  +                    }
                   }
               }
   
  
  
  
  1.11      +24 -6     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/Engine.java
  
  Index: Engine.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/Engine.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Engine.java	21 Dec 2002 05:17:22 -0000	1.10
  +++ Engine.java	15 Jan 2003 09:09:24 -0000	1.11
  @@ -60,6 +60,7 @@
   import org.apache.avalon.assembly.appliance.Appliance;
   import org.apache.avalon.assembly.appliance.ApplianceException;
   import org.apache.avalon.assembly.appliance.ApplianceContext;
  +import org.apache.avalon.assembly.appliance.DependencyGraph;
   import org.apache.avalon.assembly.engine.model.ClasspathDescriptor;
   import org.apache.avalon.assembly.lifecycle.AssemblyService;
   import org.apache.avalon.assembly.lifestyle.LifestyleService;
  @@ -76,6 +77,12 @@
   public interface Engine 
   {
      /**
  +    * Returns the repository manager.
  +    * @return the repository manager
  +    */
  +    RepositoryManager getRepository();
  +
  +   /**
       * Dynamic registration of a type and associated profiles with the container.
       * @param path the path to the appliance implementation class
       * @return the appliance
  @@ -89,7 +96,18 @@
       * @param shared TRUE if this appliance may be shared
       * @return the appliance
       */
  -    Appliance createAppliance( ApplianceContext context, boolean shared ) throws ApplianceException;
  +    Appliance createAppliance( 
  +      ApplianceContext context, boolean shared ) throws ApplianceException;
  +
  +   /**
  +    * Create a new appliance.
  +    * @param context the appliance context
  +    * @param shared TRUE if this appliance may be shared
  +    * @param nested if TRUE the return appliance is assigned a child logging channel
  +    * @return the appliance
  +    */
  +    Appliance createAppliance( 
  +      ApplianceContext context, boolean shared, boolean nested ) throws ApplianceException;
   
      /**
       * Resolve an appliance capable of supporting a supplied service 
  @@ -98,7 +116,7 @@
       * @param dependency a service depedency descriptor
       * @return the appliance
       */
  -    Appliance resolve( DependencyDescriptor dependency ) throws Exception;
  +    Appliance resolve( DependencyGraph graph, DependencyDescriptor dependency ) throws Exception;
   
      /**
       * Resolve an appliance capable of supporting a service 
  @@ -108,7 +126,7 @@
       * @param partition the partition to assign to a new appliance if creation is necessary
       * @return the appliance
       */
  -    Appliance resolve( DependencyDescriptor dependency, String partition ) throws Exception;
  +    Appliance resolve( DependencyGraph graph, DependencyDescriptor dependency, String partition ) throws Exception;
   
      /**
       * Resolve an appliance capable of supporting a referenced extension.
  @@ -116,7 +134,7 @@
       * @param stage a lifecycle stage descriptor
       * @return the appliance
       */
  -    Appliance resolve( StageDescriptor stage ) throws Exception;
  +    Appliance resolve( DependencyGraph graph, StageDescriptor stage ) throws Exception;
   
      /**
       * Resolve an appliance capable of supporting a referenced extension.
  @@ -125,6 +143,6 @@
       * @param partition the partition to assign to a new appliance if creation is necessary
       * @return the appliance
       */
  -    Appliance resolve( StageDescriptor stage, String partition ) throws Exception;
  +    Appliance resolve( DependencyGraph graph, StageDescriptor stage, String partition ) throws Exception;
   
   }
  
  
  
  1.25      +73 -49    avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java
  
  Index: EngineClassLoader.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- EngineClassLoader.java	9 Jan 2003 15:08:10 -0000	1.24
  +++ EngineClassLoader.java	15 Jan 2003 09:09:24 -0000	1.25
  @@ -151,12 +151,6 @@
       private URL[] m_parsable = new URL[0];
   
      /**
  -    * The supplied configuration.  The configuration may be empty
  -    * as defaults are provided for all values.
  -    */
  -    private DependencyGraph m_graph;
  -
  -   /**
       * The base system wide context.
       */
       private Locator m_system;
  @@ -251,7 +245,6 @@
       public EngineClassLoader()
       {
           super( new URL[ 0 ] );
  -        m_graph = new DependencyGraph();
           m_parsable = getParentURLs();
       }
   
  @@ -262,7 +255,6 @@
       public EngineClassLoader( ClassLoader parent )
       {
           super( new URL[ 0 ], parent );
  -        m_graph = getDependencyGraph( parent );
           m_parsable = getParentURLs();
       }
   
  @@ -274,7 +266,6 @@
       public EngineClassLoader( URL[] urls, ClassLoader parent )
       {
           super( new URL[ 0 ], parent );
  -        m_graph = getDependencyGraph( parent );
           m_urls = urls;
           m_parsable = getParentURLs();
       }
  @@ -554,11 +545,6 @@
           return m_logging;
       }
   
  -    protected DependencyGraph getDependencyGraph()
  -    {
  -        return m_graph;
  -    }
  -
       protected ExtensionManager getExtensionManager()
       {
           return m_extensions;
  @@ -762,9 +748,9 @@
       * @param dependency a service depedency descriptor
       * @return the appliance
       */
  -    public Appliance resolve( DependencyDescriptor dependency ) throws Exception
  +    public Appliance resolve( DependencyGraph graph, DependencyDescriptor dependency ) throws Exception
       {
  -        return resolve( dependency, "" );
  +        return resolve( graph, dependency, "" );
       }
   
      /**
  @@ -775,17 +761,27 @@
       * @param partition the partition name
       * @return the appliance
       */
  -    public Appliance resolve( DependencyDescriptor dependency, String partition ) throws Exception
  +    public Appliance resolve( 
  +      DependencyGraph graph, DependencyDescriptor dependency, String partition ) throws Exception
       {
  +        if( graph == null )
  +        {
  +            throw new IllegalStateException( "graph" );
  +        }
           if( dependency == null )
           {
               throw new IllegalStateException( "dependency" );
           }
  +        if( partition == null )
  +        {
  +            throw new IllegalStateException( "partition" );
  +        }
   
           if( getLogger().isDebugEnabled() )
           {
               getLogger().debug( "resolve: " + dependency );
           }
  +
           Appliance appliance = m_appliances.getAppliance( dependency );
           if( appliance == null )
           {
  @@ -801,9 +797,19 @@
                   context.setPartitionName( partition );
                   context.makeReadOnly();
                   appliance = createAppliance( context, true );
  -                appliance.assemble();
               }
           }
  +
  +        try
  +        {
  +            appliance.assemble( graph );
  +        }
  +        catch( Throwable e )
  +        {
  +            throw new ApplianceException(
  +                  "Unresolvable assembly graph for appliance: " + appliance );
  +        }
  +
           return appliance;
       }
   
  @@ -813,9 +819,9 @@
       * @param stage a lifecycle stage descriptor
       * @return the appliance
       */
  -    public Appliance resolve( StageDescriptor stage ) throws Exception
  +    public Appliance resolve( DependencyGraph graph, StageDescriptor stage ) throws Exception
       {
  -        return resolve( stage, "" );
  +        return resolve( graph, stage, "" );
       }
   
      /**
  @@ -825,7 +831,7 @@
       * @param partition the partition to assign to a new appliance if creation is necessary
       * @return the appliance
       */
  -    public Appliance resolve( StageDescriptor stage, String partition ) throws Exception
  +    public Appliance resolve( DependencyGraph graph, StageDescriptor stage, String partition ) throws Exception
       {
           if( stage == null )
           {
  @@ -851,9 +857,19 @@
                   context.setPartitionName( partition );
                   context.makeReadOnly();
                   appliance = createAppliance( context, true );
  -                appliance.assemble();
               }
           }
  +
  +        try
  +        {
  +            appliance.assemble( graph );
  +        }
  +        catch( Throwable e )
  +        {
  +            throw new ApplianceException(
  +                  "Unresolvable assembly graph for appliance: " + appliance );
  +        }
  +
           return appliance;
       }
   
  @@ -861,33 +877,60 @@
       * 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
       * @return the appliance
       */
  -    public Appliance createAppliance( ApplianceContext context, boolean shared ) throws ApplianceException
  +    public Appliance createAppliance( 
  +      ApplianceContext context, boolean shared ) throws ApplianceException
  +    {
  +        return createAppliance( context, shared, true );
  +    }
  +
  +   /**
  +    * Create a new non-assembled 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
  +    * @return the appliance
  +    */
  +    public Appliance createAppliance( 
  +      ApplianceContext context, boolean shared, boolean nested ) throws ApplianceException
       {
           if( context == null )
           {
               throw new NullPointerException( "context" );
           }
  +
  +        Logger logger;
  +        if( nested ) 
  +        {
  +            logger = getLogger().getChildLogger( context.getName() );
  +        }
  +        else
  +        {
  +            logger = getLogger();
  +        }
  +
           String classname = context.getApplianceFactoryClassname();
  -        Appliance appliance;
  +        ApplianceFactory factory;
           if( classname == null )
           {
  -            appliance = m_factory.createAppliance( this, context );
  +            factory = m_factory;
           }
           else
           {
  -            String name = context.getName();
  -            Logger logger = getLogger().getChildLogger( name );
  -            ApplianceFactory factory = 
  +            factory = 
                 DefaultApplianceFactory.createApplianceFactory( 
                   this, classname, logger, getSystemContext() );
  -            appliance = factory.createAppliance( this, context );
           }
  +
  +        Appliance appliance = factory.createAppliance( getSystemContext(), this, context, logger );
  +
           if( shared )
           {
               m_appliances.addAppliance( appliance );
           }
  +
           return appliance;
       }
   
  @@ -896,24 +939,6 @@
       //==============================================================
   
      /**
  -    * If the supplied loader is an engine, then create a depedency graph
  -    * using the parent graph, otherwise return a root graph.
  -    * @param loader the parent classloader
  -    * @return a depedency graph
  -    */
  -    private DependencyGraph getDependencyGraph( ClassLoader loader )
  -    {
  -        if( loader instanceof EngineClassLoader )
  -        {
  -            return new DependencyGraph( ((EngineClassLoader)loader).getDependencyGraph() );
  -        }
  -        else
  -        {
  -            return new DependencyGraph();
  -        }
  -    }
  -
  -   /**
       * If the parent classloader is not a engine, then we need to scan the parent classloaders
       * jar files for component types.  This method recursively steps through the parent heirachy 
       * looking for jar files and collapses these into URL array that can be scanned by the 
  @@ -1038,7 +1063,6 @@
           }
   
           context.put( "urn:assembly:logging", getLoggingManager() );
  -        context.put( "urn:assembly:dependency.graph", getDependencyGraph() );
           m_system = context;
           return m_system;
       }
  
  
  
  1.6       +28 -9     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/DefaultAssemblyService.java
  
  Index: DefaultAssemblyService.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/DefaultAssemblyService.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultAssemblyService.java	9 Jan 2003 15:08:10 -0000	1.5
  +++ DefaultAssemblyService.java	15 Jan 2003 09:09:24 -0000	1.6
  @@ -172,11 +172,11 @@
       */
       public void assemble( Appliance appliance ) throws AssemblyException
       {
  -        if( appliance == null )
  -        {
  -            throw new NullPointerException( "appliance" );
  -        }
  -        assembleAppliance( m_map, appliance, m_visited, "" );
  +        //if( appliance == null )
  +        //{
  +       //     throw new NullPointerException( "appliance" );
  +       // }
  +       // assembleAppliance( m_map, appliance, m_visited, "" );
       }
   
      /**
  @@ -185,11 +185,26 @@
       */
       public void disassemble( Appliance appliance )
       {
  +        /*
  +        Appliance[] consumers = m_map.getConsumerGraph( appliance );
  +        Appliance[] providers = m_map.getProviderGraph( appliance );
           if( getLogger().isDebugEnabled() )
           {
  -            getLogger().debug("dissasemble: " + appliance );
  +            StringBuffer buffer = new StringBuffer();
  +            buffer.append( "dissasemble (consumers): " + appliance );
  +            for( int j=0; j<consumers.length; j++ )
  +            {
  +               buffer.append( ", " + consumers[j] );
  +            }
  +            getLogger().debug( buffer.toString() );
  +            buffer = new StringBuffer();
  +            buffer.append( "dissasemble (providers): " + appliance );
  +            for( int k=0; k<providers.length; k++ )
  +            {
  +               buffer.append( ", " + providers[k] );
  +            }
  +            getLogger().debug( buffer.toString() );
           }
  -        Appliance[] consumers = m_map.getConsumerGraph( appliance );
           for( int i=0; i<consumers.length; i++ )
           {
               Appliance consumer = consumers[i];
  @@ -200,6 +215,7 @@
               consumer.terminate();
               m_map.remove( consumer );
           }
  +        */
       }
   
      /**
  @@ -238,6 +254,7 @@
        * @param pad used in formatting log messages
        * @exception AssemblyException if an assembly related error occurs
        */
  +/*
       private void assembleAppliance(
           DependencyGraph map, Appliance appliance, List visited, String pad )
           throws AssemblyException
  @@ -421,7 +438,8 @@
               }
           }
       }
  -
  +*/
  +/*
       private boolean assembleManagers(
           DependencyGraph map, Appliance appliance, StageDescriptor stage,
           List visited, String pad )
  @@ -473,4 +491,5 @@
           }
           return ok;
       }
  +*/
   }
  
  
  
  1.13      +13 -13    avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/DefaultDeploymentService.java
  
  Index: DefaultDeploymentService.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/DefaultDeploymentService.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultDeploymentService.java	9 Jan 2003 15:08:10 -0000	1.12
  +++ DefaultDeploymentService.java	15 Jan 2003 09:09:24 -0000	1.13
  @@ -261,16 +261,16 @@
           // make sure we are deploying a fully assembled appliance
           //
   
  -        try
  -        {
  -            appliance.assemble();
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Unresolved dependencies in appliance: " + appliance;
  -            throw new DeploymentException( error, e );
  -        }
  +        //try
  +        //{
  +        //    appliance.assemble();
  +        //}
  +        //catch( Throwable e )
  +        //{
  +        //    final String error = 
  +        //      "Unresolved dependencies in appliance: " + appliance;
  +        //    throw new DeploymentException( error, e );
  +        //}
   
           //
           // commence deployment
  @@ -296,10 +296,10 @@
           try
           {
               m_logging.enableLogging( appliance, instance );
  -            m_configuration.configure( appliance, instance );
  -            m_parameters.parameterize( appliance, instance );
               m_contextualization.contextualize( appliance, instance );
               m_composition.service( appliance, instance );
  +            m_configuration.configure( appliance, instance );
  +            m_parameters.parameterize( appliance, instance );
               m_initialization.initialize( appliance, instance );
               m_startup.start( appliance, instance );
               return instance;
  
  
  
  1.6       +3 -3      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/DefaultCompositionService.java
  
  Index: DefaultCompositionService.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/DefaultCompositionService.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultCompositionService.java	21 Dec 2002 03:28:37 -0000	1.5
  +++ DefaultCompositionService.java	15 Jan 2003 09:09:24 -0000	1.6
  @@ -52,7 +52,6 @@
   
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.WrapperComponentManager;
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.service.Serviceable;
  @@ -116,7 +115,8 @@
               manager.enableLogging( getLogger().getChildLogger( "manager" ) );
               try
               {
  -                ((Composable)object).compose( new WrapperComponentManager( manager ) );
  +                ((Composable)object).compose( 
  +                  new WrapperComponentManager( manager ) );
               }
               catch( ComponentException e )
               {
  
  
  
  1.3       +5 -3      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/StandardServiceManager.java
  
  Index: StandardServiceManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/StandardServiceManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StandardServiceManager.java	20 Dec 2002 11:54:28 -0000	1.2
  +++ StandardServiceManager.java	15 Jan 2003 09:09:25 -0000	1.3
  @@ -75,7 +75,7 @@
       //========================================================================
   
       /**
  -     * A map of resources keyed by lookup role.
  +     * The appliance from which provide appliances are resolved.
        */
       private Appliance m_appliance;
   
  @@ -139,7 +139,8 @@
   
           try
           {
  -            Object object = provider.access( dependency );
  +            //Object object = provider.access( dependency );
  +            Object object = provider.resolve( this );
               m_table.put( object, provider );
               return object;
           }
  @@ -174,7 +175,8 @@
           }
           else
           {
  -            provider.release( object );
  +            //provider.release( object );
  +            provider.release( object, this );
               m_table.remove( object );
           }
       }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/ComponentInvocationHandler.java
  
  Index: ComponentInvocationHandler.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.assembly.lifecycle.composition;
  
  import java.lang.reflect.InvocationHandler;
  import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.Method;
  import java.lang.reflect.Proxy;
  import org.apache.avalon.meta.info.Type;
  import org.apache.avalon.meta.info.ServiceDescriptor;
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.component.ComponentException;
  
  /**
   * This makes a dynamic proxy for an object.  The object can be represented
   * by one, some or all of it's interfaces.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version CVS $Revision: 1.1 $ $Date: 2003/01/15 09:09:24 $
   */
  final class ComponentInvocationHandler
      implements InvocationHandler
  {
      private transient Object m_object;
      private transient Component m_proxy;
  
      /**
       * Create a proxy object that has interfaces implemented by proxy defined by the component type.
       *
       * @param object the underlying object
       * @param type the component type
       */
      protected ComponentInvocationHandler( final Object object, Type type ) throws ComponentException
      {
          final ClassLoader loader = object.getClass().getClassLoader();
          
          Class[] interfaces = getClasses( type, loader );
  
          m_object = object;
          m_proxy = (Component) Proxy.newProxyInstance( loader, interfaces, this );
      }
  
      /**
       * Invalidate Proxy making it impossible to call methods
       * of real-object.
       */
      public void invalidate()
      {
          m_object = null;
          m_proxy = null;
      }
  
      /**
       * Return the proxy object.
       *
       * @return the proxy object
       */
      public Component getProxy()
      {
          return m_proxy;
      }
  
      /**
       * Invoke the specified method on underlying object.
       * This is called by proxy object.
       *
       * @param proxy the proxy object
       * @param method the method invoked on proxy object
       * @param args the arguments supplied to method
       * @return the return value of method
       * @throws Throwable if an error occurs
       */
      public Object invoke( final Object proxy,
                            final Method method,
                            final Object[] args )
          throws Throwable
      {
          if( null == m_object )
          {
              throw new IllegalStateException( "Invalid proxy." );
          }
  
          try
          {
              return method.invoke( m_object, args );
          }
          catch( final InvocationTargetException ite )
          {
              throw ite.getTargetException();
          }
      }
  
      private Class[] getClasses( Type type, ClassLoader loader ) throws ComponentException
      {
          try
          {
              ServiceDescriptor[] services = type.getServices();
              Class[] classes = new Class[ services.length + 1 ];
              for( int i=0; i<services.length; i++ )
              {
                  classes[i] = loader.loadClass( services[i].getReference().getClassname() );
              }
              classes[ services.length ] = Component.class;
              return classes;
          }
          catch( Throwable e )
          {
              final String error = 
                "Unable to create a Component proxy for an type: " + type;
              throw new ComponentException( error, e );
          }
      }
  
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/WrapperComponentManager.java
  
  Index: WrapperComponentManager.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.assembly.lifecycle.composition;
  
  import java.lang.reflect.Proxy;
  
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.framework.service.ServiceSelector;
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentSelector;
  import org.apache.avalon.assembly.engine.Engine;
  import org.apache.avalon.meta.info.Type;
  import org.apache.avalon.meta.info.ServiceDescriptor;
  
  /**
   * This is a {@link ComponentManager} implementation that can wrap around a
   * {@link ServiceManager} object effectively adapting a {@link ServiceManager}
   * interface to a {@link ComponentManager} interface.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/01/15 09:09:25 $
   */
  public class WrapperComponentManager
      implements ComponentManager
  {
      /**
       * The service manager we are adapting.
       */
      private final ServiceManager m_manager;
  
      public WrapperComponentManager( final ServiceManager manager )
      {
          if( null == manager )
          {
              throw new NullPointerException( "manager" );
          }
  
          m_manager = manager;
      }
  
      /**
       * Retrieve a component via a key.
       *
       * @param key the key
       * @return the component
       * @throws ComponentException if unable to aquire component
       */
      public Component lookup( final String key )
          throws ComponentException
      {
          try
          {
              final Object object = m_manager.lookup( key );
              if( object instanceof ServiceSelector )
              {
                  return new WrapperComponentSelector( key, (ServiceSelector)object );
              }
              else 
              {
                  if( object instanceof Component )
                  {
                      return (Component)object;
                  }
                  else
                  {
                      //
                      // use the services defined by the type and use them to 
                      // construct a proxy together with the Component interface
                      //
  
                      Class clazz = object.getClass();
                      ClassLoader loader = clazz.getClassLoader();
                      if( !( loader instanceof Engine ) )
                      {
                          final String error = 
                            "Resolved component is not contained within an engine classloader. "
                            + "Cannot build a Component interface proxy.";
                          throw new ComponentException( key, error );
                      }
  
                      Type type = ((Engine)loader).getRepository().getTypeManager().getType( clazz );
                      return new ComponentInvocationHandler( object, type ).getProxy();
                  }
              }
          }
          catch( final ServiceException se )
          {
              throw new ComponentException( se.getKey(), se.getMessage(), se.getCause() );
          }
          catch( final Throwable e )
          {
              final String error = 
                "Unexpected error while handling component lookup request.";
              throw new ComponentException( key, error, e );
          }
      }
  
      /**
       * Check to see if a <code>Component</code> exists for a key.
       *
       * @param key  a string identifying the key to check.
       * @return True if the component exists, False if it does not.
       */
      public boolean hasComponent( final String key )
      {
          return m_manager.hasService( key );
      }
  
      /**
       * Return the <code>Component</code> when you are finished with it.  This
       * allows the <code>ComponentManager</code> to handle the End-Of-Life Lifecycle
       * events associated with the Component.  Please note, that no Exceptions
       * should be thrown at this point.  This is to allow easy use of the
       * ComponentManager system without having to trap Exceptions on a release.
       *
       * @param component The Component we are releasing.
       */
      public void release( final Component component )
      {
          if( component instanceof WrapperComponentSelector )
          {
              m_manager.
                  release( ( (WrapperComponentSelector)component ).getWrappedSelector() );
          }
          else
          {
              m_manager.release( component );
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/WrapperComponentSelector.java
  
  Index: WrapperComponentSelector.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation. All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software
   *    itself, if and wherever such third-party acknowledgments
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.avalon.assembly.lifecycle.composition;
  
  import org.apache.avalon.framework.service.ServiceSelector;
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.component.ComponentSelector;
  import org.apache.avalon.framework.component.ComponentException;
  
  /**
   * This is a {@link ServiceSelector} implementation that can wrap around a legacy
   * {@link ComponentSelector} object effectively adapting a {@link ComponentSelector}
   * interface to a {@link ServiceSelector} interface.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version CVS $Revision: 1.1 $ $Date: 2003/01/15 09:09:25 $
   */
  public class WrapperComponentSelector
      implements ComponentSelector
  {
      /**
       * The Selector we are wrapping.
       */
      private final ServiceSelector m_selector;
  
      /**
       * The role that this selector was aquired via.
       */
      private final String m_key;
  
      /**
       * This constructor is a constructor for a WrapperComponentSelector.
       *
       * @param key the key used to aquire this selector
       * @param selector the selector to wrap
       */
      public WrapperComponentSelector( final String key,
                                       final ServiceSelector selector )
      {
          if( null == key )
          {
              throw new NullPointerException( "key" );
          }
          if( null == selector )
          {
              throw new NullPointerException( "selector" );
          }
  
          m_key = key + "/";
          m_selector = selector;
      }
  
      /**
       * Select a Component based on a policy.
       *
       * @param policy the policy
       * @return the Component
       * @throws ComponentException if unable to select service
       */
      public Component select( final Object policy )
          throws ComponentException
      {
          try
          {
              final Object object = m_selector.select( policy );
              if( object instanceof Component )
              {
                  return (Component)object;
              }
          }
          catch( final ServiceException se )
          {
              throw new ComponentException( m_key + policy, se.getMessage(), se );
          }
  
          final String message = "Role does not implement the Component " +
              "interface and thus can not be accessed via ComponentSelector";
          throw new ComponentException( m_key + policy, message );
      }
  
      /**
       * Check to see if a {@link Component} exists relative to the supplied policy.
       *
       * @param policy a {@link Object} containing the selection criteria
       * @return True if the component is available, False if it not.
       */
      public boolean hasComponent( final Object policy )
      {
          return m_selector.isSelectable( policy );
      }
  
      /**
       * Return the {@link Object} when you are finished with it.  This
       * allows the {@link ServiceSelector} to handle the End-Of-Life Lifecycle
       * events associated with the {@link Object}.  Please note, that no
       * Exception should be thrown at this point.  This is to allow easy use of the
       * ServiceSelector system without having to trap Exceptions on a release.
       *
       * @param object The {@link Object} we are releasing.
       */
      public void release( final Component object )
      {
          m_selector.release( object );
      }
  
      /**
       * The {@link WrapperComponentManager} wraps ServiceSelectors in
       *  WrapperServiceSelectors when they are looked up.  This method
       *  makes it possible to release the original component selector.
       *
       * @return The {@link ServiceSelector} being wrapped.
       */
      ServiceSelector getWrappedSelector()
      {
          return m_selector;
      }
  }
  
  
  
  1.11      +10 -3     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/context/DefaultContextualizationService.java
  
  Index: DefaultContextualizationService.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/context/DefaultContextualizationService.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DefaultContextualizationService.java	9 Jan 2003 03:58:26 -0000	1.10
  +++ DefaultContextualizationService.java	15 Jan 2003 09:09:25 -0000	1.11
  @@ -114,15 +114,17 @@
                   if( getLogger().isDebugEnabled() )
                   {
                       final String message = 
  -                      "Activating custom context: " + provider
  +                      "activating custom provider: " + provider
                         + " for appliance: " + appliance;
                       getLogger().debug( message );
                   }
   
                   try
                   {
  -                    Contextualization handler = (Contextualization) provider.access();
  +                    //Contextualization handler = (Contextualization) provider.access();
  +                    Contextualization handler = (Contextualization) provider.resolve( this );
                       handler.contextualize( object, context );
  +                    provider.release( handler, this ); // ## new
                       return;
                   }
                   catch( Throwable e )
  @@ -139,6 +141,11 @@
   
               if( object instanceof Contextualizable )
               {
  +                if( getLogger().isDebugEnabled() )
  +                {
  +                    final String message = appliance.toString();
  +                    getLogger().debug( message );
  +                }
                   try
                   {
                       ((Contextualizable)object).contextualize( context );
  
  
  
  1.10      +5 -3      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/disposal/ExtendedDisposalService.java
  
  Index: ExtendedDisposalService.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/disposal/ExtendedDisposalService.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ExtendedDisposalService.java	21 Dec 2002 09:26:34 -0000	1.9
  +++ ExtendedDisposalService.java	15 Jan 2003 09:09:25 -0000	1.10
  @@ -154,7 +154,8 @@
               Creator handler = null;
               try
               {
  -                handler = (Creator) provider.access( stage );
  +                //handler = (Creator) provider.access( stage );
  +                handler = (Creator) provider.resolve( this );
               }
               catch( Throwable e )
               {
  @@ -169,7 +170,8 @@
               try
               {
                   handler.destroy( object, appliance.getContext() );
  -                provider.release( handler );
  +                //provider.release( handler );
  +                provider.release( handler, this );
               }
               catch( Throwable e )
               {
  
  
  
  1.12      +5 -3      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization/ExtendedInitializationService.java
  
  Index: ExtendedInitializationService.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization/ExtendedInitializationService.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ExtendedInitializationService.java	9 Jan 2003 15:08:10 -0000	1.11
  +++ ExtendedInitializationService.java	15 Jan 2003 09:09:25 -0000	1.12
  @@ -133,7 +133,8 @@
                   Creator handler = null;
                   try
                   {
  -                    handler = (Creator) provider.access( stage );
  +                    //handler = (Creator) provider.access( stage );
  +                    handler = (Creator) provider.resolve( this );
                   }
                   catch( Throwable e )
                   {
  @@ -148,7 +149,8 @@
                   try
                   {
                       handler.create( object, appliance.getContext() );
  -                    provider.release( handler );
  +                    //provider.release( handler );
  +                    provider.release( handler, this );
                   }
                   catch( Throwable e )
                   {
  
  
  
  1.17      +13 -8     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/AbstractLifestyleHandler.java
  
  Index: AbstractLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/AbstractLifestyleHandler.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- AbstractLifestyleHandler.java	9 Jan 2003 15:08:10 -0000	1.16
  +++ AbstractLifestyleHandler.java	15 Jan 2003 09:09:25 -0000	1.17
  @@ -70,6 +70,7 @@
   import org.apache.avalon.assembly.appliance.Appliance;
   import org.apache.avalon.assembly.lifecycle.DeploymentService;
   import org.apache.avalon.assembly.locator.Contextualizable;
  +import org.apache.avalon.assembly.locator.LocatorException;
   import org.apache.avalon.assembly.locator.Locator;
   import org.apache.avalon.lifecycle.Accessor;
   
  @@ -181,20 +182,22 @@
       * Activate a service provided by the appliance.
       * @param appliance the appliance to deploy
       */
  -    public abstract Object access( DependencyDescriptor dependency ) throws LifestyleException;
  +    //public abstract Object access( DependencyDescriptor dependency ) throws LifestyleException;
  +    public abstract Object resolve( Object partition ) throws LocatorException;
   
      /**
       * Activate an extension handler provided by the appliance.
       * @param appliance the appliance to deploy
       */
  -    public abstract Object access( StageDescriptor stage ) throws LifestyleException;
  +    //public abstract Object access( StageDescriptor stage ) throws LifestyleException;
   
      /**
       * 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
       */
  -    public void release( Object object )
  +    //public void release( Object object )
  +    public void release( Object object, Object partition )
       {
           if( getLogger().isDebugEnabled() )
           {
  @@ -262,7 +265,7 @@
        * @param object the object to process
        * @exception Exception if a stage procesing exception occurs
        */
  -    protected void processAccessStage( Object object ) throws LifestyleException
  +    protected void processAccessStage( Object object ) throws LifestyleException, ContextException
       {
           StageDescriptor[] phases = getAppliance().getType().getStages();
           for( int i = 0; i < phases.length; i++ )
  @@ -311,7 +314,7 @@
           StageDescriptor stage,
           Object object,
           boolean access )
  -        throws LifestyleException
  +        throws LifestyleException, ContextException
       {
           Appliance provider = m_appliance.getExtensionProvider( stage );
           if( provider == null )
  @@ -324,7 +327,8 @@
   
           if( Accessor.class.isAssignableFrom( getImplementationClass( provider ) ) )
           {
  -            Accessor extension = (Accessor) provider.access( stage );
  +            //Accessor extension = (Accessor) provider.access( stage );
  +            Accessor extension = (Accessor) provider.resolve( this );
               try
               {
                   Context context = getAppliance().getContext();
  @@ -336,7 +340,8 @@
                   {
                       extension.release( object, context );
                   }
  -                provider.release( extension );
  +                //provider.release( extension );
  +                provider.release( extension, this );
               }
               catch( Throwable e )
               {
  
  
  
  1.7       +3 -2      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/DefaultLifestyleService.java
  
  Index: DefaultLifestyleService.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/DefaultLifestyleService.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultLifestyleService.java	9 Jan 2003 15:08:10 -0000	1.6
  +++ DefaultLifestyleService.java	15 Jan 2003 09:09:25 -0000	1.7
  @@ -66,6 +66,7 @@
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.avalon.assembly.appliance.Appliance;
  +import org.apache.avalon.assembly.appliance.ApplianceHolder;
   import org.apache.avalon.assembly.engine.Engine;
   import org.apache.avalon.assembly.lifecycle.DeploymentService;
   import org.apache.avalon.assembly.lifecycle.DefaultDeploymentService;
  @@ -188,7 +189,7 @@
           {
               context.put( "urn:assembly:deployment.context", deploymentContext );
           }
  -        context.put( "urn:assembly:appliance.target", appliance );
  +        context.put( "urn:assembly:appliance.target", new ApplianceHolder( appliance ) );
           context.put( "urn:avalon:classloader", classloader );
           context.put(  "urn:assembly:lifecycle.deployment", m_deployment );
           context.makeReadOnly();
  
  
  
  1.5       +7 -6      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleHandler.java
  
  Index: LifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LifestyleHandler.java	17 Dec 2002 04:57:20 -0000	1.4
  +++ LifestyleHandler.java	15 Jan 2003 09:09:25 -0000	1.5
  @@ -52,6 +52,7 @@
   
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
  +import org.apache.avalon.assembly.locator.Reclaimable;
   
   /**
    * A lifestyle handler provides support for a particular lifestyle policy.
  @@ -59,31 +60,31 @@
    * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
    * @version $Revision$ $Date$
    */
  -public interface LifestyleHandler
  +public interface LifestyleHandler extends Reclaimable
   {
      /**
       * Activate of the appliance.
       * @return the implementation object
       */
  -    Object access() throws LifestyleException;
  +    //Object access() throws LifestyleException;
   
      /**
       * Activate a service provided by the appliance.
       * @param appliance the appliance to deploy
       */
  -    Object access( DependencyDescriptor dependency ) throws LifestyleException;
  +    //Object access( DependencyDescriptor dependency ) throws LifestyleException;
   
      /**
       * Activate an extension handler provided by the appliance.
       * @param appliance the appliance to deploy
       */
  -    Object access( StageDescriptor stage ) throws LifestyleException;
  +    //Object access( StageDescriptor stage ) throws LifestyleException;
   
      /**
       * Release an a service or handler established by the appliance.
       * @param object the service to be released
       */
  -    void release( Object object );
  +    //void release( Object object );
   
      /**
       * Terminate the handler.
  
  
  
  1.7       +13 -11    avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/PooledLifestyleHandler.java
  
  Index: PooledLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/PooledLifestyleHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PooledLifestyleHandler.java	9 Jan 2003 15:08:10 -0000	1.6
  +++ PooledLifestyleHandler.java	15 Jan 2003 09:09:25 -0000	1.7
  @@ -72,6 +72,7 @@
   import org.apache.excalibur.mpool.ObjectFactory;
   import org.apache.avalon.assembly.locator.Contextualizable;
   import org.apache.avalon.assembly.locator.Locator;
  +import org.apache.avalon.assembly.locator.LocatorException;
   
   /**
    * Lifestyle implementation that provides suppport for the pooled
  @@ -184,7 +185,8 @@
       * Activate a service provided by the appliance.
       * @param appliance the appliance to deploy
       */
  -    public Object access( DependencyDescriptor dependency ) throws LifestyleException
  +    //public Object access( DependencyDescriptor dependency ) throws LifestyleException
  +    public Object resolve( Object partition ) throws LocatorException
       {
           return access();
       }
  @@ -193,10 +195,10 @@
       * Activate an extension handler provided by the appliance.
       * @param appliance the appliance to deploy
       */
  -    public Object access( StageDescriptor stage ) throws LifestyleException
  -    {
  -        return access();
  -    }
  +    //public Object access( StageDescriptor stage ) throws LifestyleException
  +    //{
  +    //    return access();
  +    //}
   
       /**
        * Returns an instance of the object type supported by the
  @@ -206,7 +208,7 @@
        * @return an instance of the type defined by the profile
        * @exception Exception if an error occurs while aquiring the object
        */
  -    public Object access() throws LifestyleException
  +    private Object access() throws LocatorException
       {
           try
           {
  @@ -217,9 +219,8 @@
           catch( Throwable e )
           {
               final String error = 
  -              "Internal pool error occured while aquiring an object under appliance: " 
  -              + m_appliance;
  -            throw new LifestyleException( error, e );
  +              "Pooled object creation error.";
  +            throw new LocatorException( error, e );
           }
       }
   
  @@ -227,7 +228,8 @@
       * Release an a service or handler established by the appliance.
       * @param object the service to be released
       */
  -    public void release( Object object )
  +    //public void release( Object object )
  +    public void release( Object object, Object partition )
       {
           if( object == null )
           {
  
  
  
  1.10      +25 -12    avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/SingletonLifestyleHandler.java
  
  Index: SingletonLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/SingletonLifestyleHandler.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SingletonLifestyleHandler.java	9 Jan 2003 15:08:10 -0000	1.9
  +++ SingletonLifestyleHandler.java	15 Jan 2003 09:09:25 -0000	1.10
  @@ -60,6 +60,7 @@
   import org.apache.avalon.assembly.appliance.Appliance;
   import org.apache.avalon.assembly.locator.Contextualizable;
   import org.apache.avalon.assembly.locator.Locator;
  +import org.apache.avalon.assembly.locator.LocatorException;
   
   /**
    * The singleton lifestyle handler provides support for object instantiation and 
  @@ -87,7 +88,8 @@
       * Activate a service provided by the appliance.
       * @param appliance the appliance to deploy
       */
  -    public Object access( DependencyDescriptor dependency ) throws LifestyleException
  +    //public Object access( DependencyDescriptor dependency ) throws LifestyleException
  +    public Object resolve( Object partition ) throws LocatorException
       {
           return access();
       }
  @@ -96,16 +98,16 @@
       * Activate an extension handler provided by the appliance.
       * @param appliance the appliance to deploy
       */
  -    public Object access( StageDescriptor stage ) throws LifestyleException
  -    {
  -        return access();
  -    }
  +    //public Object access( StageDescriptor stage ) throws LifestyleException
  +    //{
  +    //    return access();
  +    //}
   
      /**
       * Activate the implementation.
       * @param appliance the appliance to deploy
       */
  -    public Object access() throws LifestyleException
  +    private Object access() throws LocatorException
       {
           if( getLogger().isDebugEnabled() )
           {
  @@ -113,17 +115,28 @@
                 "access in appliance: " + getAppliance();
               getLogger().debug( debug );
           }
  -        Object object = newInstance();
  -        super.processAccessStage( object );
  -        return object;
  +
  +        try
  +        {
  +            Object object = newInstance();
  +            super.processAccessStage( object );
  +            return object;
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Singleton object access failure.";
  +            throw new LocatorException( error, e );
  +        }
       }
   
      /**
       * Release an a service or handler established by the appliance.
       * @param object the service to be released
       */
  -    public void release( Object object )
  +    //public void release( Object object )
  +    public void release( Object object, Object partition )
       {
  +        // default does nothing
       }
   
       //==============================================================
  @@ -137,7 +150,7 @@
       {
           if( m_instance != null )
           {
  -            super.release( m_instance );
  +            super.release( m_instance, this );
               m_instance = null;
           }
           super.dispose();
  
  
  
  1.7       +23 -12    avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/ThreadLocalLifestyleHandler.java
  
  Index: ThreadLocalLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/ThreadLocalLifestyleHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ThreadLocalLifestyleHandler.java	21 Dec 2002 03:28:38 -0000	1.6
  +++ ThreadLocalLifestyleHandler.java	15 Jan 2003 09:09:25 -0000	1.7
  @@ -59,6 +59,7 @@
   import org.apache.avalon.meta.model.Profile;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
  +import org.apache.avalon.assembly.locator.LocatorException;
   
   /**
    * Lifestyle implementation that provides suppport for the per thread
  @@ -74,7 +75,8 @@
       * Activate a service provided by the appliance.
       * @param appliance the appliance to deploy
       */
  -    public Object access( DependencyDescriptor dependency ) throws LifestyleException
  +    //public Object access( DependencyDescriptor dependency ) throws LifestyleException
  +    public Object resolve( Object partition ) throws LocatorException
       {
           return access();
       }
  @@ -83,10 +85,10 @@
       * Activate an extension handler provided by the appliance.
       * @param appliance the appliance to deploy
       */
  -    public Object access( StageDescriptor stage ) throws LifestyleException
  -    {
  -        return access();
  -    }
  +    //public Object access( StageDescriptor stage ) throws LifestyleException
  +    //{
  +    //    return access();
  +    //}
   
       /**
        * Returns an instance of the object type supported by the
  @@ -95,7 +97,7 @@
        * @return an instance of the type defined by the appliance
        * @exception Exception if an access phase error occurs
        */
  -    public Object access() throws LifestyleException
  +    public Object access() throws LocatorException
       {
           if( getLogger().isDebugEnabled() )
           {        
  @@ -109,16 +111,25 @@
               m_instance = new ThreadLocalComponent( this );
           }
   
  -        Object object = m_instance.get();
  -        super.processAccessStage( object );
  -        return object;
  +        try
  +        {
  +            Object object = m_instance.get();
  +            super.processAccessStage( object );
  +            return object;
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Access stage error.";
  +            throw new LocatorException( error, e );
  +        }
       }
   
      /**
       * Release an a service or handler established by the appliance.
       * @param object the service to be released
       */
  -    public void release( Object object )
  +    //public void release( Object object )
  +    public void release( Object object, Object partition )
       {
           if( object == null )
           {
  @@ -132,7 +143,7 @@
       }
   
      /**
  -    * Internal utility class to hold the thread local instance .
  +    * Internal utility class to hold the thread local instance.
       */
       private static final class ThreadLocalComponent extends ThreadLocal
       {
  @@ -160,7 +171,7 @@
       {
           if( m_instance != null )
           {
  -            super.release( m_instance.get() );
  +            super.release( m_instance.get(), this );
               m_instance = null;
           }
       }
  
  
  
  1.8       +26 -14    avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/TransientLifestyleHandler.java
  
  Index: TransientLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/TransientLifestyleHandler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TransientLifestyleHandler.java	9 Jan 2003 15:08:10 -0000	1.7
  +++ TransientLifestyleHandler.java	15 Jan 2003 09:09:25 -0000	1.8
  @@ -62,6 +62,7 @@
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.assembly.appliance.Appliance;
  +import org.apache.avalon.assembly.locator.LocatorException;
   
   /**
    * The abstract lifestyle handler provides support for object instantiation and 
  @@ -89,7 +90,8 @@
       * Activate a service provided by the appliance.
       * @param appliance the appliance to deploy
       */
  -    public Object access( DependencyDescriptor dependency ) throws LifestyleException
  +    //public Object access( DependencyDescriptor dependency ) throws LifestyleException
  +    public Object resolve( Object partition ) throws LocatorException
       {
           return access();
       }
  @@ -98,31 +100,41 @@
       * Activate an extension handler provided by the appliance.
       * @param appliance the appliance to deploy
       */
  -    public Object access( StageDescriptor stage ) throws LifestyleException
  -    {
  -        return access();
  -    }
  +    //public Object access( StageDescriptor stage ) throws LifestyleException
  +    //{
  +    //    return access();
  +    //}
   
      /**
       * Activate the implementation.
       * @param appliance the appliance to deploy
       */
  -    public Object access() throws LifestyleException
  +    private Object access() throws LocatorException
       {
  -        Object object = newInstance();
  -        synchronized( m_instances )
  +        try
  +        {
  +            Object object = newInstance();
  +            synchronized( m_instances )
  +            {
  +                m_instances.add( object );
  +            } 
  +            super.processAccessStage( object );
  +            return object;
  +        }
  +        catch( Throwable e )
           {
  -            m_instances.add( object );
  +            final String error =
  +              "Transient object establishment error.";
  +            throw new LocatorException( error, e );
           }
  -        super.processAccessStage( object );
  -        return object;
       }
   
      /**
       * Release an a service or handler established by the appliance.
       * @param object the service to be released
       */
  -    public void release( Object object )
  +    //public void release( Object object )
  +    public void release( Object object, Object partition )
       {
           processReleaseStage( object );
           m_deployment.decommission( getAppliance(), object, false );
  @@ -146,7 +158,7 @@
               Iterator iterator = m_instances.iterator();
               while( iterator.hasNext() )
               {
  -                release( iterator.next() );
  +                release( iterator.next(), null );
               }
           }
           super.dispose();
  
  
  
  1.4       +0 -1      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/locator/DefaultLocator.java
  
  Index: DefaultLocator.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/locator/DefaultLocator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultLocator.java	9 Jan 2003 11:25:26 -0000	1.3
  +++ DefaultLocator.java	15 Jan 2003 09:09:26 -0000	1.4
  @@ -257,7 +257,6 @@
       {
   
           final Object data = getObject( m_dictionary.translate( key ) );
  -
           if( data instanceof Reclaimable )
           {
               Object object = ( (Resolvable)data ).resolve( this );
  
  
  
  1.3       +2 -2      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/locator/Reclaimable.java
  
  Index: Reclaimable.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/locator/Reclaimable.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Reclaimable.java	9 Jan 2003 15:08:11 -0000	1.2
  +++ Reclaimable.java	15 Jan 2003 09:09:26 -0000	1.3
  @@ -67,7 +67,7 @@
        * Release an object
        *
        * @param the object to be reclaimed
  -     * @param context the context with respect which to reclain the object
  +     * @param partition the context with respect the reclaimed object is qualified
        */
  -    void release( Object object, Locator context );
  +    void release( Object object, Object partition );
   }
  
  
  
  1.3       +3 -3      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/locator/Resolvable.java
  
  Index: Resolvable.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/locator/Resolvable.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Resolvable.java	9 Jan 2003 15:08:11 -0000	1.2
  +++ Resolvable.java	15 Jan 2003 09:09:26 -0000	1.3
  @@ -68,10 +68,10 @@
       /**
        * Resolve a object to a value.
        *
  -     * @param context the context within the the resolution is applied
  +     * @param partition the context within the the resolution is applied
        * @return the resolved object
        * @throws ContextException if an error occurs
        */
  -    Object resolve( Locator locator )
  -        throws ContextException;
  +    Object resolve( Object partition )
  +        throws LocatorException;
   }
  
  
  
  1.3       +12 -1     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/util/ExceptionHelper.java
  
  Index: ExceptionHelper.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/util/ExceptionHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExceptionHelper.java	17 Dec 2002 04:59:08 -0000	1.2
  +++ ExceptionHelper.java	15 Jan 2003 09:09:26 -0000	1.3
  @@ -150,6 +150,17 @@
        */
       public static String packException( final String message, final Throwable e )
       {
  +        return packException( message, e, true );
  +    }
  +
  +    /**
  +     * Returns the exception and causal exceptions as a formatted string.
  +     * @param message the header message
  +     * @param e the exception
  +     * @return String the formatting string
  +     */
  +    public static String packException( final String message, final Throwable e, boolean stack )
  +    {
           StringBuffer buffer = new StringBuffer();
           buffer.append( "Message: " + message );
           buffer.append( "\n===================================================================" );
  @@ -165,7 +176,7 @@
               buffer.append( "\n\n===================================================================" );
           }
           Throwable root = getLastThrowable( e );
  -        if( root != null )
  +        if(( root != null ) && stack )
           {
               String[] trace = captureStackTrace( root );
               for( int i = 0; i < trace.length; i++ )
  
  
  
  1.7       +14 -10    avalon-sandbox/assembly/src/test/config/block.xml
  
  Index: block.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/test/config/block.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- block.xml	27 Dec 2002 16:28:22 -0000	1.6
  +++ block.xml	15 Jan 2003 09:09:26 -0000	1.7
  @@ -1,27 +1,31 @@
   
   <!--
  -Merlin default kernel configuration.
  +Example block deployment descriptor.
   -->
   
   <block>
   
      <implementation>
   
  -     <appliance name="complex" class="org.apache.avalon.playground.ComplexComponent" activation="startup">
  -        <context>
  -          <entry key="location" value="Paris"/>
  -        </context>
  -        <configuration>
  -          <message value="Hello"/>
  -        </configuration>
  -     </appliance>
  -
        <appliance name="basic" class="org.apache.avalon.playground.basic.BasicComponent" activation="startup">
          <context class="org.apache.avalon.playground.basic.BasicContextImp">
            <entry key="location">My Place</entry>
            <import name="urn:avalon:home" key="home" />
          </context>
        </appliance>
  +
  +     <container name="subsidiary">
  +
  +       <appliance name="complex" class="org.apache.avalon.playground.ComplexComponent" activation="startup">
  +         <context>
  +           <entry key="location" value="Paris"/>
  +         </context>
  +         <configuration>
  +           <message value="Hello in complex"/>
  +         </configuration>
  +       </appliance>
  +
  +     </container>
   
      </implementation>
   
  
  
  
  1.13      +11 -8     avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/engine/EngineTestCase.java
  
  Index: EngineTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/engine/EngineTestCase.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- EngineTestCase.java	9 Jan 2003 15:08:11 -0000	1.12
  +++ EngineTestCase.java	15 Jan 2003 09:09:26 -0000	1.13
  @@ -21,6 +21,7 @@
   import org.apache.avalon.assembly.appliance.Appliance;
   import org.apache.avalon.assembly.appliance.ApplianceContext;
   import org.apache.avalon.assembly.appliance.DefaultApplianceContext;
  +import org.apache.avalon.assembly.appliance.DependencyGraph;
   import org.apache.avalon.assembly.util.ExceptionHelper;
   
   /**
  @@ -33,6 +34,8 @@
   
       protected EngineClassLoader m_engine;
   
  +    protected DependencyGraph graph = new DependencyGraph();
  +
       public EngineTestCase()
       {
           this( "EngineTestCase" );
  @@ -88,7 +91,7 @@
             
           try
           {
  -            appliance = m_engine.resolve( dependency );
  +            appliance = m_engine.resolve( graph, dependency );
               assertTrue( appliance != null );
           }
           catch( Throwable e )
  @@ -104,7 +107,7 @@
   
           try
           {
  -            Object object = appliance.access( dependency );
  +            Object object = appliance.resolve( this );
               assertTrue( true );
           }
           catch( Throwable e )
  @@ -134,7 +137,7 @@
           try
           {
               getLogger().info( "resolving: " + dependency );
  -            appliance = m_engine.resolve( dependency );
  +            appliance = m_engine.resolve( graph, dependency );
               assertTrue( appliance != null );
           }
           catch( Throwable e )
  @@ -148,7 +151,7 @@
           try
           {
               getLogger().info( "accessing: " + dependency );
  -            Object object = appliance.access( dependency );
  +            Object object = appliance.resolve( this );
               assertTrue( true );
           }
           catch( Throwable e )
  @@ -174,7 +177,7 @@
           try
           {
               getLogger().info( "resolving: " + dependency );
  -            appliance = m_engine.resolve( dependency );
  +            appliance = m_engine.resolve( graph, dependency );
               assertTrue( appliance != null );
           }
           catch( Throwable e )
  @@ -188,7 +191,7 @@
           try
           {
               getLogger().info( "accesing: " + dependency );
  -            Object object = appliance.access( dependency );
  +            Object object = appliance.resolve( this );
               assertTrue( true );
           }
           catch( Throwable e )
  @@ -211,8 +214,8 @@
               DefaultApplianceContext context = new DefaultApplianceContext( profile );
               context.makeReadOnly();
               Appliance appliance = m_engine.createAppliance( context, false );
  -            appliance.assemble();
  -            assertTrue( appliance.access() != null );
  +            appliance.assemble( graph );
  +            assertTrue( appliance.resolve( this ) != null );
           }
           catch( Throwable e )
           {
  
  
  

--
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