You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2003/07/04 17:24:55 UTC

cvs commit: avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model ClassLoaderModel.java ContainmentModel.java DeploymentModel.java

mcconnell    2003/07/04 08:24:55

  Modified:    merlin/composition/src/java/org/apache/avalon/composition/model/impl
                        DefaultClassLoaderModel.java
                        DefaultCompositionModel.java
                        DefaultCompositionModelFactory.java
                        DefaultContainmentModel.java
                        DefaultDeploymentModel.java Resources.properties
               merlin/composition-spi/src/java/org/apache/avalon/composition/model
                        ClassLoaderModel.java ContainmentModel.java
                        DeploymentModel.java
  Log:
  Updating of the composition model to ensure that a model is built using the classpath declared within the model (i.e. all factory methods have to look ahead into the model, construct the classloader, and supply the classloader as a constructor argument to the model it is creating).  This ensures that *any* class referenced within the scope of a particular model is valid providing it is declared with the models classpath.  This allows the declaration of model factories within the declaration of the model.
  
  Revision  Changes    Path
  1.2       +90 -55    avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultClassLoaderModel.java
  
  Index: DefaultClassLoaderModel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultClassLoaderModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultClassLoaderModel.java	4 Jul 2003 07:27:35 -0000	1.1
  +++ DefaultClassLoaderModel.java	4 Jul 2003 15:24:55 -0000	1.2
  @@ -57,9 +57,11 @@
   import java.util.jar.Manifest;
   import java.net.JarURLConnection;
   import java.net.URL;
  +import java.net.URLClassLoader;
   
   import org.apache.avalon.composition.model.ClassLoaderModel;
   import org.apache.avalon.composition.model.SystemContext;
  +import org.apache.avalon.composition.model.TypeRepository;
   import org.apache.avalon.composition.repository.Repository;
   import org.apache.avalon.extension.Extension;
   import org.apache.avalon.extension.manager.ExtensionManager;
  @@ -67,14 +69,13 @@
   import org.apache.avalon.extension.manager.PackageManager;
   import org.apache.avalon.extension.manager.impl.DefaultExtensionManager;
   import org.apache.avalon.extension.manager.impl.DelegatingExtensionManager;
  +import org.apache.avalon.excalibur.i18n.ResourceManager;
  +import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.meta.data.ClassLoaderDirective;
   import org.apache.avalon.meta.data.ClasspathDirective;
   import org.apache.avalon.meta.data.RepositoryDirective;
   import org.apache.avalon.meta.data.ResourceDirective;
  -import org.apache.avalon.excalibur.i18n.ResourceManager;
  -import org.apache.avalon.excalibur.i18n.Resources;
  -
   
   /**
    * <p>Implementation of a classloader model within which a 
  @@ -119,25 +120,23 @@
       // state
       //==============================================================
   
  -    private File m_base;
  -
  -    private Repository m_repository;
  +    private final ClassLoaderModel m_parent;
   
  -    private ClassLoaderDirective m_directive;
  +    private final String[] m_classpath;
   
  -    private ClassLoaderModel m_parent;
  +    private final ExtensionManager m_extension;
   
  -    private String[] m_classpath;
  +    private final PackageManager m_manager;
   
  -    private ExtensionManager m_extension;
  +    private final Logger m_logger;
   
  -    private PackageManager m_manager;
  +    private final OptionalPackage[] m_packages;
   
  -    private Logger m_logger;
  +    private final URL[] m_urls;
   
  -    private OptionalPackage[] m_packages;
  +    private final URLClassLoader m_classLoader;
   
  -    private URL[] m_urls;
  +    private final DefaultTypeRepository m_types;
   
       //==============================================================
       // constructor
  @@ -156,29 +155,49 @@
       *    primative classpath entries and resource directives
       */
       protected DefaultClassLoaderModel( 
  -      final Logger logger, final SystemContext system, final ClassLoaderDirective directive )
  +      final Logger logger, final SystemContext system, ClassLoader classLoader, final ClassLoaderDirective directive )
         throws Exception
       {
  +        if( logger == null )
  +        {
  +            throw new NullPointerException( "logger" );
  +        }
           if( system == null )
           {
               throw new NullPointerException( "system" );
           }
  +        if( classLoader == null )
  +        {
  +            throw new NullPointerException( "classLoader" );
  +        }
  +        if( directive == null )
  +        {
  +            throw new NullPointerException( "directive" );
  +        }
   
           m_logger = logger;
  -        m_repository = system.getRepository();
  -        m_base = system.getBaseDirectory();
           m_extension = new DefaultExtensionManager( 
  -            directive.getLibrary().getOptionalExtensionDirectories( m_base ) );
  +            directive.getLibrary().getOptionalExtensionDirectories( system.getBaseDirectory() ) );
           m_manager = new PackageManager( m_extension );
  -        m_directive = directive;
  +        m_parent = null;
   
           //
           // generate the primitive classpath
           //
   
  -        m_classpath = createClassPath();
  +        m_classpath = createClassPath( system, directive );
           m_packages = buildOptionalPackages( m_classpath );
           m_urls = buildQualifiedClassPath();
  +        m_classLoader = new URLClassLoader( 
  +          m_urls, classLoader );
  +
  +        //
  +        // create a type repository
  +        //
  +
  +        m_types = new DefaultTypeRepository( m_classLoader );
  +        m_types.enableLogging( logger.getChildLogger( "type" ) );
  +
       }
   
      /**
  @@ -186,48 +205,65 @@
       * repository, a base directory and a classloader directive 
       * enabling the creation of a fully populated classpath.
       *
  -    * @param base the base directory from which relative references 
  -    *    shall be resolved
  -    * @param repository a local cache of jar files addressable
  -    *    relative to group/name/version identifiers
  +    * @param logger the assigned logging channel
  +    * @param system the system context
  +    * @param classloader the parent classloader
  +    * @param parent the parent classloader model
       * @param directive the classloader directive containing the 
       *    primative classpath entries and resource directives
       */
       protected DefaultClassLoaderModel( 
  -      final Logger logger, final SystemContext system, ClassLoaderModel parent, ClassLoaderDirective directive )
  +      final Logger logger, final SystemContext system, 
  +      ClassLoaderModel parent, ClassLoaderDirective directive )
         throws Exception
       {
  +        if( logger == null )
  +        {
  +            throw new NullPointerException( "logger" );
  +        }
  +        if( system == null )
  +        {
  +            throw new NullPointerException( "system" );
  +        }
           if( parent == null )
           {
               throw new NullPointerException( "parent" );
           }
  -
           if( directive == null )
           {
               throw new NullPointerException( "directive" );
           }
   
           m_logger = logger;
  -        m_repository = system.getRepository();
  -        m_base = system.getBaseDirectory();
           m_parent = parent;
   
           DefaultExtensionManager local = 
             new DefaultExtensionManager( 
  -            directive.getLibrary().getOptionalExtensionDirectories( m_base ) );
  +            directive.getLibrary().getOptionalExtensionDirectories( system.getBaseDirectory() ) );
           m_extension = new DelegatingExtensionManager(
             new ExtensionManager[]{ parent.getExtensionManager(), local } );
           m_manager = new PackageManager( m_extension );
  -        m_directive = directive;
   
           //
           // generate the primitive classpath
           //
   
  -        m_classpath = createClassPath();
  +        m_classpath = createClassPath( system, directive );
           m_packages = buildOptionalPackages( 
             m_classpath, parent.getOptionalPackages( true ) );
           m_urls = buildQualifiedClassPath();
  +        m_classLoader = new URLClassLoader( 
  +          m_urls, parent.getClassLoader() );
  +
  +        //
  +        // create a type repository
  +        //
  +
  +        m_types = 
  +          new DefaultTypeRepository( 
  +            m_classLoader, parent.getTypeRepository() );
  +        m_types.enableLogging( logger.getChildLogger( "type" ) );
  +
       }
   
       //==============================================================
  @@ -235,15 +271,14 @@
       //==============================================================
   
      /**
  -    * Return the fully qualified classpath including extension jar files
  -    * resolved relative to the classpath directives in the meta-data
  -    * and any parent classloader models.
  +    * Return the type repository managed by this containment
  +    * context.
       *
  -    * @return an array of URL representing the complete classpath 
  +    * @return the repository
       */
  -    public URL[] getQualifiedClassPath()
  +    public TypeRepository getTypeRepository()
       {
  -        return m_urls;
  +        return m_types;
       }
   
      /**
  @@ -297,27 +332,25 @@
           return (OptionalPackage[]) list.toArray( new OptionalPackage[0] );
       }
   
  -    //==============================================================
  -    // protected implementation
  -    //==============================================================
  -
      /**
  -    * Return the base directory from which any relative file references
  -    * shall be resolved.
  -    * @return the base directory
  +    * Return the fully qualified classpath including extension jar files
  +    * resolved relative to the classpath directives in the meta-data
  +    * and any parent classloader models.
  +    *
  +    * @return an array of URL representing the complete classpath 
       */
  -    protected File getBaseDirectory()
  +    public URL[] getQualifiedClassPath()
       {
  -        return m_base;
  +        return m_urls;
       }
   
      /**
  -    * Return the system wide jar file repository.
  -    * @return the repository
  +    * Return the classloader established by this classloader model.
  +    * @return the classloader
       */
  -    protected Repository getRepository()
  +    public ClassLoader getClassLoader()
       {
  -        return m_repository;
  +        return m_classLoader;
       }
   
       //==============================================================
  @@ -352,15 +385,17 @@
           return m_classpath;
       }
   
  -    private String[] createClassPath()
  +    private String[] createClassPath( SystemContext system, ClassLoaderDirective directive )
         throws Exception
       {
           ArrayList classpath = new ArrayList();
           addToClassPath( 
  -          classpath, m_directive.getClasspathDirective().expandFileSetDirectives( m_base ) );
  +          classpath, 
  +          directive.getClasspathDirective().expandFileSetDirectives( 
  +            system.getBaseDirectory() ) );
   
           RepositoryDirective[] repositories = 
  -          m_directive.getClasspathDirective().getRepositoryDirectives();
  +          directive.getClasspathDirective().getRepositoryDirectives();
           for( int i=0; i<repositories.length; i++ )
           {
               ResourceDirective[] resources = repositories[i].getResources();
  @@ -369,7 +404,7 @@
                   ResourceDirective resource = resources[j];
                   String id = resource.getId();
                   String version = resource.getVersion();
  -                URL url = m_repository.getArtifact( id, version, "jar" );
  +                URL url = system.getRepository().getArtifact( id, version, "jar" );
                   classpath.add( url.toString() );
               }
           }
  
  
  
  1.2       +9 -16     avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultCompositionModel.java
  
  Index: DefaultCompositionModel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultCompositionModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultCompositionModel.java	4 Jul 2003 07:27:35 -0000	1.1
  +++ DefaultCompositionModel.java	4 Jul 2003 15:24:55 -0000	1.2
  @@ -52,6 +52,7 @@
   
   import java.io.File;
   
  +import org.apache.avalon.composition.model.ClassLoaderModel;
   import org.apache.avalon.composition.model.CompositionModel;
   import org.apache.avalon.composition.model.ContainmentModel;
   import org.apache.avalon.composition.model.ModelException;
  @@ -82,7 +83,7 @@
       //==============================================================
   
       private static final Resources REZ =
  -            ResourceManager.getPackageResources( CompositionModel.class );
  +            ResourceManager.getPackageResources( DefaultCompositionModel.class );
   
       //==============================================================
       // state
  @@ -110,7 +111,7 @@
       * @param directive the composition profile
       */
       protected DefaultCompositionModel( 
  -      final Logger logger, SystemContext system, ClassLoader classloader, 
  +      final Logger logger, SystemContext system, ClassLoaderModel classLoaderModel,  
         CompositionProfile profile )
         throws Exception
       {
  @@ -123,7 +124,7 @@
           {
               m_implementation = 
                 new DefaultContainmentModel( 
  -                logger, system, profile.getImplementation() );
  +                logger, system, classLoaderModel, profile.getImplementation() );
           }
           catch( Throwable e )
           {
  @@ -146,7 +147,8 @@
       * @param profile the composition profile
       */
       protected DefaultCompositionModel( 
  -      final Logger logger, SystemContext system, DefaultContainmentModel parent, CompositionProfile profile )
  +      final Logger logger, SystemContext system, ClassLoaderModel classLoaderModel, 
  +      ContainmentModel parent, CompositionProfile profile )
         throws Exception
       {
           super( 
  @@ -154,7 +156,7 @@
             profile.getName(), 
             parent.getPath() + profile.getName() + ContainmentModel.SEPERATOR );
   
  -        m_system = parent.getSystemContext();
  +        m_system = system;
           m_profile = profile;
   
           try
  @@ -164,6 +166,7 @@
                   logger,
                   system,
                   parent, 
  +                classLoaderModel,
                   profile.getImplementation() );
           }
           catch( Throwable e )
  @@ -210,18 +213,8 @@
       // protected implementation
       //==============================================================
   
  -   /**
  -    * Return the system context used as the context for model establishment.
  -    * @return the system context
  -    */
  -    protected SystemContext getSystemContext()
  -    {
  -        return m_system;
  -    }
  -
       public String toString()
       {
           return "[composition: " + getPath() + "]";
       }
  -
   }
  
  
  
  1.2       +20 -12    avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultCompositionModelFactory.java
  
  Index: DefaultCompositionModelFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultCompositionModelFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultCompositionModelFactory.java	4 Jul 2003 07:27:36 -0000	1.1
  +++ DefaultCompositionModelFactory.java	4 Jul 2003 15:24:55 -0000	1.2
  @@ -52,6 +52,7 @@
   
   import java.io.File;
   
  +import org.apache.avalon.composition.model.ClassLoaderModel;
   import org.apache.avalon.composition.model.CompositionModel;
   import org.apache.avalon.composition.model.CompositionModelFactory;
   import org.apache.avalon.composition.model.ModelException;
  @@ -112,23 +113,30 @@
           final Logger logger = getLogger();
           try
           {
  -            if( classloader == null )
  -            {
  -                ClassLoader loader = Thread.currentThread().getContextClassLoader();
  -                return new DefaultCompositionModel(
  -                  logger, system, loader, profile );
  -            }
  -            else
  -            {
  -                return new DefaultCompositionModel(
  -                  logger, system, classloader, profile );
  -            }
  +            ClassLoader loader = getClassLoader( classloader );
  +            ClassLoaderModel classLoaderModel = new DefaultClassLoaderModel( 
  +              logger.getChildLogger("classloader"), system, loader,
  +              profile.getImplementation().getClassLoaderDirective() );
  +            return new DefaultCompositionModel(
  +                  logger, system, classLoaderModel, profile );
           }
           catch( Throwable e )
           {
               final String error = 
                 "Unable to construct a new composition model.";
               throw new ModelException( error, e );
  +        }
  +    }
  +
  +    private ClassLoader getClassLoader( ClassLoader classloader )
  +    {
  +        if( classloader == null )
  +        {
  +            return Thread.currentThread().getContextClassLoader();
  +        }
  +        else
  +        {
  +            return classloader;
           }
       }
   }
  
  
  
  1.2       +23 -107   avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java
  
  Index: DefaultContainmentModel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultContainmentModel.java	4 Jul 2003 07:27:37 -0000	1.1
  +++ DefaultContainmentModel.java	4 Jul 2003 15:24:55 -0000	1.2
  @@ -64,7 +64,6 @@
   import org.apache.avalon.composition.model.Model;
   import org.apache.avalon.composition.model.ModelException;
   import org.apache.avalon.composition.model.SystemContext;
  -import org.apache.avalon.composition.model.TypeRepository;
   import org.apache.avalon.composition.repository.Repository;
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
  @@ -96,16 +95,10 @@
       // state
       //==============================================================
   
  -    private final ContainmentModel m_parent;
  -
       private final ContainmentProfile m_profile;
   
       private final ClassLoaderModel m_classLoaderModel;
   
  -    private final URLClassLoader m_classLoader;
  -
  -    private final DefaultTypeRepository m_types;
  -
       private List m_models = new ArrayList();
   
       //==============================================================
  @@ -125,44 +118,13 @@
       * @param profile the composition profile
       */
       public DefaultContainmentModel( 
  -      final Logger logger, SystemContext system, ContainmentProfile profile )
  +      final Logger logger, SystemContext system, ClassLoaderModel classLoaderModel, ContainmentProfile profile )
         throws Exception
       {
  -        super( logger, system, profile, SEPERATOR );
  -
  +        super( logger, system, classLoaderModel.getClassLoader(), profile, SEPERATOR );
           m_profile = profile;
  -        m_parent = null;
  -        try
  -        {
  -            m_classLoaderModel = 
  -              new DefaultClassLoaderModel( 
  -                logger.getChildLogger("classloader"), 
  -                getSystemContext(), 
  -                profile.getClassLoaderDirective() );
  -
  -            URL[] classpath = m_classLoaderModel.getQualifiedClassPath();
  -            m_classLoader = new URLClassLoader( classpath, super.getClassLoader() );
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              REZ.getString( "error.composition.classloader.create", getPath() );
  -            throw new ModelException( error, e );
  -        }
  -
  -        //
  -        // create a type repository
  -        //
  -
  -        m_types = new DefaultTypeRepository( m_classLoader );
  -        m_types.enableLogging( getLogger().getChildLogger( "type" ) );
  -
  -        //
  -        // create the nested profiles
  -        //
  -
  -        expand();
  -
  +        m_classLoaderModel = classLoaderModel;
  +        expandContainmentModel( system );
       }
   
      /**
  @@ -178,53 +140,18 @@
       * @param directive the composition profile
       */
       public DefaultContainmentModel( 
  -      final Logger logger, SystemContext system, ContainmentModel parent, ContainmentProfile profile )
  +      final Logger logger, SystemContext system, ContainmentModel parent, 
  +      ClassLoaderModel classLoaderModel, ContainmentProfile profile )
         throws Exception
       {
  -        super( logger, system, profile, 
  +        super( logger, system, classLoaderModel.getClassLoader(), profile, 
              parent.getPath() + profile.getName() + SEPERATOR );
  -
           m_profile = profile;
  -        m_parent = parent;
  -
  -        try
  -        {
  -            ClassLoaderModel ancestor = parent.getClassLoaderModel();
  -            m_classLoaderModel = 
  -              new DefaultClassLoaderModel( 
  -                logger.getChildLogger("classloader"), 
  -                getSystemContext(), 
  -                ancestor, 
  -                profile.getClassLoaderDirective() );
  -            URL[] classpath = m_classLoaderModel.getQualifiedClassPath();
  -            m_classLoader = 
  -              new URLClassLoader( 
  -                classpath, parent.getClassLoader() );
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              REZ.getString( "error.composition.classloader.create", getPath() );
  -            throw new ModelException( error, e );
  -        }
  -
  -        //
  -        // create a type repository
  -        //
  -
  -        m_types = 
  -          new DefaultTypeRepository( 
  -            parent.getClassLoader(), parent.getTypeRepository() );
  -        m_types.enableLogging( getLogger().getChildLogger( "type" ) );
  -
  -        //
  -        // create the nested profiles
  -        //
  -
  -        expand();
  +        m_classLoaderModel = classLoaderModel;
  +        expandContainmentModel( system );
       }
   
  -    private void expand() throws ModelException
  +    private void expandContainmentModel( SystemContext system ) throws ModelException
       {
   
           getLogger().debug( "expanding: " + this );
  @@ -243,7 +170,11 @@
                           CompositionModel model = 
                             new DefaultCompositionModel( 
                               getLogger().getChildLogger( profile.getName() ),
  -                            getSystemContext(),
  +                            system,
  +                            new DefaultClassLoaderModel( 
  +                              getLogger().getChildLogger("classloader"), 
  +                              system, m_classLoaderModel, 
  +                              composition.getImplementation().getClassLoaderDirective() ),
                               this, 
                               composition );
                           m_models.add( model );
  @@ -269,8 +200,12 @@
                           ContainmentModel model = 
                             new DefaultContainmentModel( 
                               getLogger().getChildLogger( profile.getName() ),
  -                            getSystemContext(),
  +                            system,
                               this, 
  +                            new DefaultClassLoaderModel( 
  +                              getLogger().getChildLogger("classloader"), 
  +                              system, m_classLoaderModel, 
  +                              containment.getClassLoaderDirective() ),
                               containment );
                           m_models.add( model );
                       }
  @@ -292,7 +227,8 @@
                           DeploymentModel model = 
                             new DefaultDeploymentModel( 
                               getLogger().getChildLogger( profile.getName() ),
  -                            getSystemContext(),
  +                            system,
  +                            m_classLoaderModel.getClassLoader(),
                               deployment,
                               getPath() );
                           m_models.add( model );
  @@ -326,15 +262,6 @@
       //==============================================================
       // public implementation
       //==============================================================
  -
  -   /**
  -    * Return the classloader for this containment context.
  -    * @return the classloader
  -    */
  -    public ClassLoader getClassLoader()
  -    {
  -        return m_classLoader;
  -    }
    
      /**
       * Return the classloader model.
  @@ -352,17 +279,6 @@
       public Model[] getNestedModels()
       {
           return (Model[]) m_models.toArray( new Model[0] );
  -    }
  -
  -   /**
  -    * Return the type repository managed by this containment
  -    * context.
  -    *
  -    * @return the repository
  -    */
  -    public TypeRepository getTypeRepository()
  -    {
  -        return m_types;
       }
   
       //==============================================================
  
  
  
  1.2       +55 -21    avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentModel.java
  
  Index: DefaultDeploymentModel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultDeploymentModel.java	4 Jul 2003 07:27:37 -0000	1.1
  +++ DefaultDeploymentModel.java	4 Jul 2003 15:24:55 -0000	1.2
  @@ -55,9 +55,11 @@
   import org.apache.avalon.composition.model.DeploymentModel;
   import org.apache.avalon.composition.model.SystemContext;
   import org.apache.avalon.composition.repository.Repository;
  -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.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.meta.data.DeploymentProfile;
   
   
  @@ -77,13 +79,24 @@
               ResourceManager.getPackageResources( DefaultDeploymentModel.class );
   
       //==============================================================
  -    // state
  +    // immutable state
       //==============================================================
   
       private final SystemContext m_system;
   
       private final DeploymentProfile m_profile;
   
  +    private final Class m_class;
  +
  +
  +    //==============================================================
  +    // mutable state
  +    //==============================================================
  +
  +    private ClassLoader m_classLoader;
  +
  +    private Configuration m_config = null;
  +
       //==============================================================
       // constructor
       //==============================================================
  @@ -99,13 +112,35 @@
       * @param path the partition name
       */
       public DefaultDeploymentModel( 
  -      final Logger logger, final SystemContext system, 
  +      final Logger logger, final SystemContext system, ClassLoader classLoader,
         final DeploymentProfile profile, String path )
         throws Exception
       {
           super( logger, profile.getName(), path );
  +        if( system == null )
  +        {
  +            throw new NullPointerException( "system" );
  +        }
  +        if( classLoader == null )
  +        {
  +            throw new NullPointerException( "classLoader" );
  +        }
  +        if( path == null )
  +        {
  +            throw new NullPointerException( "path" );
  +        }
  +
           m_system = system;
           m_profile = profile;
  +        m_classLoader = classLoader;
  +        if( profile.getClassname() == null )
  +        {
  +            m_class = NullComponent.class;
  +        }
  +        else
  +        {
  +            m_class = m_classLoader.loadClass( profile.getClassname() );
  +        }
       }
   
       //==============================================================
  @@ -115,35 +150,34 @@
       //==============================================================
   
      /**
  -    * Return the classloader for this containment context.
  -    * @return the classloader
  +    * Return the class for the deployable target.
  +    * @return the class
       */
  -    public ClassLoader getClassLoader()
  +    public Class getDeploymentClass()
       {
  -        return Thread.currentThread().getContextClassLoader();
  +        return m_class;
       }
   
      /**
  -    * Return the class for the deployable object.
  -    * @return the class
  +    * Return the configuration to be applied to the component.
  +    * The implementation returns the current configuration state.
  +    * If the the component type does not implementation the 
  +    * Configurable interface, the implementation returns null. 
  +    *
  +    * @return the qualified configuration
       */
  -    public Class getDeploymentClass() throws ClassNotFoundException
  +    public Configuration getConfiguration()
       {
  -        return getClassLoader().loadClass( m_profile.getClassname() );
  +        if( Configurable.class.isAssignableFrom( getDeploymentClass() ) )
  +        {
  +            //Configuration config = getType().getConfiguration();
  +        }
  +        return null;
       }
   
       //==============================================================
       // protected implementation
       //==============================================================
  -
  -   /**
  -    * Return the system wide jar file repository.
  -    * @return the repository
  -    */
  -    protected SystemContext getSystemContext()
  -    {
  -        return m_system;
  -    }
   
       public String toString()
       {
  
  
  
  1.2       +0 -1      avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/Resources.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Resources.properties	4 Jul 2003 07:27:40 -0000	1.1
  +++ Resources.properties	4 Jul 2003 15:24:55 -0000	1.2
  @@ -46,4 +46,3 @@
   error.composition.implementation.create=Unable to create implementation model: {0}
   error.containment.composition.create=Unable to create composition model: {0}
   error.containment.deployment.create=Unable to create deployment model: {0}
  -
  
  
  
  1.2       +22 -1     avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/ClassLoaderModel.java
  
  Index: ClassLoaderModel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/ClassLoaderModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ClassLoaderModel.java	4 Jul 2003 07:28:19 -0000	1.1
  +++ ClassLoaderModel.java	4 Jul 2003 15:24:55 -0000	1.2
  @@ -66,6 +66,13 @@
   public interface ClassLoaderModel
   {
      /**
  +    * Return the classloader model type repository.
  +    *
  +    * @return the repository
  +    */
  +    TypeRepository getTypeRepository();
  +
  +   /**
       * Return the optional extensions manager.
       * @return the extension manager
       */
  @@ -95,4 +102,18 @@
       * @return an array of URL representing the qualified classpath 
       */
       URL[] getQualifiedClassPath();
  +
  +   /**
  +    * Return the classloader for a containment context.
  +    * An implementation is required to fulfill the the 
  +    * criteria expressed by the associated classloader 
  +    * directive, and, deliver support for any optional  
  +    * extension criteria expressed within a jar manifest
  +    * in accordance with the Java Optional Extensions 
  +    * specification.
  +    *
  +    * @return the classloader
  +    */
  +    ClassLoader getClassLoader();
  +
   }
  
  
  
  1.2       +1 -21     avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/ContainmentModel.java
  
  Index: ContainmentModel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/ContainmentModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContainmentModel.java	4 Jul 2003 07:28:20 -0000	1.1
  +++ ContainmentModel.java	4 Jul 2003 15:24:55 -0000	1.2
  @@ -63,18 +63,6 @@
   {
       public static String SEPERATOR = "/";
   
  -   /**
  -    * Return the classloader for this containment context.
  -    * An implementation is required to fulfill the the 
  -    * criteria expressed by the associated classloader 
  -    * directive, and, deliver support for any optional  
  -    * extension criteria expressed within a jar manifest
  -    * in accordance with the Java Optional Extensions 
  -    * specification.
  -    *
  -    * @return the classloader
  -    */
  -    ClassLoader getClassLoader();
    
      /**
       * Return the classloader model assigned to this 
  @@ -89,13 +77,5 @@
       * @return the classloader model
       */
       Model[] getNestedModels();
  -
  -   /**
  -    * Return the type repository managed by the containment
  -    * context.
  -    *
  -    * @return the repository
  -    */
  -    public TypeRepository getTypeRepository();
   
   }
  
  
  
  1.2       +14 -11    avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/DeploymentModel.java
  
  Index: DeploymentModel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/DeploymentModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeploymentModel.java	4 Jul 2003 07:28:20 -0000	1.1
  +++ DeploymentModel.java	4 Jul 2003 15:24:55 -0000	1.2
  @@ -50,6 +50,9 @@
   
   package org.apache.avalon.composition.model;
   
  +import org.apache.avalon.framework.configuration.Configuration;
  +
  +
   /**
    * Deployment model defintion.
    *
  @@ -59,18 +62,18 @@
   public interface DeploymentModel extends Model
   {
      /**
  -    * Return the classloader for this deployment context.
  -    * @return the classloader
  -    */
  -    ClassLoader getClassLoader();
  -
  -   /**
       * Return the class for the deployable target.
       * @return the class
       */
  -    Class getDeploymentClass() throws ClassNotFoundException;
  +    Class getDeploymentClass();
   
  -    //
  -    // add logging, context, configuration, parameters, import, export
  -    //
  +   /**
  +    * Return the configuration to be applied to the component.
  +    * The implementation returns the current configuration state.
  +    * If the the component type does not implementation the 
  +    * Configurable interface, the implementation returns null. 
  +    *
  +    * @return the qualified configuration
  +    */
  +    Configuration getConfiguration();
   }
  
  
  

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