You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2004/02/07 18:41:29 UTC

cvs commit: avalon/merlin/composition/impl/src/test/org/apache/avalon/composition/model AbstractTestCase.java

mcconnell    2004/02/07 09:41:28

  Modified:    merlin/activation/impl/src/test/org/apache/avalon/activation/appliance
                        AbstractTestCase.java
               merlin/composition/api/src/java/org/apache/avalon/composition/model
                        ComponentContext.java ContainmentModel.java
                        ModelFactory.java
               merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl
                        DefaultComponentContext.java
                        DefaultContainmentModel.java
                        DefaultModelFactory.java
               merlin/composition/impl/src/test/org/apache/avalon/composition/model
                        AbstractTestCase.java
  Added:       merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl
                        ComponentModelContextHelper.java
  Log:
  Improve model factory interface and start of simplification of the default containerment model.
  
  Revision  Changes    Path
  1.15      +1 -1      avalon/merlin/activation/impl/src/test/org/apache/avalon/activation/appliance/AbstractTestCase.java
  
  Index: AbstractTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/test/org/apache/avalon/activation/appliance/AbstractTestCase.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AbstractTestCase.java	7 Feb 2004 14:03:42 -0000	1.14
  +++ AbstractTestCase.java	7 Feb 2004 17:41:28 -0000	1.15
  @@ -128,7 +128,7 @@
           //
   
           ContainmentProfile profile = setUpProfile( block );
  -        m_model = m_system.getModelFactory().createContainmentModel( profile );
  +        m_model = m_system.getModelFactory().createRootContainmentModel( profile );
       }
   
       protected ContainmentProfile setUpProfile( File file )
  
  
  
  1.5       +1 -8      avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ComponentContext.java
  
  Index: ComponentContext.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ComponentContext.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ComponentContext.java	6 Feb 2004 15:27:14 -0000	1.4
  +++ ComponentContext.java	7 Feb 2004 17:41:28 -0000	1.5
  @@ -70,13 +70,6 @@
       SystemContext getSystemContext();
   
      /**
  -    * Return the containment context.
  -    *
  -    * @return the containment context
  -    */
  -    ContainmentContext getContainmentContext();
  -
  -   /**
       * Return the working directory for the component.
       *
       * @return the working directory
  
  
  
  1.16      +9 -8      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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ContainmentModel.java	7 Feb 2004 06:06:30 -0000	1.15
  +++ ContainmentModel.java	7 Feb 2004 17:41:28 -0000	1.16
  @@ -105,10 +105,13 @@
       DeploymentModel[] getModels();
   
      /**
  -    * Return a model relative to a supplied name.
  -    * @return the named model or null if the name is unknown
  +    * Return a model relative to a supplied path.
  +    *
  +    * @param path a relative or absolute path
  +    * @return the model or null if the path is unresolvable
  +    * @exception IllegalArgumentException if the path if badly formed
       */
  -    DeploymentModel getModel( String name );
  +    DeploymentModel getModel( String path );
   
      /**
       * Addition of a new subsidiary model within
  @@ -143,12 +146,10 @@
       DeploymentModel addModel( DeploymentProfile profile ) throws ModelException;
   
      /**
  -    * Removal of a named model for the containment model.
  -    *
  -    * @param name the name of the subsidiary model to be removed
  +    * Remove a named model from this model.
  +    * @param name the name of an immediate child model
       */
       void removeModel( String name );
  -
   
      /**
       * Return the set of service export models.
  
  
  
  1.6       +16 -24    avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ModelFactory.java
  
  Index: ModelFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ModelFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ModelFactory.java	7 Feb 2004 14:03:42 -0000	1.5
  +++ ModelFactory.java	7 Feb 2004 17:41:28 -0000	1.6
  @@ -18,7 +18,9 @@
   package org.apache.avalon.composition.model;
   
   import java.net.URL;
  +import java.io.File;
   
  +import org.apache.avalon.composition.data.ComponentProfile;
   import org.apache.avalon.composition.data.ContainmentProfile;
   
   /**
  @@ -36,7 +38,7 @@
       * @return the containment model
       * @exception ModelException if an error occurs during model establishment
       */
  -    ContainmentModel createContainmentModel( URL url ) 
  +    ContainmentModel createRootContainmentModel( URL url ) 
         throws ModelException;
   
      /**
  @@ -46,38 +48,28 @@
       * @return the containment model
       * @exception ModelException if an error occurs during model establishment
       */
  -    ContainmentModel createContainmentModel( ContainmentProfile profile ) 
  +    ContainmentModel createRootContainmentModel( ContainmentProfile profile ) 
         throws ModelException;
   
      /**
  -    * Creation of a new root containment context.
  +    * Creation of a new nested component model using a supplied component
  +    * context.
       *
  -    * @param profile a composition profile 
  -    * @return the containment model
  +    * @param context a potentially foreign component context
  +    * @return the compoent model
       */
  -    //ContainmentContext createContainmentContext( ContainmentProfile profile ) 
  -    //  throws ModelException;
  +    ComponentModel createComponentModel( ComponentContext context )
  +      throws ModelException;
  +
   
      /**
  -    * Creation of a new nested containment model.  This method is called
  -    * by a container implementation when constructing model instances.  The 
  -    * factory is identified by its implementation classname.
  +    * Creation of a new nested containment model using a supplied 
  +    * containment context.
       *
       * @param context a potentially foreign containment context
       * @return the containment model
       */
  -    //ContainmentModel createContainmentModel( ContainmentContext context )
  -    //  throws ModelException;
  -
  -   /**
  -    * Creation of a new nested deployment model.  This method is called
  -    * by a container implementation when constructing model instances.  The 
  -    * factory is identified by its implementation classname.
  -    *
  -    * @param context a potentially foreign deployment context
  -    * @return the deployment model
  -    */
  -    //ComponentModel createComponentModel( ComponentContext context )
  -    //  throws ModelException;
  +    ContainmentModel createContainmentModel( ContainmentContext context )
  +      throws ModelException;
   
   }
  
  
  
  1.5       +14 -24    avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultComponentContext.java
  
  Index: DefaultComponentContext.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultComponentContext.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultComponentContext.java	6 Feb 2004 15:27:14 -0000	1.4
  +++ DefaultComponentContext.java	7 Feb 2004 17:41:28 -0000	1.5
  @@ -28,6 +28,7 @@
   import org.apache.avalon.composition.model.EntryModel;
   import org.apache.avalon.composition.model.ModelRuntimeException;
   import org.apache.avalon.composition.model.SystemContext;
  +import org.apache.avalon.composition.model.DependencyGraph;
   
   import org.apache.avalon.composition.data.ComponentProfile;
   
  @@ -66,7 +67,7 @@
       // immutable state
       //==============================================================
   
  -    private final ContainmentContext m_context;
  +    private final ClassLoader m_classloader;
   
       private final ComponentProfile m_profile;
   
  @@ -95,8 +96,9 @@
       *
       * @param logger the logging channel to assign
       * @param name the deployment context name
  -    * @param context the containment context in which this 
  -    *     deployment context is scoped
  +    * @param system the system context
  +    * @param classloader the containers classloader
  +    * @param graph the containers dependency graph
       * @param profile the deployment profile
       * @param type the underlying component type
       * @param clazz the compoent deployment class
  @@ -105,22 +107,20 @@
       * @param partition the partition name 
       */
       public DefaultComponentContext( 
  -      Logger logger, String name, ContainmentContext context, 
  -      ContainmentModel model, ComponentProfile profile, 
  -      Type type, Class clazz, 
  -      File home, File temp, String partition )
  +      Logger logger, String name, SystemContext system, ClassLoader classloader, 
  +      DependencyGraph graph, ContainmentModel model, ComponentProfile profile, 
  +      Type type, Class clazz, File home, File temp, String partition )
       {
           super( 
  -          logger, context.getSystemContext(), partition, name, profile.getMode(),
  -          context.getDependencyGraph() );
  +          logger, system, partition, name, profile.getMode(), graph );
   
           if( partition == null )
           {
               throw new NullPointerException( "partition" );
           }
  -        if( context == null )
  +        if( classloader == null )
           {
  -            throw new NullPointerException( "context" );
  +            throw new NullPointerException( "classloader" );
           }
           if( clazz == null )
           {
  @@ -154,7 +154,7 @@
   
           m_home = home;
           m_temp = temp;
  -        m_context = context;
  +        m_classloader = classloader;
           m_type = type;
           m_profile = profile;
           m_class = clazz;
  @@ -166,16 +166,6 @@
       //==============================================================
   
      /**
  -    * Return the containment context.
  -    *
  -    * @return the containment context
  -    */
  -    public ContainmentContext getContainmentContext()
  -    {
  -        return m_context;
  -    }
  -
  -   /**
       * Return the enclosing containment model.
       * @return the containment model that component is within
       */
  @@ -241,7 +231,7 @@
       */
       public ClassLoader getClassLoader()
       {
  -        return m_context.getClassLoader();
  +        return m_classloader;
       }
   
      /**
  
  
  
  1.26      +8 -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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- DefaultContainmentModel.java	7 Feb 2004 06:06:30 -0000	1.25
  +++ DefaultContainmentModel.java	7 Feb 2004 17:41:28 -0000	1.26
  @@ -968,59 +968,13 @@
       private ComponentModel createComponentModel( final ComponentProfile profile ) 
         throws ModelException
       {
  -        if( null == profile )
  -        {
  -            throw new NullPointerException( "profile" );
  -        }
  -
  -        final String name = profile.getName();
  -        final String partition = getPartition();
  -
  -        LoggingManager logging = m_context.getSystemContext().getLoggingManager();
  -        CategoriesDirective categories = profile.getCategories();
  -        if( null != categories )
  -        {   
  -            logging.addCategories( partition, profile.getCategories() );
  -        }
  -        Logger logger = logging.getLoggerForCategory( partition + name );
  -        if( getLogger().isDebugEnabled() )
  -        {
  -            final String message = 
  -              StringHelper.toString( REZ.getString( "containment.add", name ) );
  -            getLogger().debug(  message );
  -        }
  -
  -        try
  -        {
  -            ClassLoader classLoader = m_context.getClassLoader();
  -            Class base = classLoader.loadClass( profile.getClassname() );
  -            Type type = 
  -              m_context.getClassLoaderModel().getTypeRepository().getType( base );
  -            final File home = new File( m_context.getHomeDirectory(), name );
  -            final File temp = new File( m_context.getTempDirectory(), name );
  -
  -            DefaultComponentContext context = 
  -              new DefaultComponentContext( 
  -                logger, name, m_context, this, 
  -                profile, type, base, home, temp, partition );
  -
  -            //
  -            // TODO: lookup the profile for a factory declaration, then 
  -            // use the factory to create the model using the context as 
  -            // the argument.
  -            //
  -
  -            return new DefaultComponentModel( context );
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              REZ.getString( 
  -                "containment.deployment.create.error", 
  -                getPath(), 
  -                profile.getName() );
  -            throw new ModelException( error, e );
  -        }
  +        ComponentModelContextHelper helper = 
  +          new ComponentModelContextHelper( m_context, this );
  +        ComponentContext context = 
  +          helper.createComponentContext( profile );
  +        ModelFactory factory = 
  +          m_context.getSystemContext().getModelFactory();
  +        return factory.createComponentModel( context );
       }
   
      /**
  
  
  
  1.7       +75 -53    avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultModelFactory.java
  
  Index: DefaultModelFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultModelFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultModelFactory.java	7 Feb 2004 14:03:42 -0000	1.6
  +++ DefaultModelFactory.java	7 Feb 2004 17:41:28 -0000	1.7
  @@ -22,6 +22,11 @@
   import java.net.URL;
   import java.net.URLConnection;
   
  +import org.apache.avalon.composition.data.ComponentProfile;
  +import org.apache.avalon.composition.data.ContainmentProfile;
  +import org.apache.avalon.composition.data.ClassLoaderDirective;
  +import org.apache.avalon.composition.data.builder.ContainmentProfileBuilder;
  +import org.apache.avalon.composition.data.builder.XMLContainmentProfileCreator;
   import org.apache.avalon.composition.model.ClassLoaderModel;
   import org.apache.avalon.composition.model.ClassLoaderContext;
   import org.apache.avalon.composition.model.ContainmentModel;
  @@ -31,17 +36,22 @@
   import org.apache.avalon.composition.model.ModelFactory;
   import org.apache.avalon.composition.model.ModelException;
   import org.apache.avalon.composition.model.SystemContext;
  +import org.apache.avalon.composition.model.DependencyGraph;
  +
  +import org.apache.avalon.logging.provider.LoggingManager;
  +import org.apache.avalon.logging.data.CategoriesDirective;
  +
   import org.apache.avalon.repository.Repository;
  +
   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.DefaultConfigurationBuilder;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.logger.Logger;
  -import org.apache.avalon.composition.data.ContainmentProfile;
  -import org.apache.avalon.composition.data.ClassLoaderDirective;
  -import org.apache.avalon.composition.data.builder.ContainmentProfileBuilder;
  -import org.apache.avalon.composition.data.builder.XMLContainmentProfileCreator;
  +
  +import org.apache.avalon.meta.info.Type;
   
   /**
    * A factory enabling the establishment of new composition model instances.
  @@ -52,9 +62,9 @@
   public class DefaultModelFactory extends AbstractLogEnabled 
     implements ModelFactory
   {
  -    //==============================================================
  +    //-------------------------------------------------------------------
       // static
  -    //==============================================================
  +    //-------------------------------------------------------------------
   
       private static final XMLContainmentProfileCreator CREATOR = 
         new XMLContainmentProfileCreator();
  @@ -65,15 +75,15 @@
       private static final Resources REZ =
         ResourceManager.getPackageResources( DefaultModelFactory.class );
   
  -    //==============================================================
  +    //-------------------------------------------------------------------
       // immutable state
  -    //==============================================================
  +    //-------------------------------------------------------------------
   
       final SystemContext m_system;
   
  -    //==============================================================
  +    //-------------------------------------------------------------------
       // constructor
  -    //==============================================================
  +    //-------------------------------------------------------------------
   
       public DefaultModelFactory( final SystemContext system )
       {
  @@ -85,9 +95,9 @@
           enableLogging( system.getLogger() );
       }
   
  -    //==============================================================
  -    // ContainmentModelFactory
  -    //==============================================================
  +    //-------------------------------------------------------------------
  +    // ModelFactory
  +    //-------------------------------------------------------------------
   
      /**
       * Creation of a new root containment model using 
  @@ -96,7 +106,7 @@
       * @param url a composition profile source
       * @return the containment model
       */
  -    public ContainmentModel createContainmentModel( URL url ) 
  +    public ContainmentModel createRootContainmentModel( URL url ) 
         throws ModelException
       {
           //
  @@ -119,7 +129,7 @@
                     builder.build( url.toString() );
                   final ContainmentProfile profile = 
                     CREATOR.createContainmentProfile( config );
  -                return createContainmentModel( profile );
  +                return createRootContainmentModel( profile );
               }
               catch( ModelException e )
               {
  @@ -143,7 +153,7 @@
               final InputStream stream = connection.getInputStream();
               final ContainmentProfile profile = 
                 BUILDER.createContainmentProfile( stream );
  -            return createContainmentModel( profile );
  +            return createRootContainmentModel( profile );
           }
           catch( Throwable e )
           {
  @@ -160,29 +170,67 @@
       * @param profile a containment profile 
       * @return the containment model
       */
  -    public ContainmentModel createContainmentModel( ContainmentProfile profile ) 
  +    public ContainmentModel createRootContainmentModel( 
  +      ContainmentProfile profile ) 
         throws ModelException
       {
           try
           {
  -            ContainmentContext context = createContainmentContext( profile );
  +            ContainmentContext context = 
  +              createRootContainmentContext( profile );
               return createContainmentModel( context );
           }
           catch( Throwable e )
           {
               final String error = 
  -              REZ.getString( "factory.containment.create.error", profile.getName() );
  +              REZ.getString( 
  +                "factory.containment.create.error", 
  +                profile.getName() );
               throw new ModelException( error, e );
           }
       }
   
      /**
  +    * Creation of a new nested deployment model.  This method is called
  +    * by a container implementation when constructing model instances.  The 
  +    * factory is identified by its implementation classname.
  +    *
  +    * @param context a potentially foreign deployment context
  +    * @return the deployment model
  +    */
  +    public ComponentModel createComponentModel( ComponentContext context )
  +      throws ModelException
  +    {
  +        return new DefaultComponentModel( context );
  +    }
  +
  +   /**
  +    * Creation of a new nested containment model.  This method is called
  +    * by a container implementation when constructing model instances.  The 
  +    * factory is identified by its implementation classname.
  +    *
  +    * @param context a potentially foreign containment context
  +    * @return the containment model
  +    */
  +    public ContainmentModel createContainmentModel( 
  +      ContainmentContext context )
  +      throws ModelException
  +    {
  +        return new DefaultContainmentModel( context );
  +    }
  +
  +    //-------------------------------------------------------------------
  +    // implementation
  +    //-------------------------------------------------------------------
  +
  +   /**
       * Creation of a new root containment context.
       *
       * @param profile a containment profile 
       * @return the containment context
       */
  -    private ContainmentContext createContainmentContext( ContainmentProfile profile ) 
  +    private ContainmentContext createRootContainmentContext( 
  +      ContainmentProfile profile ) 
         throws ModelException
       {
           if( profile == null )
  @@ -190,8 +238,10 @@
               throw new NullPointerException( "profile" );
           }
   
  -        m_system.getLoggingManager().addCategories( profile.getCategories() );
  -        final Logger logger = m_system.getLoggingManager().getLoggerForCategory("");
  +        m_system.getLoggingManager().addCategories( 
  +          profile.getCategories() );
  +        final Logger logger =
  +          m_system.getLoggingManager().getLoggerForCategory("");
   
           try
           {
  @@ -216,38 +266,10 @@
           catch( Throwable e )
           {
               final String error = 
  -              REZ.getString( "factory.containment.create.error", profile.getName() );
  +              REZ.getString( 
  +                "factory.containment.create.error", 
  +                profile.getName() );
               throw new ModelException( error, e );
           }
  -    }
  -
  -
  -   /**
  -    * Creation of a new nested containment model.  This method is called
  -    * by a container implementation when constructing model instances.  The 
  -    * factory is identified by its implementation classname.
  -    *
  -    * @param context a potentially foreign containment context
  -    * @return the containment model
  -    */
  -    private ContainmentModel createContainmentModel( ContainmentContext context )
  -      throws ModelException
  -    {
  -        return new DefaultContainmentModel( context );
  -    }
  -
  -
  -   /**
  -    * Creation of a new nested deployment model.  This method is called
  -    * by a container implementation when constructing model instances.  The 
  -    * factory is identified by its implementation classname.
  -    *
  -    * @param context a potentially foreign deployment context
  -    * @return the deployment model
  -    */
  -    public ComponentModel createComponentModel( ComponentContext context )
  -      throws ModelException
  -    {
  -        return new DefaultComponentModel( context );
       }
   }
  
  
  
  1.1                  avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/ComponentModelContextHelper.java
  
  Index: ComponentModelContextHelper.java
  ===================================================================
  /* 
   * Copyright 2004 Apache Software Foundation
   * Licensed  under the  Apache License,  Version 2.0  (the "License");
   * you may not use  this file  except in  compliance with the License.
   * You may obtain a copy of the License at 
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed  under the  License is distributed on an "AS IS" BASIS,
   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
   * implied.
   * 
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.avalon.composition.model.impl;
  
  import java.io.File;
  import java.io.InputStream;
  import java.net.URL;
  import java.net.URLConnection;
  
  import org.apache.avalon.composition.data.ComponentProfile;
  import org.apache.avalon.composition.data.ContainmentProfile;
  import org.apache.avalon.composition.data.ClassLoaderDirective;
  import org.apache.avalon.composition.data.builder.ContainmentProfileBuilder;
  import org.apache.avalon.composition.data.builder.XMLContainmentProfileCreator;
  import org.apache.avalon.composition.model.ClassLoaderModel;
  import org.apache.avalon.composition.model.ClassLoaderContext;
  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.ComponentModel;
  import org.apache.avalon.composition.model.ModelFactory;
  import org.apache.avalon.composition.model.ModelException;
  import org.apache.avalon.composition.model.SystemContext;
  import org.apache.avalon.composition.model.DependencyGraph;
  
  import org.apache.avalon.logging.provider.LoggingManager;
  import org.apache.avalon.logging.data.CategoriesDirective;
  
  import org.apache.avalon.repository.Repository;
  
  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.DefaultConfigurationBuilder;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.logger.Logger;
  
  import org.apache.avalon.meta.info.Type;
  
  /**
   * A utility class that handles creation of a component model context.
   *
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2004/02/07 17:41:28 $
   */
  class ComponentContextHelper
  {
      //-------------------------------------------------------------------
      // static
      //-------------------------------------------------------------------
  
      private static final Resources REZ =
        ResourceManager.getPackageResources( ComponentContextHelper.class );
  
      //-------------------------------------------------------------------
      // immutable state
      //-------------------------------------------------------------------
  
      private final ContainmentContext m_context;
      private final ContainmentModel m_model;
  
      //-------------------------------------------------------------------
      // constructor
      //-------------------------------------------------------------------
  
     /**
      * Creation of a component context creation helper.
      * @param context the containment model context
      * @param model the containment model
      */
      public ComponentContextHelper( 
         ContainmentContext context, ContainmentModel model )
      {
          if( context == null )
          {
              throw new NullPointerException( "context" );
          }
          if( model == null )
          {
              throw new NullPointerException( "model" );
          }
          m_context = context;
          m_model = model;
      }
  
      //-------------------------------------------------------------------
      // implementation
      //-------------------------------------------------------------------
  
     /**
      * Creation of a new component model relative to a supplied profile.
      *
      * @param profile the component profile
      * @return the component model context
      */
      public ComponentContext createComponentContext( final ComponentProfile profile )
        throws ModelException
      {
          if( null == profile )
          {
              throw new NullPointerException( "profile" );
          }
  
          SystemContext system = m_context.getSystemContext();
          final String name = profile.getName();
          final String partition = m_model.getPartition();
          LoggingManager logging = system.getLoggingManager();
          CategoriesDirective categories = profile.getCategories();
          if( null != categories )
          {
              logging.addCategories( partition, categories );
          }
  
          Logger logger = 
            logging.getLoggerForCategory( partition + name );
          DependencyGraph graph = m_context.getDependencyGraph();
          ClassLoader classloader = m_context.getClassLoader();
          final File home = new File( m_context.getHomeDirectory(), name );
          final File temp = new File( m_context.getTempDirectory(), name );
  
          try
          {
              Class base = classloader.loadClass( profile.getClassname() );
              Type type = 
                m_model.getClassLoaderModel().getTypeRepository().getType( base );
  
              return new DefaultComponentContext( 
                  logger, 
                  name, 
                  system, 
                  classloader, 
                  graph, 
                  m_model, 
                  profile, 
                  type, 
                  base, 
                  home, 
                  temp, 
                  partition );
  
          }
          catch( Throwable e )
          {
              final String error = 
                REZ.getString( 
                  "containment.deployment.create.error", 
                  m_model.getPath(), 
                  name );
              throw new ModelException( error, e );
          }
      }
  }
  
  
  
  1.8       +1 -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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AbstractTestCase.java	7 Feb 2004 14:03:42 -0000	1.7
  +++ AbstractTestCase.java	7 Feb 2004 17:41:28 -0000	1.8
  @@ -82,7 +82,7 @@
                     SystemContextBuilder.createSystemContext( 
                       context, base, root, PRIORITY, true, 1000 );
                   ModelFactory factory = system.getModelFactory();
  -                m_model = factory.createContainmentModel( source.toURL() );
  +                m_model = factory.createRootContainmentModel( source.toURL() );
               }
               catch( Throwable e )
               {
  
  
  

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