avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon/merlin/composition/impl/src/test/org/apache/avalon/composition/model/test AssemblyTestCase.java
Date Tue, 06 Jan 2004 23:16:50 GMT
mcconnell    2004/01/06 15:16:50

  Modified:    merlin/composition/api/src/java/org/apache/avalon/composition/model
                        Tag: Ver_3_4 ComponentContext.java
                        ContainmentContext.java ContainmentModel.java
                        DependencyGraph.java ModelRepository.java
                        SystemContext.java
               merlin/composition/impl Tag: Ver_3_4 maven.xml
               merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl
                        Tag: Ver_3_4 DefaultComponentContext.java
                        DefaultComponentModel.java
                        DefaultContainmentContext.java
                        DefaultContainmentModel.java
                        DefaultDeploymentContext.java
                        DefaultDeploymentModel.java
                        DefaultModelRepository.java
                        DefaultSystemContext.java
                        DefaultTypeRepository.java Resources.properties
               merlin/composition/impl/src/test/conf Tag: Ver_3_4 block.xml
               merlin/composition/impl/src/test/org/apache/avalon/composition/model
                        Tag: Ver_3_4 AbstractTestCase.java
               merlin/composition/impl/src/test/org/apache/avalon/composition/model/test
                        Tag: Ver_3_4 AssemblyTestCase.java
  Log:
  Enhancing the dependency resolution model so that we can resolve consumers and providers relative to a particular deployment model.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.3   +24 -3     avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/Attic/ComponentContext.java
  
  Index: ComponentContext.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/Attic/ComponentContext.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ComponentContext.java	4 Jan 2004 20:19:27 -0000	1.1.2.2
  +++ ComponentContext.java	6 Jan 2004 23:16:49 -0000	1.1.2.3
  @@ -52,11 +52,15 @@
   
   import java.io.File;
   
  -import org.apache.avalon.meta.info.ContextDescriptor;
  +import org.apache.avalon.composition.data.DeploymentProfile;
  +
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.logger.Logger;
  +
  +import org.apache.avalon.meta.info.ContextDescriptor;
  +import org.apache.avalon.meta.info.DependencyDescriptor;
  +import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.meta.info.Type;
  -import org.apache.avalon.composition.data.DeploymentProfile;
   
   /**
    * Defintion of a component deployment context.
  @@ -146,6 +150,23 @@
       * @return the classloader
       */
       ClassLoader getClassLoader();
  +
  +   /**
  +    * Return a model relative to a supplied dependency.
  +    * @return a matching model or null if the dependency is unresolvable
  +    * @exception ModelRuntimeException if an error occurs during model establishment
  +    */
  +    //DeploymentModel getModel( DependencyDescriptor dependency ) 
  +    // throws ModelRuntimeException;
  +
  +   /**
  +    * Return a model relative to a supplied stage descriptor.
  +    * @param stage the stage descriptor
  +    * @return model of a an stage handler or null if the stage is unresolvable
  +    * @exception ModelRuntimeException if an error occurs during model establishment
  +    */
  +    //DeploymentModel getModel( StageDescriptor stage ) 
  +    //  throws ModelRuntimeException;
   
      /**
       * Add a context entry model to the deployment context.
  
  
  
  1.1.1.1.2.4 +14 -2     avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentContext.java
  
  Index: ContainmentContext.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentContext.java,v
  retrieving revision 1.1.1.1.2.3
  retrieving revision 1.1.1.1.2.4
  diff -u -r1.1.1.1.2.3 -r1.1.1.1.2.4
  --- ContainmentContext.java	4 Jan 2004 20:19:27 -0000	1.1.1.1.2.3
  +++ ContainmentContext.java	6 Jan 2004 23:16:49 -0000	1.1.1.1.2.4
  @@ -54,8 +54,12 @@
   
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.logger.Logger;
  +
   import org.apache.avalon.composition.data.ContainmentProfile;
   
  +import org.apache.avalon.meta.info.DependencyDescriptor;
  +import org.apache.avalon.meta.info.StageDescriptor;
  +
   /**
    * Defintion of a working context.
    *
  @@ -106,11 +110,19 @@
       */
       ClassLoader getClassLoader();
   
  -
      /**
       * Return the model repository.
       *
       * @return the model repository
       */
       ModelRepository getModelRepository();
  +
  +   /**
  +    * Return the parent container model. If the container is a root
  +    * container, the operation shall return a null value.
  +    *
  +    * @return the parent containment model
  +    */
  +    ContainmentModel getParentContainmentModel();
  +
   }
  
  
  
  1.9.2.6   +13 -5     avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentModel.java
  
  Index: ContainmentModel.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentModel.java,v
  retrieving revision 1.9.2.5
  retrieving revision 1.9.2.6
  diff -u -r1.9.2.5 -r1.9.2.6
  --- ContainmentModel.java	4 Jan 2004 21:28:59 -0000	1.9.2.5
  +++ ContainmentModel.java	6 Jan 2004 23:16:49 -0000	1.9.2.6
  @@ -99,6 +99,14 @@
       */
       String getPartition();
   
  +   /** 
  +    * Returns the maximum allowable time for deployment.
  +    *
  +    * @return the maximum time expressed in millisecond of how 
  +    * long a deployment may take.
  +    **/
  +   long getDeploymentTimeout();
  +
      /**
       * Return the classloader model.
       *
  @@ -123,8 +131,8 @@
       * @return a matching model or null if the dependency is unresolvable
       * @exception ModelRuntimeException if an error occurs during model establishment
       */
  -    DeploymentModel getModel( DependencyDescriptor dependency ) 
  -      throws ModelRuntimeException;
  +    //DeploymentModel getModel( DependencyDescriptor dependency ) 
  +    //  throws ModelRuntimeException;
   
      /**
       * Return a model relative to a supplied stage descriptor.
  @@ -132,8 +140,8 @@
       * @return model of a an stage handler or null if the stage is unresolvable
       * @exception ModelRuntimeException if an error occurs during model establishment
       */
  -    DeploymentModel getModel( StageDescriptor stage ) 
  -      throws ModelRuntimeException;
  +    //DeploymentModel getModel( StageDescriptor stage ) 
  +    //  throws ModelRuntimeException;
   
      /**
       * Addition of a new subsidiary model within
  
  
  
  1.1.2.4   +11 -10    avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/Attic/DependencyGraph.java
  
  Index: DependencyGraph.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/Attic/DependencyGraph.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- DependencyGraph.java	4 Jan 2004 21:28:59 -0000	1.1.2.3
  +++ DependencyGraph.java	6 Jan 2004 23:16:49 -0000	1.1.2.4
  @@ -201,9 +201,12 @@
        */
       public DeploymentModel[] getConsumerGraph( final DeploymentModel model )
       {
  +        if( m_parent != null ) return m_parent.getConsumerGraph( model );
  +
           try
           {
  -            return referencedModels( model, getComponentGraph( model, false ) );
  +            DeploymentModel[] graph = getComponentGraph( model, false );
  +            return referencedModels( model, graph );
           } 
           catch( Throwable e )
           {
  @@ -237,7 +240,8 @@
       /**
        * Return an model array that does not include the provided model.
        */
  -    private DeploymentModel[] referencedModels( final DeploymentModel model, DeploymentModel[] models )
  +    private DeploymentModel[] referencedModels( 
  +      final DeploymentModel model, DeploymentModel[] models )
       {
           ArrayList list = new ArrayList();
           for( int i = 0; i < models.length; i++ )
  @@ -257,7 +261,8 @@
        * @param providers true if traversing providers, false if consumers
        * @return the list of models 
        */
  -    private DeploymentModel[] getComponentGraph( final DeploymentModel model, final boolean providers )
  +    private DeploymentModel[] getComponentGraph( 
  +      final DeploymentModel model, final boolean providers )
       {
           final ArrayList result = new ArrayList();
           visitcomponent( model,
  @@ -274,7 +279,8 @@
        * It is expected that the specified components have passed
        * verification tests and are well formed.
        *
  -     * @param direction true if forward dependencys traced, false if dependencies reversed
  +     * @param direction true if forward dependencys traced, false if 
  +     *   dependencies reversed
        * @return the ordered model list
        */
       private DeploymentModel[] walkGraph( final boolean direction )
  @@ -312,7 +318,6 @@
               final ArrayList done,
               final ArrayList order )
       {
  -
           //If already visited this model return
   
           if( done.contains( model ) ) return;
  @@ -358,15 +363,11 @@
               final ArrayList done,
               final ArrayList order )
       {
  -
  -        final String name = model.getName();
  -
           final int size = m_models.size();
           for( int i = 0; i < size; i++ )
           {
               final DeploymentModel other =
                       (DeploymentModel) m_models.get( i );
  -
               final DeploymentModel[] providers = other.getProviders();
               for( int j = 0; j < providers.length; j++ )
               {
  
  
  
  1.1.2.3   +18 -1     avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/Attic/ModelRepository.java
  
  Index: ModelRepository.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/Attic/ModelRepository.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ModelRepository.java	4 Jan 2004 21:28:59 -0000	1.1.2.2
  +++ ModelRepository.java	6 Jan 2004 23:16:49 -0000	1.1.2.3
  @@ -80,6 +80,23 @@
       DeploymentModel getModel( DependencyDescriptor dependency );
   
       /**
  +     * Locate all models meeting the supplied dependency criteria.
  +     *
  +     * @param dependency a component service dependency
  +     * @return the candidate models
  +     */
  +    DeploymentModel[] getCandidateProviders( 
  +      DependencyDescriptor dependency );
  +
  +    /**
  +     * Locate all models meeting the supplied criteria.
  +     *
  +     * @param stage a component stage dependency
  +     * @return the candidate models
  +     */
  +    DeploymentModel[] getCandidateProviders( StageDescriptor stage );
  +
  +    /**
        * Locate a model meeting the supplied criteria.
        *
        * @param stage a component stage dependency
  
  
  
  1.1.1.1.2.1 +9 -2      avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/SystemContext.java
  
  Index: SystemContext.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/SystemContext.java,v
  retrieving revision 1.1.1.1
  retrieving revision 1.1.1.1.2.1
  diff -u -r1.1.1.1 -r1.1.1.1.2.1
  --- SystemContext.java	24 Sep 2003 09:31:22 -0000	1.1.1.1
  +++ SystemContext.java	6 Jan 2004 23:16:49 -0000	1.1.1.1.2.1
  @@ -57,7 +57,7 @@
   import org.apache.avalon.repository.Repository;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.logger.Logger;
  -
  +import org.apache.avalon.framework.parameters.Parameters;
   
   /**
    * Defintion of a system context that exposes a system wide set of parameters.
  @@ -141,4 +141,11 @@
       */
       Logger getLogger();
   
  +    /** 
  +     * Returns the configurable kernel parameters.
  +     *
  +     * @return a Parameters object populated with the system
  +     * parameters.
  +     */
  +    Parameters getSystemParameters();
   }
  
  
  
  No                   revision
  No                   revision
  1.1.1.1.2.3 +2 -0      avalon/merlin/composition/impl/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/maven.xml,v
  retrieving revision 1.1.1.1.2.2
  retrieving revision 1.1.1.1.2.3
  diff -u -r1.1.1.1.2.2 -r1.1.1.1.2.3
  --- maven.xml	3 Jan 2004 23:18:55 -0000	1.1.1.1.2.2
  +++ maven.xml	6 Jan 2004 23:16:49 -0000	1.1.1.1.2.3
  @@ -7,6 +7,8 @@
   
     <postGoal name="test:compile">
   
  +    <!--<attainGoal name="avalon:meta"/>-->
  +
       <mkdir dir="${basedir}/target/test-classes/repository/test/jars"/>
       <mkdir dir="${basedir}/target/test-classes/ext"/>
       <mkdir dir="${basedir}/target/test-classes/lib"/>
  
  
  
  No                   revision
  No                   revision
  1.1.2.3   +45 -6     avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultComponentContext.java
  
  Index: DefaultComponentContext.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultComponentContext.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- DefaultComponentContext.java	4 Jan 2004 20:19:27 -0000	1.1.2.2
  +++ DefaultComponentContext.java	6 Jan 2004 23:16:49 -0000	1.1.2.3
  @@ -54,19 +54,27 @@
   import java.util.Map;
   import java.util.Hashtable;
   
  -import org.apache.avalon.composition.model.SystemContext;
  -import org.apache.avalon.composition.model.EntryModel;
  +import org.apache.avalon.composition.model.ContainmentModel;
   import org.apache.avalon.composition.model.ContainmentContext;
   import org.apache.avalon.composition.model.ComponentContext;
  +import org.apache.avalon.composition.model.DeploymentModel;
  +import org.apache.avalon.composition.model.EntryModel;
   import org.apache.avalon.composition.model.ModelRuntimeException;
  -import org.apache.avalon.framework.context.DefaultContext;
  +import org.apache.avalon.composition.model.SystemContext;
  +
  +import org.apache.avalon.composition.data.DeploymentProfile;
  +
   import org.apache.avalon.framework.context.ContextException;
  +import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.avalon.framework.logger.Logger;
  +
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.avalon.composition.data.DeploymentProfile;
  +
   import org.apache.avalon.meta.info.Type;
   import org.apache.avalon.meta.info.EntryDescriptor;
  +import org.apache.avalon.meta.info.DependencyDescriptor;
  +import org.apache.avalon.meta.info.StageDescriptor;
   
   
   /**
  @@ -103,6 +111,8 @@
   
       private final File m_temp;
   
  +    private final ContainmentModel m_model;
  +
      /**
       * Map containing context entry models 
       * keyed by entry key.
  @@ -129,7 +139,8 @@
       */
       public DefaultComponentContext( 
         Logger logger, String name, ContainmentContext context, 
  -      DeploymentProfile profile, Type type, Class clazz, 
  +      ContainmentModel model, DeploymentProfile profile, 
  +      Type type, Class clazz, 
         File home, File temp, String partition )
       {
           super( 
  @@ -156,6 +167,10 @@
           {
               throw new NullPointerException( "profile" );
           }
  +        if( model == null )
  +        {
  +            throw new NullPointerException( "model" );
  +        }
   
           if( home.exists() && !home.isDirectory() )
           {
  @@ -176,6 +191,7 @@
           m_type = type;
           m_profile = profile;
           m_class = clazz;
  +        m_model = model;
       }
   
       //==============================================================
  @@ -201,6 +217,29 @@
       {
           return m_context;
       }
  +
  +   /**
  +    * Return a model relative to a supplied dependency.
  +    * @return a matching model or null if the dependency is unresolvable
  +    * @exception ModelRuntimeException if an error occurs during model establishment
  +    */
  +    //public DeploymentModel getModel( DependencyDescriptor dependency ) 
  +    //  throws ModelRuntimeException
  +    //{
  +    //    return m_model.getModel( dependency );
  +    //}
  +
  +   /**
  +    * Return a model relative to a supplied stage descriptor.
  +    * @param stage the stage descriptor
  +    * @return model of a an stage handler or null if the stage is unresolvable
  +    * @exception ModelRuntimeException if an error occurs during model establishment
  +    */
  +    //public DeploymentModel getModel( StageDescriptor stage ) 
  +    //  throws ModelRuntimeException
  +    //{
  +    //    return m_model.getModel( stage );
  +    //}
   
      /**
       * Return the working directory.
  
  
  
  1.1.2.5   +44 -177   avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultComponentModel.java
  
  Index: DefaultComponentModel.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultComponentModel.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- DefaultComponentModel.java	4 Jan 2004 21:28:59 -0000	1.1.2.4
  +++ DefaultComponentModel.java	6 Jan 2004 23:16:49 -0000	1.1.2.5
  @@ -67,22 +67,26 @@
   import org.apache.avalon.composition.data.DependencyDirective;
   import org.apache.avalon.composition.data.StageDirective;
   import org.apache.avalon.composition.data.CategoriesDirective;
  +import org.apache.avalon.composition.data.ContextDirective;
  +import org.apache.avalon.composition.data.Mode;
  +
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  +
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.framework.logger.Logger;
  -import org.apache.avalon.composition.data.ContextDirective;
  -import org.apache.avalon.composition.data.Mode;
  +
   import org.apache.avalon.meta.info.ContextDescriptor;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.InfoDescriptor;
   import org.apache.avalon.meta.info.ServiceDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.meta.info.Type;
  +
   import org.apache.excalibur.configuration.CascadingConfiguration;
   
   /**
  @@ -263,7 +267,40 @@
        */
       public boolean isAssembled()
       {
  -        return m_assembly.isEnabled();
  +        //return m_assembly.isEnabled();
  +        return ( isContextAssembled() 
  +          && isStageAssembled()
  +          && isServiceAssembled() );
  +    }
  +
  +    private boolean isContextAssembled()
  +    {
  +        if( null == getContextModel() ) return true;
  +        Class clazz = getContextModel().getStrategyClass();
  +        if( clazz.getName().equals( 
  +          ContextModel.DEFAULT_STRATEGY_CLASSNAME ) )
  +            return true;
  +        return ( null != getContextModel().getProvider() );
  +    }
  +
  +    private boolean isStageAssembled()
  +    {
  +        StageModel[] stages = getStageModels();
  +        for( int i=0; i<stages.length; i++ )
  +        {
  +            if( null == stages[i].getProvider() ) return false;
  +        }
  +        return true;
  +    }
  +
  +    private boolean isServiceAssembled()
  +    {
  +        DependencyModel[] dependencies = getDependencyModels();
  +        for( int i=0; i<dependencies.length; i++ )
  +        {
  +            if( null == dependencies[i].getProvider() ) return false;
  +        }
  +        return true;
       }
   
       /**
  @@ -272,143 +309,7 @@
        */
       public void assemble() throws AssemblyException
       {
  -        synchronized( m_assembly )
  -        {
  -            if( isAssembled() )
  -            {
  -                return;
  -            }
  -
  -            if( getLogger().isDebugEnabled() )
  -            {
  -                getLogger().debug( "assembly phase" );
  -            }
  -
  -            ModelRepository repository = 
  -              m_context.getContainmentContext().getModelRepository();
  -
  -            //
  -            // check if we need a contextualization handler
  -            //
  -
  -            if( getContextModel() != null )
  -            {
  -                Class clazz = getContextModel().getStrategyClass();
  -                if( !clazz.getName().equals( ContextModel.DEFAULT_STRATEGY_CLASSNAME ) )
  -                {
  -                    //
  -                    // we need to load a deployment phase context strategy handler
  -                    // using the strategy interface as the extension handler key
  -                    //
  -
  -                    StageDescriptor stage = 
  -                      new StageDescriptor( clazz.getName() );
  -                    DeploymentModel provider = repository.getModel( stage );
  -                    if( null == provider )
  -                    {
  -                        final String error = 
  -                          REZ.getString( 
  -                            "assembly.context.error",
  -                            getQualifiedName(), 
  -                            clazz.getName() );
  -                        throw new AssemblyException( error );
  -                    }
  -                    else
  -                    {
  -                        getContextModel().setProvider( provider );
  -                    }
  -
  -                    /*
  -                    #
  -                    # TO DO = verify that the stage is a context handler
  -                    #
  -
  -                    Class handler = m_contextProvider.getDeploymentClass();
  -
  -                    if( !ContextualizationHandler.class.isAssignableFrom( handler ) )
  -                    {
  -                        final String error = 
  -                          REZ.getString( 
  -                            "assembly.context-strategy.bad-class.error",
  -                            handler.getName() );
  -                        throw new AssemblyException( error );
  -                    }
  -                    */
  -
  -                    if( getLogger().isDebugEnabled() )
  -                    {
  -                        getLogger().debug( 
  -                          "assigning context provider: " + provider );
  -                    }
  -                }
  -            }
  -
  -            //
  -            // get the dependency models for the type and resolve providers
  -            //
  -
  -            DependencyModel[] dependencies = getDependencyModels();
  -            for( int i=0; i<dependencies.length; i++ )
  -            {
  -                DependencyModel dependency = dependencies[i];
  -                final String key = dependency.getDependency().getKey();
  -                final DeploymentModel model = 
  -                  repository.getModel( dependency.getDependency() );
  -                if( null == model )
  -                {
  -                    final String error = 
  -                      REZ.getString( 
  -                        "assembly.dependency.error",
  -                        getQualifiedName(), key );
  -                    throw new AssemblyException( error );
  -                }
  -                else
  -                {
  -                    dependency.setProvider( model );
  -                    if( getLogger().isDebugEnabled() )
  -                    {
  -                        getLogger().debug( 
  -                          "assigning service provider for key (" 
  -                          + key + "): " 
  -                          + model );
  -                    }
  -                }
  -            }
  -
  -            //
  -            // get the stage models for the type and resolve providers
  -            //
  -
  -            StageModel[] stages = getStageModels();
  -            for( int i=0; i<stages.length; i++ )
  -            {
  -                StageModel stage = stages[i];
  -                final String key = stage.getStage().getKey();
  -                final DeploymentModel model = 
  -                  repository.getModel( stage.getStage() );
  -                if( null == model )
  -                {
  -                    final String error = 
  -                      REZ.getString( 
  -                        "assembly.stage.error",
  -                        getQualifiedName(), key );
  -                    throw new AssemblyException( error );
  -                }
  -                else
  -                {
  -                    stage.setProvider( model );
  -                    if( getLogger().isDebugEnabled() )
  -                    {
  -                        getLogger().debug( 
  -                          "assigning stage provider (" 
  -                          + key + "): " 
  -                          + model );
  -                    }
  -                }
  -            }
  -
  -            m_assembly.setEnabled( true );
  -        }
  +        return;
       }
   
       /**
  @@ -416,36 +317,6 @@
        */
       public void disassemble()
       {
  -        synchronized( m_assembly )
  -        {
  -            if( !isAssembled() )
  -            {
  -                return;
  -            }
  -
  -            getLogger().debug( "dissassembly phase" );
  -
  -            StageModel[] stages = getStageModels();
  -            for( int i=0; i<stages.length; i++ )
  -            {
  -                StageModel stage = stages[i];
  -                stage.clearProvider();
  -            }
  -
  -            DependencyModel[] dependencies = getDependencyModels();
  -            for( int i=0; i<dependencies.length; i++ )
  -            {
  -                DependencyModel dependency = dependencies[i];
  -                dependency.clearProvider();
  -            }
  -
  -            if( null != getContextModel() )
  -            {
  -                getContextModel().clearProvider();
  -            }
  -
  -            m_assembly.setEnabled( false );
  -        }
       }
   
       /**
  @@ -589,7 +460,8 @@
               {
                   final String warning = 
                     "Ignoring collection policy override [" + policy 
  -                  + "] because the value is higher that type threshhold [" + minimum + "].";
  +                  + "] because the value is higher that type threshhold [" 
  +                  + minimum + "].";
                   getLogger().warn( warning );
               }
           }
  @@ -1031,10 +903,5 @@
                   return new CascadingConfiguration( primary, defaults );
               }
           }
  -    }
  -
  -    public String toString()
  -    {
  -        return "[deployment model : " + getQualifiedName() + "]";
       }
   }
  
  
  
  1.2.2.4   +35 -9     avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentContext.java
  
  Index: DefaultContainmentContext.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentContext.java,v
  retrieving revision 1.2.2.3
  retrieving revision 1.2.2.4
  diff -u -r1.2.2.3 -r1.2.2.4
  --- DefaultContainmentContext.java	4 Jan 2004 20:19:27 -0000	1.2.2.3
  +++ DefaultContainmentContext.java	6 Jan 2004 23:16:49 -0000	1.2.2.4
  @@ -55,13 +55,22 @@
   import org.apache.avalon.composition.model.DependencyGraph;
   import org.apache.avalon.composition.model.SystemContext;
   import org.apache.avalon.composition.model.ContainmentContext;
  +import org.apache.avalon.composition.model.ContainmentModel;
   import org.apache.avalon.composition.model.ClassLoaderModel;
   import org.apache.avalon.composition.model.ModelRepository;
  +import org.apache.avalon.composition.model.ModelRuntimeException;
  +import org.apache.avalon.composition.model.DeploymentModel;
  +
  +import org.apache.avalon.composition.data.ContainmentProfile;
  +
   import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.avalon.framework.logger.Logger;
  +
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.avalon.composition.data.ContainmentProfile;
  +
  +import org.apache.avalon.meta.info.DependencyDescriptor;
  +import org.apache.avalon.meta.info.StageDescriptor;
   
   
   /**
  @@ -88,7 +97,7 @@
   
       private final File m_temp;
   
  -    private final ClassLoaderModel m_model;
  +    private final ClassLoaderModel m_classloader;
   
       private final ContainmentProfile m_profile;
   
  @@ -96,6 +105,8 @@
   
       private final ModelRepository m_repository;
   
  +    private final ContainmentModel m_parent;
  +
       //---------------------------------------------------------
       // constructor
       //---------------------------------------------------------
  @@ -112,11 +123,12 @@
       */
       public DefaultContainmentContext( 
         Logger logger, SystemContext system, ClassLoaderModel model, 
  -      ModelRepository repository, DependencyGraph graph, ContainmentProfile profile )
  +      ModelRepository repository, DependencyGraph graph, 
  +      ContainmentProfile profile )
       {
           this( logger, system, model, repository, graph,
             system.getHomeDirectory(), system.getTempDirectory(), 
  -          profile, null, "" );
  +          null, profile, null, "" );
       }
   
      /**
  @@ -137,7 +149,8 @@
       public DefaultContainmentContext( 
         Logger logger, SystemContext system, ClassLoaderModel model, 
         ModelRepository repository, DependencyGraph graph, 
  -      File home, File temp, ContainmentProfile profile, String partition, String name )
  +      File home, File temp, ContainmentModel parent, 
  +      ContainmentProfile profile, String partition, String name )
       {
           super( logger, partition, name, profile.getMode(), graph );
   
  @@ -180,9 +193,10 @@
           m_repository = new DefaultModelRepository( repository, logger );
   
           m_system = system;
  -        m_model = model;
  +        m_classloader = model;
           m_home = home;
           m_temp = temp;
  +        m_parent = parent;
           m_profile = profile;
       }
   
  @@ -249,7 +263,7 @@
       */
       public ClassLoaderModel getClassLoaderModel()
       {
  -        return m_model;
  +        return m_classloader;
       }
   
      /**
  @@ -261,6 +275,18 @@
       */
       public ClassLoader getClassLoader()
       {
  -        return m_model.getClassLoader();
  +        return m_classloader.getClassLoader();
       }
  +
  +   /**
  +    * Return the parent containment model.
  +    *
  +    * @return the model parent container
  +    */
  +    public ContainmentModel getParentContainmentModel()
  +    {
  +        return m_parent;
  +    }
  +
  +
   }
  
  
  
  1.13.2.10 +474 -54   avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java
  
  Index: DefaultContainmentModel.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java,v
  retrieving revision 1.13.2.9
  retrieving revision 1.13.2.10
  diff -u -r1.13.2.9 -r1.13.2.10
  --- DefaultContainmentModel.java	4 Jan 2004 21:28:59 -0000	1.13.2.9
  +++ DefaultContainmentModel.java	6 Jan 2004 23:16:49 -0000	1.13.2.10
  @@ -82,6 +82,8 @@
   import org.apache.avalon.composition.model.ClassLoaderModel;
   import org.apache.avalon.composition.model.ContainmentModel;
   import org.apache.avalon.composition.model.ContainmentContext;
  +import org.apache.avalon.composition.model.ContextModel;
  +import org.apache.avalon.composition.model.DependencyModel;
   import org.apache.avalon.composition.model.DependencyGraph;
   import org.apache.avalon.composition.model.ComponentModel;
   import org.apache.avalon.composition.model.DeploymentModel;
  @@ -90,17 +92,24 @@
   import org.apache.avalon.composition.model.ModelRepository;
   import org.apache.avalon.composition.model.ModelSelector;
   import org.apache.avalon.composition.model.ProfileSelector;
  +import org.apache.avalon.composition.model.SystemContext;
  +import org.apache.avalon.composition.model.StageModel;
   import org.apache.avalon.composition.model.TypeRepository;
  +import org.apache.avalon.composition.model.TypeUnknownException;
   import org.apache.avalon.composition.logging.LoggingManager;
   import org.apache.avalon.composition.util.StringHelper;
   import org.apache.avalon.repository.Repository;
   import org.apache.avalon.repository.Artifact;
   import org.apache.avalon.repository.RepositoryException;
  +
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  +import org.apache.avalon.framework.parameters.Parameters;
  +
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  +
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.ServiceDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
  @@ -148,20 +157,24 @@
       }
   
       //--------------------------------------------------------------
  -    // state
  +    // immutable state
       //--------------------------------------------------------------
   
  -    private ContainmentContext m_context;
  +    private final LinkedList m_compositionListeners = new LinkedList();
   
  -    private String m_partition;
  +    private final DefaultState m_assembly = new DefaultState();
   
       private final Map m_models = new Hashtable();
   
  -    private CategoriesDirective m_categories;
  +    private final ContainmentContext m_context;
   
  -    private final LinkedList m_compositionListeners = new LinkedList();
  +    private final String m_partition;
   
  -    private final DefaultState m_assembly = new DefaultState();
  +    //--------------------------------------------------------------
  +    // state
  +    //--------------------------------------------------------------
  +
  +    private CategoriesDirective m_categories;
   
       //--------------------------------------------------------------
       // constructor
  @@ -213,6 +226,19 @@
           return m_context.getClassLoaderModel();
       }
   
  +   /** 
  +    * Returns the maximum allowable time for deployment.
  +    *
  +    * @return the maximum time expressed in millisecond of how 
  +    * long a deployment may take.
  +    */
  +    public long getDeploymentTimeout()
  +    {
  +        SystemContext system = m_context.getSystemContext();
  +        Parameters params = system.getSystemParameters();
  +        return params.getParameterAsLong( "deployment-timeout", 1000 );
  +    }
  +
      /**
       * Return the set of services produced by the model.
       * @return the services
  @@ -286,13 +312,339 @@
               for( int i=0; i<models.length; i++ )
               {
                   DeploymentModel model = models[i];
  -                model.assemble();
  +                assembleModel( model );
               }
   
               m_assembly.setEnabled( true );
           }
       }
   
  +    private void assembleModel( DeploymentModel model ) throws AssemblyException
  +    {
  +         if( null == model )
  +         {
  +             throw new NullPointerException( "model" );
  +         }
  +
  +         if( model.isAssembled() ) 
  +         {
  +             return;
  +         }
  +         else
  +         {
  +             if( model instanceof ComponentModel )
  +             {
  +                 assembleComponent( (ComponentModel) model );
  +             }
  +             else
  +             {
  +                 model.assemble();
  +             }
  +        }
  +    }
  +
  +    private void assembleComponent( ComponentModel model ) throws AssemblyException
  +    {
  +        ModelRepository repository = m_context.getModelRepository();
  +
  +        //
  +        // locate and assemble the component context handler
  +        //
  +
  +        if( model.getContextModel() != null )
  +        {
  +            ContextModel context = model.getContextModel();
  +            Class clazz = context.getStrategyClass();
  +            if( !clazz.getName().equals( 
  +              ContextModel.DEFAULT_STRATEGY_CLASSNAME ) )
  +            {
  +                if( null == context.getProvider() )
  +                {
  +                    try
  +                    {
  +                        StageDescriptor stage = 
  +                          new StageDescriptor( clazz.getName() );
  +                        DeploymentModel provider = 
  +                          findExtensionProvider( repository, stage );
  +                        context.setProvider( provider );
  +                    }
  +                    catch( Throwable e )
  +                    {
  +                        final String error = 
  +                          "Unable to assemble component: " 
  +                          + model 
  +                         + " due to a component context phase handler establishment failure.";
  +                        throw new AssemblyException( error, e );
  +                    }
  +                }
  +            }
  +        }
  +
  +        //
  +        // locate and resolve the stage providers
  +        //
  +
  +        StageModel[] stages = model.getStageModels();
  +        for( int i=0; i<stages.length; i++ )
  +        {
  +            StageModel stage = stages[i];
  +            if( null == stage.getProvider() )
  +            {
  +                try
  +                {
  +                    DeploymentModel provider =
  +                      findExtensionProvider( repository, stage );
  +                    stage.setProvider( provider );
  +                }
  +                catch( Throwable e )
  +                {
  +                    final String error = 
  +                      "Unable to assemble component: " 
  +                      + model 
  +                      + " due to a component extension handler establishment failure.";
  +                    throw new AssemblyException( error, e );
  +                }
  +            }
  +        }
  +
  +        //
  +        // locate and resolve the service providers
  +        //
  +
  +        DependencyModel[] dependencies = model.getDependencyModels();
  +        for( int i=0; i<dependencies.length; i++ )
  +        {
  +            DependencyModel dependency = dependencies[i];
  +            if( null == dependency.getProvider() )
  +            {
  +                try
  +                {
  +                    DeploymentModel provider =
  +                      findDependencyProvider( repository, dependency );
  +                    dependency.setProvider( provider );
  +                }
  +                catch( Throwable e )
  +                {
  +                    final String error = 
  +                      "Unable to assemble component: " + model 
  +                      + " due to a service provider establishment failure.";
  +                    throw new AssemblyException( error, e );
  +                }
  +            }
  +        }
  +    }
  +
  +    private DeploymentModel findDependencyProvider( 
  +      ModelRepository repository, DependencyModel dependency )
  +      throws AssemblyException
  +    {
  +        String path = dependency.getPath();
  +        if( null != path )
  +        {
  +            DeploymentModel model = getModel( path );
  +            if( null == model )
  +            {
  +                final String error = 
  +                  "Could not locate a model at the address: [" 
  +                  + path + "] in " + this + ".";
  +                throw new AssemblyException( error );
  +            }
  +            assembleModel( model );
  +            return model;
  +        }
  +        else
  +        {
  +            return findDependencyProvider( 
  +              repository, dependency.getDependency() );
  +        }
  +    }
  +
  +    private DeploymentModel findDependencyProvider( 
  +      ModelRepository repository, DependencyDescriptor dependency )
  +      throws AssemblyException
  +    {
  +        DeploymentModel[] candidates = 
  +          repository.getCandidateProviders( dependency );
  +        ModelSelector selector = new DefaultModelSelector();
  +        DeploymentModel model = selector.select( candidates, dependency );
  +        if( model != null )
  +        {
  +            assembleModel( model );
  +            return model;
  +        }
  +
  +        //
  +        // otherwise, check for any packaged profiles that 
  +        // we could use to construct the model
  +        //
  +
  +        Profile[] profiles = findDependencyProfiles( dependency );
  +        ProfileSelector profileSelector = new DefaultProfileSelector();
  +        Profile profile = profileSelector.select( profiles, dependency );
  +        if( profile != null ) 
  +        {
  +            try
  +            {
  +                DeploymentModel solution = addModel( profile );
  +                assembleModel( solution );
  +                return solution;
  +            }
  +            catch( AssemblyException ae )
  +            {
  +                final String error = 
  +                  "Nested assembly failure while attempting to construct model"
  +                  + " for the profile: [" + profile + "] for the dependency: ["
  +                  + dependency + "].";
  +                throw new AssemblyException( error, ae );
  +            }
  +            catch( ModelException me )
  +            {
  +                final String error = 
  +                  "Nested model failure while attempting to add model"
  +                  + " for the profile: [" + profile + "] for the dependency: ["
  +                  + dependency + "].";
  +                throw new AssemblyException( error, me );
  +            }
  +        }
  +        else
  +        {
  +            final String error = 
  +              "Unable to locate a service provider for the dependency: [ "
  +              + dependency + "].";
  +            throw new AssemblyException( error );
  +        }
  +    }
  +
  +    private DeploymentModel findExtensionProvider( 
  +      ModelRepository repository, StageModel stage )
  +      throws AssemblyException
  +    {
  +        String path = stage.getPath();
  +        if( null != path )
  +        {
  +            DeploymentModel model = getModel( path );
  +            if( null == model )
  +            {
  +                final String error = 
  +                  "Could not locate a model at the address: [" 
  +                  + path + "] in " + this + ".";
  +                throw new AssemblyException( error );
  +            }
  +            assembleModel( model );
  +            return model;
  +        }
  +        else
  +        {
  +            return findExtensionProvider( repository, stage.getStage() );
  +        }
  +    }
  +
  +    private DeploymentModel findExtensionProvider( 
  +      ModelRepository repository, StageDescriptor stage )
  +      throws AssemblyException
  +    {
  +        DeploymentModel[] candidates = 
  +          repository.getCandidateProviders( stage );
  +        ModelSelector selector = new DefaultModelSelector();
  +        DeploymentModel model = selector.select( candidates, stage );
  +        if( model != null )
  +        {
  +            assembleModel( model );
  +            return model;
  +        }
  +
  +        //
  +        // otherwise, check for any packaged profiles that 
  +        // we could use to construct the model
  +        //
  +
  +        Profile[] profiles = findExtensionProfiles( stage );
  +        ProfileSelector profileSelector = new DefaultProfileSelector();
  +        Profile profile = profileSelector.select( profiles, stage );
  +        if( profile != null ) 
  +        {
  +            try
  +            {
  +                DeploymentModel solution = addModel( profile );
  +                assembleModel( solution );
  +                return solution;
  +            }
  +            catch( AssemblyException ae )
  +            {
  +                final String error = 
  +                  "Nested assembly failure while attempting to construct model"
  +                  + " for the extension profile: [" + profile 
  +                  + "] for the stage dependency: ["
  +                  + stage + "].";
  +                throw new AssemblyException( error, ae );
  +            }
  +            catch( ModelException me )
  +            {
  +                final String error = 
  +                  "Nested model failure while attempting to add model"
  +                  + " for the extension profile: [" + profile 
  +                  + "] for the stage dependency: ["
  +                  + stage + "].";
  +                throw new AssemblyException( error, me );
  +            }
  +        }
  +        else
  +        {
  +            final String error = 
  +              "Unable to locate a extension provider for the stage: [ "
  +              + stage + "].";
  +            throw new AssemblyException( error );
  +        }
  +    }
  +
  +    private Profile[] findExtensionProfiles( StageDescriptor stage )
  +    {
  +        TypeRepository repository = getClassLoaderModel().getTypeRepository();
  +        Type[] types = repository.getTypes( stage );
  +        try
  +        {
  +            return getProfiles( repository, types );
  +        }
  +        catch( TypeUnknownException tue )
  +        {
  +            // will not happen
  +            final String error = "An irrational condition has occured.";
  +            throw new ModelRuntimeException( error, tue );
  +        }
  +    }
  +
  +    private Profile[] findDependencyProfiles( DependencyDescriptor dependency )
  +    {
  +        TypeRepository repository = getClassLoaderModel().getTypeRepository();
  +        Type[] types = repository.getTypes( dependency );
  +        try
  +        {
  +            return getProfiles( repository, types );
  +        }
  +        catch( TypeUnknownException tue )
  +        {
  +            // will not happen
  +            final String error = "An irrational condition has occured.";
  +            throw new ModelRuntimeException( error, tue );
  +        }
  +    }
  +
  +    private Profile[] getProfiles( TypeRepository repository, Type[] types )
  +      throws TypeUnknownException
  +    {
  +        ArrayList list = new ArrayList();
  +        for( int i=0; i<types.length; i++ )
  +        {
  +            Profile[] profiles = 
  +            repository.getProfiles( types[i] );
  +            for( int j=0; j<profiles.length; j++ )
  +            {
  +                list.add( profiles[j] );
  +            }
  +        }
  +        return (Profile[]) list.toArray( new Profile[0] );
  +    }
  +
       /**
        * Disassemble the model.
        */
  @@ -484,7 +836,8 @@
           return addModel( name, model );
       }
   
  -    private DeploymentModel addModel( String name, DeploymentModel model ) throws ModelException
  +    private DeploymentModel addModel( 
  +      String name, DeploymentModel model ) throws ModelException
       {
           ModelRepository repository = m_context.getModelRepository();
           synchronized( repository )
  @@ -609,7 +962,8 @@
   
               DefaultComponentContext context = 
                 new DefaultComponentContext( 
  -                logger, name, m_context, profile, type, base, home, temp, partition );
  +                logger, name, m_context, this, 
  +                profile, type, base, home, temp, partition );
   
               //
               // TODO: lookup the profile for a factory declaration, then 
  @@ -709,7 +1063,7 @@
                 new DefaultContainmentContext( 
                   logger, m_context.getSystemContext(), 
                   classLoaderModel, modelRepository, graph, 
  -                home, temp, profile, partition, name );
  +                home, temp, this, profile, partition, name );
   
               //
               // TODO: lookup the profile for a factory declaration, then 
  @@ -1046,58 +1400,121 @@
       */
       public DeploymentModel getModel( String path )
       {
  -        if( path.startsWith( "/" ) )
  +        if( path.equals( "" ) )
           {
  -            return getModel( path.substring( 1, path.length() ) );
  +            return this;
           }
  +        else if( path.startsWith( "/" ) )
  +        {
  +            //
  +            // its a absolute reference that need to be handled by the 
  +            // root container
  +            //
   
  -        int j = path.indexOf( "/" );
  -        if( j > -1 )
  +            if( null != m_context.getParentContainmentModel() )
  +            {
  +                return m_context.getParentContainmentModel().getModel( path );
  +            }
  +            else
  +            {
  +                //
  +                // this is the root container thereforw the 
  +                // path can be transfored to a relative reference
  +                //
  +
  +                return getModel( path.substring( 1 ) );
  +            }
  +        }
  +        else
           {
  -            String key = path.substring( 0, j );
  -            if( key.equals( "" ) )
  +            //
  +            // its a relative reference in the form xxx/yyy/zzz
  +            // so if the path contains "/", then locate the token 
  +            // proceeding the "/" (i.e. xxx) and apply the remainder 
  +            // (i.e. yyy/zzz) as the path argument , otherwise, its 
  +            // a local reference that we can pull from the model 
  +            // repository
  +            //
  +
  +            if( path.indexOf( "/" ) < 0 )
               {
  -                return this;
  +                return m_context.getModelRepository().getModel( path );
               }
               else
               {
  -                String remainder = path.substring( j+1 );
  -                DeploymentModel model = getModel( key );
  -                if( model == null )
  -                {
  -                    return null;
  -                }
  -                else if( model instanceof ContainmentModel )
  +                //
  +                // locate the relative root container, and apply 
  +                // getModel to the container
  +                //
  +
  +                final String root = getRootName( path );
  +                DeploymentModel model = 
  +                  m_context.getModelRepository().getModel( root );
  +                if( model != null )
                   {
  -                    return ((ContainmentModel)model).getModel( remainder );
  +                    //
  +                    // we have the sub-container so we can apply 
  +                    // the relative path after subtracting the name of 
  +                    // this container and the path seperator character
  +                    //
  +
  +                    if( model instanceof ContainmentModel )
  +                    {
  +                        ContainmentModel container = 
  +                          (ContainmentModel) model;
  +                        final String remainder = getRemainder( root, path );
  +                        return container.getModel( remainder );
  +                    }
  +                    else
  +                    {
  +                        final String error = 
  +                          "The path element [" + root 
  +                          + "] does not reference a containment model within ["
  +                          + this + "].";
  +                        throw new IllegalArgumentException( error );
  +                    }
                   }
                   else
                   {
  +                    //
  +                    // path contains a token that does not map to 
  +                    // known container
  +                    //
  +                    
                       final String error = 
  -                      "Bad path element: " + key 
  -                      + " in path: " + path;
  +                      "Unable to locate a container with name [" 
  +                      + root + "] within the container [" 
  +                      + this + "].";
                       throw new IllegalArgumentException( error );
  -                } 
  +                }
               }
           }
  +    }
  +
  +    private String getRootName( String path )
  +    {
  +        int n = path.indexOf( "/" );
  +        if( n < 0 ) 
  +        {
  +            return path;
  +        }
           else
           {
  -            if( path.equals( "" ) )
  -            {
  -                return this;
  -            }
  -            else
  -            {
  -                return m_context.getModelRepository().getModel( path );
  -            }
  +            return path.substring( 0, n ); 
           }
       }
   
  +    private String getRemainder( String name, String path )
  +    {
  +        return path.substring( name.length() + 1 );
  +    }
  +
      /**
       * Get a local model relative to a supplied service dependency.
       * @param dependency the service dependency descriptor
       * @exception ModelRuntimeException if an error occurs during model establishment
       */
  +    /*
       public DeploymentModel getModel( DependencyDescriptor dependency )
         throws ModelRuntimeException
       {
  @@ -1142,8 +1559,10 @@
               Profile[] collection = (Profile[]) list.toArray( new Profile[0] );
               ProfileSelector selector = new DefaultProfileSelector();
               Profile profile = selector.select( collection, dependency );
  -            if( profile != null ) return addModel( profile );
  -            return null;
  +            if( profile != null ) 
  +            {
  +                return addModel( profile );
  +            }
           }
           catch( Throwable e )
           {
  @@ -1155,7 +1574,14 @@
                   dependency.toString() );
               throw new ModelRuntimeException( error, e );
           }
  +
  +        //
  +        // check the parent
  +        //
  +
  +        return m_context.getModel( dependency );
       }
  +    */
   
      /**
       * Return a model relative to a supplied stage descriptor.
  @@ -1165,6 +1591,7 @@
       * @exception ModelRuntimeException if an error occurs 
       *   during model establishment
       */
  +    /*
       public DeploymentModel getModel( StageDescriptor stage ) 
         throws ModelRuntimeException
       {
  @@ -1214,10 +1641,6 @@
               {
                   return addModel( profile );
               }
  -            else
  -            {
  -                return null;
  -            }
           }
           catch( Throwable e )
           {
  @@ -1229,7 +1652,14 @@
                   stage.toString() );
               throw new ModelRuntimeException( error, e );
           }
  +
  +        //
  +        // check the parent
  +        //
  +
  +        return m_context.getModel( stage );
       }
  +    */
   
      /**
       * Return the set of service export mappings
  @@ -1270,15 +1700,6 @@
       }
   
      /**
  -    * Return a simple string represention of the containment model.
  -    * @return the string representation
  -    */
  -    public String toString()
  -    {
  -        return "[containment model: " + getQualifiedName() + "]";
  -    }
  -
  -   /**
       * Create a full deployment profile using a supplied named 
       * profile reference.
       *
  @@ -1394,6 +1815,5 @@
                 "Could not load the targets directive: " + url;
               throw new ModelException( error, e );
           }
  -        
       }
  -}
  +}
  \ No newline at end of file
  
  
  
  1.2.2.3   +5 -10     avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentContext.java
  
  Index: DefaultDeploymentContext.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentContext.java,v
  retrieving revision 1.2.2.2
  retrieving revision 1.2.2.3
  diff -u -r1.2.2.2 -r1.2.2.3
  --- DefaultDeploymentContext.java	4 Jan 2004 21:28:59 -0000	1.2.2.2
  +++ DefaultDeploymentContext.java	6 Jan 2004 23:16:49 -0000	1.2.2.3
  @@ -107,6 +107,10 @@
           }
   
           m_graph = new DependencyGraph( graph );
  +        if( graph != null )
  +        {
  +            graph.addChild( m_graph );
  +        }
   
           m_logger = logger;
           m_partition = partition;
  @@ -137,15 +141,6 @@
       {
           return m_partition;
       }
  -
  -   /**
  -    * Return the model fully qualified name.
  -    * @return the fully qualified name
  -    */
  -    //public String getPath()
  -    //{
  -    //    return getQualifiedName();
  -    //}
   
      /**
       * Return the model fully qualified name.
  
  
  
  1.9.2.6   +7 -2      avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentModel.java
  
  Index: DefaultDeploymentModel.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentModel.java,v
  retrieving revision 1.9.2.5
  retrieving revision 1.9.2.6
  diff -u -r1.9.2.5 -r1.9.2.6
  --- DefaultDeploymentModel.java	4 Jan 2004 21:28:59 -0000	1.9.2.5
  +++ DefaultDeploymentModel.java	6 Jan 2004 23:16:49 -0000	1.9.2.6
  @@ -177,7 +177,12 @@
   
       public String toString()
       {
  -        return "[model: " + getQualifiedName() + "]";
  +        return "[" + getQualifiedName() + "]";
       }
   
  +    public boolean equals( Object other )
  +    {
  +        boolean equal = super.equals( other ); 
  +        return equal;
  +    }
   }
  
  
  
  1.1.2.3   +74 -13    avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultModelRepository.java
  
  Index: DefaultModelRepository.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultModelRepository.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- DefaultModelRepository.java	4 Jan 2004 21:28:59 -0000	1.1.2.2
  +++ DefaultModelRepository.java	6 Jan 2004 23:16:49 -0000	1.1.2.3
  @@ -53,6 +53,7 @@
   import java.util.Map;
   import java.util.Hashtable;
   import java.util.Iterator;
  +import java.util.ArrayList;
   
   import org.apache.avalon.composition.model.DeploymentModel;
   import org.apache.avalon.composition.model.ModelRepository;
  @@ -93,19 +94,15 @@
       // constructor
       //------------------------------------------------------------------
   
  -    public DefaultModelRepository( Logger logger )
  -    {
  -        this( null, logger );
  -    }
  -
  -    public DefaultModelRepository( ModelRepository parent, Logger logger )
  +    public DefaultModelRepository( 
  +      ModelRepository parent, Logger logger )
       {
           m_parent = parent;
           m_logger = logger;
       }
       
       //------------------------------------------------------------------
  -    // ApplianceRepository
  +    // ModelRepository
       //------------------------------------------------------------------
   
       /**
  @@ -120,6 +117,7 @@
           // attempt to locate a solution locally
           //
   
  +System.out.println( "## resolving dep: " + dependency );
           Iterator iterator = m_models.values().iterator();
           while( iterator.hasNext() )
           {
  @@ -134,6 +132,7 @@
           // attempt to locate a solution from the parent
           //
   
  +System.out.println( "## nothing local, try parent: " + m_parent );
           if( m_parent != null )
           {
               return m_parent.getModel( dependency );
  @@ -143,7 +142,68 @@
       }
   
       /**
  -     * Locate an model meeting the supplied criteria.
  +     * Locate all models meeting the supplied criteria.
  +     *
  +     * @param stage a component stage dependency
  +     * @return the candidate models
  +     */
  +    public DeploymentModel[] getCandidateProviders( StageDescriptor stage )
  +    {
  +        ArrayList list = new ArrayList();
  +        Iterator iterator = m_models.values().iterator();
  +        while( iterator.hasNext() )
  +        {
  +            DeploymentModel model = (DeploymentModel) iterator.next();
  +            if( model.isaCandidate( stage ) )
  +            {
  +                list.add( model );
  +            }
  +        }
  +
  +        if( m_parent != null )
  +        {
  +            DeploymentModel[] models = m_parent.getCandidateProviders( stage );
  +            for( int i=0; i<models.length; i++ )
  +            {
  +                list.add( models[i] );
  +            }
  +        }
  +        return (DeploymentModel[]) list.toArray( new DeploymentModel[0] );
  +    }
  +
  +    /**
  +     * Locate all models meeting the supplied dependency criteria.
  +     *
  +     * @param dependency a component service dependency
  +     * @return the candidate models
  +     */
  +    public DeploymentModel[] getCandidateProviders( 
  +      DependencyDescriptor dependency )
  +    {
  +        ArrayList list = new ArrayList();
  +        Iterator iterator = m_models.values().iterator();
  +        while( iterator.hasNext() )
  +        {
  +            DeploymentModel model = (DeploymentModel) iterator.next();
  +            if( model.isaCandidate( dependency ) )
  +            {
  +                list.add( model );
  +            }
  +        }
  +
  +        if( m_parent != null )
  +        {
  +            DeploymentModel[] models = m_parent.getCandidateProviders( dependency );
  +            for( int i=0; i<models.length; i++ )
  +            {
  +                list.add( models[i] );
  +            }
  +        }
  +        return (DeploymentModel[]) list.toArray( new DeploymentModel[0] );
  +    }
  +
  +    /**
  +     * Locate a model meeting the supplied criteria.
        *
        * @param stage a component stage dependency
        * @return the model
  @@ -205,17 +265,18 @@
       }
   
       /**
  -     * Locate an model meeting the supplied criteria.
  +     * Return a sequence of all of the local models.
        *
  -     * @return the model
  +     * @return the model sequence
        */
       public DeploymentModel[] getModels()
       {
  -        return (DeploymentModel[]) m_models.values().toArray( new DeploymentModel[0] );
  +        return (DeploymentModel[]) m_models.values().toArray( 
  +          new DeploymentModel[0] );
       }
   
       /**
  -     * Locate an model matching the supplied name.
  +     * Locate a local model matching the supplied name.
        *
        * @param name the model name
        * @return the model or null if the model name is unknown
  
  
  
  1.4.2.1   +31 -5     avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSystemContext.java
  
  Index: DefaultSystemContext.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSystemContext.java,v
  retrieving revision 1.4
  retrieving revision 1.4.2.1
  diff -u -r1.4 -r1.4.2.1
  --- DefaultSystemContext.java	7 Dec 2003 08:36:07 -0000	1.4
  +++ DefaultSystemContext.java	6 Jan 2004 23:16:49 -0000	1.4.2.1
  @@ -67,7 +67,10 @@
   import org.apache.avalon.framework.logger.ConsoleLogger;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  +
   import org.apache.avalon.framework.context.DefaultContext;
  +import org.apache.avalon.framework.parameters.Parameters;
  +
   import org.apache.avalon.composition.data.CategoryDirective;
   
   
  @@ -107,7 +110,7 @@
           final File temp = new File( working, "temp" );
   
           return new DefaultSystemContext( 
  -          logging, base, home, temp, repository, "system", false );
  +          logging, base, home, temp, repository, "system", false, null );
       }
   
       private static Repository createRepository( File root ) throws Exception
  @@ -186,6 +189,8 @@
   
       private final Logger m_logger;
   
  +    private final Parameters m_parameters;
  +
       private ModelFactory m_factory;
   
       //==============================================================
  @@ -212,7 +217,7 @@
       */
       public DefaultSystemContext( 
         LoggingManager logging, File base, File home, File temp, 
  -      Repository repository, String category, boolean trace )
  +      Repository repository, String category, boolean trace, Parameters params )
       {
           if( base == null )
           {
  @@ -239,11 +244,20 @@
           m_trace = trace;
           m_repository = repository;
           m_logging = logging;
  -        m_logger = m_logging.getLoggerForCategory( category );
   
  +        if( params == null )
  +        {
  +            m_parameters = new Parameters();
  +            m_parameters.makeReadOnly();
  +        }
  +        else
  +        {
  +            m_parameters = params;
  +        }
  +
  +        m_logger = m_logging.getLoggerForCategory( category );
           m_system = SystemContext.class.getClassLoader();
           m_common = Logger.class.getClassLoader();
  -
           m_factory = new DefaultModelFactory( this );
       }
   
  @@ -366,4 +380,16 @@
       {
           return m_logger;
       }
  +
  +   /** 
  +    * Returns the configurable kernel parameters.
  +    *
  +    * @return a Parameters object populated with the system
  +    * parameters.
  +    */
  +    public Parameters getSystemParameters()
  +    {
  +        return m_parameters;
  +    }
  +
   }
  
  
  
  1.3.2.1   +20 -1     avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultTypeRepository.java
  
  Index: DefaultTypeRepository.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultTypeRepository.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- DefaultTypeRepository.java	28 Oct 2003 20:21:00 -0000	1.3
  +++ DefaultTypeRepository.java	6 Jan 2004 23:16:49 -0000	1.3.2.1
  @@ -306,6 +306,15 @@
               }
           }
   
  +        if( m_parent != null )
  +        {
  +            Type[] suppliment = m_parent.getTypes( dependency );
  +            for( int i=0; i<suppliment.length; i++ )
  +            {
  +                list.add( suppliment[i] );
  +            }
  +        }
  +
           return (Type[]) list.toArray( new Type[0] );
       }
   
  @@ -332,6 +341,16 @@
                   list.add( type );
               }
           }
  +
  +        if( m_parent != null )
  +        {
  +            Type[] suppliment = m_parent.getTypes( stage );
  +            for( int i=0; i<suppliment.length; i++ )
  +            {
  +                list.add( suppliment[i] );
  +            }
  +        }
  +
           return (Type[]) list.toArray( new Type[0] );
       }
   
  
  
  
  1.2.2.3   +7 -7      avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Resources.properties,v
  retrieving revision 1.2.2.2
  retrieving revision 1.2.2.3
  diff -u -r1.2.2.2 -r1.2.2.3
  --- Resources.properties	4 Jan 2004 17:23:17 -0000	1.2.2.2
  +++ Resources.properties	6 Jan 2004 23:16:50 -0000	1.2.2.3
  @@ -40,13 +40,13 @@
   deployment.context.internal.error=The context key [{0}] was recognized but could not be fulfilled as no context entry manager has be assigned to handle the request.
   deployment.registration.override.error=Illegal attempt to override an existing model entry [{0}].
   
  -assembly.context.error=Assembly of appliance [{0}] could not be completed due to an unresolvable custom contextualization stage dependency for the interface [{1}].
  -assembly.dependency.error=Assembly of appliance [{0}] could not be completed due to an unresolvable service dependency for the key [{1}].
  -assembly.stage.error=Assembly of appliance [{0}] could not be completed due to an unresolvable stage dependency for the key [{1}].
  -assembly.transitional.error=Illegal attempt to assemble [{0}] while the appliance is in a state of transition.
  -assembly.reassembly.error=Illegal attempt to re-assemble appliance [{0}].
  -assembly.dissassembly.transitional.error=Illegal attempt to dissassemble [{0}] while the appliance is in a state of transition.
  -assembly.dissassembly.state.error=Illegal attempt to dissassemble a dissassembled appliance [{0}].
  +assembly.context.error=Assembly of the model [{0}] could not be completed due to an unresolvable custom contextualization stage dependency for the interface [{1}].
  +assembly.dependency.error=Assembly of the model [{0}] could not be completed due to an unresolvable service dependency for the key [{1}].
  +assembly.stage.error=Assembly of the model [{0}] could not be completed due to an unresolvable stage dependency for the key [{1}].
  +assembly.transitional.error=Illegal attempt to assemble [{0}] while the the model is in a state of transition.
  +assembly.reassembly.error=Illegal attempt to re-assemble the model [{0}].
  +assembly.dissassembly.transitional.error=Illegal attempt to dissassemble [{0}] while the model is in a state of transition.
  +assembly.dissassembly.state.error=Illegal attempt to dissassemble a dissassembled model [{0}].
   assembly.context-strategy.bad-class.error=Context strategy handler class [{0}] does not implement the org.apache.avalon.activation.lifecycle.ContextualizationHandler interface defined in the container classloader.
   
   
  
  
  
  No                   revision
  No                   revision
  1.1.1.1.2.1 +1 -1      avalon/merlin/composition/impl/src/test/conf/block.xml
  
  Index: block.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/test/conf/block.xml,v
  retrieving revision 1.1.1.1
  retrieving revision 1.1.1.1.2.1
  diff -u -r1.1.1.1 -r1.1.1.1.2.1
  --- block.xml	24 Sep 2003 09:32:19 -0000	1.1.1.1
  +++ block.xml	6 Jan 2004 23:16:50 -0000	1.1.1.1.2.1
  @@ -43,7 +43,7 @@
          <component name="test" class="org.apache.avalon.composition.model.teste.TestE">
            <context>
              <entry key="home">
  -             <import key="urn:avalon:home.dir"/>
  +             <import key="urn:avalon:home"/>
              </entry>
            </context>
          </component>
  
  
  
  No                   revision
  No                   revision
  1.2.2.2   +79 -1     avalon/merlin/composition/impl/src/test/org/apache/avalon/composition/model/AbstractTestCase.java
  
  Index: AbstractTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/test/org/apache/avalon/composition/model/AbstractTestCase.java,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- AbstractTestCase.java	4 Jan 2004 20:19:27 -0000	1.2.2.1
  +++ AbstractTestCase.java	6 Jan 2004 23:16:50 -0000	1.2.2.2
  @@ -15,7 +15,7 @@
   
   public abstract class AbstractTestCase extends TestCase
   {
  -    public int PRIORITY = ConsoleLogger.LEVEL_WARN;
  +    public int PRIORITY = ConsoleLogger.LEVEL_INFO;
   
      //-------------------------------------------------------
      // state
  @@ -73,6 +73,84 @@
                   System.err.println( error );
                   fail( error );
               }
  +        }
  +    }
  +
  +    public void printModel( String lead, DeploymentModel model )
  +    {
  +        if( model instanceof ContainmentModel )
  +        {
  +            printContainmentModel( lead, (ContainmentModel) model );
  +        }
  +        else if( model instanceof ComponentModel ) 
  +        {
  +            printComponentModel( lead, (ComponentModel) model );
  +        }
  +    }
  +
  +    public void printContainmentModel( String lead, ContainmentModel model )
  +    {
  +        System.out.println( lead + "model:" + model );
  +        printDeploymentModel( lead, model );
  +        DeploymentModel[] models = model.getModels();
  +        if( models.length > 0 )
  +        {
  +            System.out.println( lead + "  children:" );
  +            for( int i=0; i<models.length; i++ )
  +            {
  +                DeploymentModel m = models[i];
  +                printModel( "    " + lead, m );
  +            }
  +        }
  +        models = model.getStartupGraph();
  +        if( models.length > 0 )
  +        {
  +            System.out.println( lead + "  startup:" );
  +            for( int i=0; i<models.length; i++ )
  +            {
  +                DeploymentModel m = models[i];
  +                System.out.println( "    " + lead + (i+1) + ": " + m );
  +            }
  +        }
  +        models = ((ContainmentModel)model).getShutdownGraph();
  +        if( models.length > 0 )
  +        {
  +            System.out.println( lead + "  shutdown:" );
  +            for( int i=0; i<models.length; i++ )
  +            {
  +                DeploymentModel m = models[i];
  +                System.out.println( "    " + lead + (i+1) + ": " + m );
  +            }
  +        }
  +    }
  +
  +    public void printComponentModel( String lead, ComponentModel model )
  +    {
  +        System.out.println( lead + "model:" + model );
  +        printDeploymentModel( lead, model );
  +    }
  +
  +    public void printDeploymentModel( String lead, DeploymentModel model )
  +    {
  +
  +        DeploymentModel[] providers = model.getProviderGraph();
  +        DeploymentModel[] consumers = model.getConsumerGraph();
  +
  +        if(( providers.length == 0 ) && ( consumers.length == 0 ))
  +        {
  +            return;
  +        }
  +
  +        if( providers.length > 0 ) for( int i=0; i<providers.length; i++ )
  +        {
  +            DeploymentModel m = providers[i];
  +            System.out.println( lead + "  <-- " + m );
  +        }
  +
  +        if( consumers.length > 0 ) for( int i=0; i<consumers.length; i++ )
  +        {
  +            DeploymentModel m = consumers[i];
  +            System.out.println( lead + "  --> " + m );
           }
       }
   }
  
  
  
  No                   revision
  No                   revision
  1.1.2.5   +0 -70     avalon/merlin/composition/impl/src/test/org/apache/avalon/composition/model/test/Attic/AssemblyTestCase.java
  
  Index: AssemblyTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/test/org/apache/avalon/composition/model/test/Attic/AssemblyTestCase.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- AssemblyTestCase.java	4 Jan 2004 21:29:00 -0000	1.1.2.4
  +++ AssemblyTestCase.java	6 Jan 2004 23:16:50 -0000	1.1.2.5
  @@ -43,74 +43,4 @@
               fail( error );
           }
       }
  -
  -    private void printModel( String lead, DeploymentModel model )
  -    {
  -        if( model instanceof ContainmentModel )
  -        {
  -            printContainmentModel( lead, (ContainmentModel) model );
  -        }
  -        else if( model instanceof ComponentModel ) 
  -        {
  -            printComponentModel( lead, (ComponentModel) model );
  -        }
  -    }
  -
  -    private void printContainmentModel( String lead, ContainmentModel model )
  -    {
  -        System.out.println( lead + "model:" + model );
  -        printCompositeModel( "\t" + lead, model );
  -        DeploymentModel[] models = model.getModels();
  -        if( models.length > 0 )
  -        {
  -            System.out.println( lead + "\tchildren:" );
  -            for( int i=0; i<models.length; i++ )
  -            {
  -                DeploymentModel m = models[i];
  -                printModel( "\t\t" + lead, m );
  -            }
  -        }
  -        models = model.getStartupGraph();
  -        if( models.length > 0 )
  -        {
  -            System.out.println( lead + "\tstartup:" );
  -            for( int i=0; i<models.length; i++ )
  -            {
  -                DeploymentModel m = models[i];
  -                System.out.println( "\t\t" + lead + (i+1) + ": " + m );
  -            }
  -        }
  -        models = ((ContainmentModel)model).getShutdownGraph();
  -        if( models.length > 0 )
  -        {
  -            System.out.println( lead + "\tshutdown:" );
  -            for( int i=0; i<models.length; i++ )
  -            {
  -                DeploymentModel m = models[i];
  -                System.out.println( "\t\t" + lead + (i+1) + ": " + m );
  -            }
  -        }
  -    }
  -
  -    private void printComponentModel( String lead, ComponentModel model )
  -    {
  -        System.out.println( lead + "model:" + model );
  -        printCompositeModel( lead, model );
  -    }
  -
  -    private void printCompositeModel( String lead, DeploymentModel model )
  -    {
  -        DeploymentModel[] models = model.getProviderGraph();
  -        for( int i=0; i<models.length; i++ )
  -        {
  -            DeploymentModel m = models[i];
  -            System.out.println( "\t" + lead + (i+1) + ": " + m + " (provider)" );
  -        }
  -        models = model.getConsumerGraph();
  -        for( int i=0; i<models.length; i++ )
  -        {
  -            DeploymentModel m = models[i];
  -            System.out.println( "\t" + lead + (i+1) + ": " + m + " (consumer)" );
  -        }
  -    }
   }
  
  
  

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


Mime
View raw message