mcconnell    2003/07/07 01:31:20

  Modified:    merlin/composition/src/java/org/apache/avalon/composition/model/impl
                        DefaultClassLoaderModel.java
                        DefaultContainmentModel.java
                        DefaultDeploymentModel.java DefaultModel.java
                        DefaultTypeRepository.java Resources.properties
                        Scanner.java
               merlin/composition-spi/src/java/org/apache/avalon/composition/model
                        ContainmentModel.java Model.java
                        TypeRepository.java
               merlin/merlin-extensions .cvsignore
               merlin/meta/src/java/org/apache/avalon/meta/data/builder
                        ProfilePackageBuilder.java
                        ProfilePackageCreator.java
                        SerializedProfilePackageCreator.java
                        XMLDeploymentProfileCreator.java
                        XMLProfilePackageCreator.java
               merlin/meta/src/java/org/apache/avalon/meta/info/builder
                        TypeBuilder.java
               merlin/meta-spi/src/java/org/apache/avalon/meta/data
                        ContainmentProfile.java DeploymentProfile.java
                        Profile.java ProfilePackage.java
  Added:       merlin/composition/src/java/org/apache/avalon/composition/model/impl
                        DefaultModelSelector.java
               merlin/composition-spi/src/java/org/apache/avalon/composition/model
                        Consumer.java ModelSelector.java Producer.java
  Removed:     merlin/composition-spi/src/java/org/apache/avalon/composition/model
                        ProfileRepository.java ProfileSelector.java
  Log:
  Move selection semantics from the profile level to the model level.
  
  Revision  Changes    Path
  1.7       +3 -22     
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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultClassLoaderModel.java      6 Jul 2003 10:08:16 -0000       1.6
  +++ DefaultClassLoaderModel.java      7 Jul 2003 08:31:18 -0000       1.7
  @@ -53,6 +53,8 @@
   import java.io.File;
   import java.io.IOException;
   import java.util.ArrayList;
  +import java.util.Map;
  +import java.util.Hashtable;
   import java.util.List;
   import java.util.jar.Manifest;
   import java.net.JarURLConnection;
  @@ -180,25 +182,6 @@
       *
       * @param logger the assigned logging channel
       * @param system the system context
  -    * @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 )
  -    //  throws Exception
  -    //{
  -    //    this( logger, system, parent.getClassLoader(), parent, directive );
  -    //}
  -
  -   /**
  -    * Creation of a new classloader model.  The model associated a 
  -    * repository, a base directory and a classloader directive 
  -    * enabling the creation of a fully populated classpath.
  -    *
  -    * @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 
  @@ -272,11 +255,9 @@
   
           ArrayList types = new ArrayList();
           ArrayList services = new ArrayList();
  -
           Scanner scanner = new Scanner( classLoader );
           scanner.enableLogging( logger.getChildLogger( "scanner" ) );
           scanner.scan( m_urls, types, services );
  -
           Logger typeLogger = logger.getChildLogger( "types" );
           Logger serviceLogger = logger.getChildLogger( "services" );
           if( parent != null )
  
  
  
  1.7       +52 -13    
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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultContainmentModel.java      6 Jul 2003 10:08:16 -0000       1.6
  +++ DefaultContainmentModel.java      7 Jul 2003 08:31:18 -0000       1.7
  @@ -71,7 +71,9 @@
   import org.apache.avalon.meta.data.DeploymentProfile;
   import org.apache.avalon.meta.data.Profile;
   import org.apache.avalon.meta.data.ServiceDirective;
  +import org.apache.avalon.meta.info.ServiceDescriptor;
   import org.apache.avalon.meta.info.DependencyDescriptor;
  +import org.apache.avalon.meta.info.StageDescriptor;
   
   
   /**
  @@ -124,7 +126,7 @@
         ContainmentProfile profile )
         throws Exception
       {
  -        super( logger, "", SEPERATOR );
  +        super( logger, SEPERATOR, "", profile.getMode() );
           m_partition = SEPERATOR;
           m_profile = profile;
           m_classLoaderModel = classLoaderModel;
  @@ -148,7 +150,7 @@
         ClassLoaderModel classLoaderModel, ContainmentProfile profile )
         throws Exception
       {
  -        super( logger, profile.getName(), parent.getPartition() );
  +        super( logger, parent.getPartition(), profile.getName(), profile.getMode() 
);
   
           m_partition = getPath() + getName() + SEPERATOR;
           m_profile = profile;
  @@ -186,7 +188,53 @@
       }
   
       //==============================================================
  -    // public implementation
  +    // Producer
  +    //==============================================================
  +
  +   /**
  +    * Return the set of services produced by the model.
  +    * @return the services
  +    */
  +    public ServiceDescriptor[] getServices()
  +    {
  +        return getServiceDirectives();
  +    }
  +
  +   /**
  +    * Return TRUE is this model is capable of supporting a supplied 
  +    * depedendency.
  +    * @return true if this model can fulfill the dependency
  +    */
  +    public boolean isaCandidate( DependencyDescriptor dependency )
  +    {
  +        return false; 
  +    }
  +
  +   /**
  +    * Return TRUE is this model is capable of supporting a supplied 
  +    * stage dependency.
  +    * @return true if this model can fulfill the dependency
  +    */
  +    public boolean isaCandidate( StageDescriptor stage )
  +    {
  +        return false;
  +    }
  +
  +    //==============================================================
  +    // Consumer
  +    //==============================================================
  +
  +   /**
  +    * Return the set of services that this model consumes.
  +    * @return the cumsumed depedencies
  +    */
  +    public DependencyDescriptor[] getDependencies()
  +    {
  +        return m_profile.getDependencies();
  +    }
  +
  +    //==============================================================
  +    // ContainmentModel
       //==============================================================
   
      /**
  @@ -273,15 +321,6 @@
           return m_profile.getServiceDirectives();
       }
   
  -   /**
  -    * Return the set of dependencies
  -    * @return the block implementation model
  -    */
  -    public DependencyDescriptor[] getDependencies()
  -    {
  -        return m_profile.getDependencies();
  -    }
  - 
      /**
       * Return the classloader model.
       * @return the classloader model
  
  
  
  1.7       +54 -3     
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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultDeploymentModel.java       6 Jul 2003 10:08:16 -0000       1.6
  +++ DefaultDeploymentModel.java       7 Jul 2003 08:31:18 -0000       1.7
  @@ -51,8 +51,9 @@
   package org.apache.avalon.composition.model.impl;
   
   import java.io.File;
  -import java.util.Properties;
  +import java.util.ArrayList;
   import java.util.Enumeration;
  +import java.util.Properties;
   
   import org.apache.avalon.composition.model.DeploymentModel;
   import org.apache.avalon.composition.model.ClassLoaderModel;
  @@ -66,7 +67,11 @@
   import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.meta.data.DeploymentProfile;
  +import org.apache.avalon.meta.data.Mode;
   import org.apache.avalon.meta.info.Type;
  +import org.apache.avalon.meta.info.ServiceDescriptor;
  +import org.apache.avalon.meta.info.StageDescriptor;
  +import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.builder.TypeBuilder;
   import org.apache.excalibur.configuration.CascadingConfiguration;
   
  @@ -128,7 +133,7 @@
         final DeploymentProfile profile, String path )
         throws Exception
       {
  -        super( logger, profile.getName(), path );
  +        super( logger, path, profile.getName(), profile.getMode() );
           if( classLoaderModel == null )
           {
               throw new NullPointerException( "classLoaderModel" );
  @@ -179,6 +184,52 @@
                   m_parameters = Parameters.EMPTY_PARAMETERS;
               }
           }
  +    }
  +
  +    //==============================================================
  +    // Producer
  +    //==============================================================
  +
  +   /**
  +    * Return the set of services produced by the model.
  +    * @return the services
  +    */
  +    public ServiceDescriptor[] getServices()
  +    {
  +        return getType().getServices();
  +    }
  +
  +   /**
  +    * Return TRUE is this model is capable of supporting a supplied 
  +    * depedendency.
  +    * @return true if this model can fulfill the dependency
  +    */
  +    public boolean isaCandidate( DependencyDescriptor dependency )
  +    {
  +        return getType().getService( dependency.getReference() ) != null;
  +    }
  +
  +   /**
  +    * Return TRUE is this model is capable of supporting a supplied 
  +    * stage dependency.
  +    * @return true if this model can fulfill the dependency
  +    */
  +    public boolean isaCandidate( StageDescriptor stage )
  +    {
  +        return getType().getExtension( stage ) != null;
  +    }
  +
  +    //==============================================================
  +    // Consumer
  +    //==============================================================
  +
  +   /**
  +    * Return the set of services that this model consumes.
  +    * @return the cumsumed depedencies
  +    */
  +    public DependencyDescriptor[] getDependencies()
  +    {
  +        return getType().getDependencies();
       }
   
       //==============================================================
  
  
  
  1.4       +16 -6     
avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultModel.java
  
  Index: DefaultModel.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultModel.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultModel.java 6 Jul 2003 04:07:52 -0000       1.3
  +++ DefaultModel.java 7 Jul 2003 08:31:18 -0000       1.4
  @@ -50,13 +50,11 @@
   
   package org.apache.avalon.composition.model.impl;
   
  -import java.io.File;
  -
   import org.apache.avalon.composition.model.Model;
   import org.apache.avalon.framework.logger.Logger;
  -import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  +import org.apache.avalon.meta.data.Mode;
   
   
   /**
  @@ -84,6 +82,8 @@
   
       private final Logger m_logger;
   
  +    private final Mode m_mode;
  +
       //==============================================================
       // constructor
       //==============================================================
  @@ -92,16 +92,17 @@
       * Creation of an abstract model.  The model associated a 
       * name and a partition.
       *
  -    * @param name the profile name
       * @param path the profile partition
  +    * @param name the profile name
       */
       public DefaultModel( 
  -      final Logger logger, final String name, String path )
  +      final Logger logger, String path, final String name, Mode mode )
         throws Exception
       {
           m_logger = logger;
           m_name = name;
           m_path = path;
  +        m_mode = mode;
   
           if( getLogger().isDebugEnabled() )
           {
  @@ -131,6 +132,15 @@
       public String getPath()
       {
           return m_path;
  +    }
  +
  +   /**
  +    * Return the mode of establishment.
  +    * @return the mode
  +    */
  +    public Mode getMode()
  +    {
  +        return m_mode;
       }
   
       //==============================================================
  
  
  
  1.5       +56 -10    
avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultTypeRepository.java
  
  Index: DefaultTypeRepository.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultTypeRepository.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultTypeRepository.java        6 Jul 2003 03:00:25 -0000       1.4
  +++ DefaultTypeRepository.java        7 Jul 2003 08:31:18 -0000       1.5
  @@ -65,6 +65,10 @@
   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.ProfilePackage;
  +import org.apache.avalon.meta.data.Profile;
  +import org.apache.avalon.meta.data.DeploymentProfile;
  +import org.apache.avalon.meta.data.builder.ProfilePackageBuilder;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.ReferenceDescriptor;
   import org.apache.avalon.meta.info.ServiceDescriptor;
  @@ -104,6 +108,12 @@
           }
       }
   
  +    /**
  +     * The profile builder.
  +     */
  +    private static final ProfilePackageBuilder PACKAGE_BUILDER = 
  +      new ProfilePackageBuilder();
  +
       //==============================================================
       // immutable state
       //==============================================================
  @@ -122,6 +132,11 @@
        */
       private final Hashtable m_types = new Hashtable();
   
  +    /**
  +     * Table of packaged profiles keyed by implementation classname.
  +     */
  +    private final Hashtable m_profiles = new Hashtable();
  +
       //==============================================================
       // constructor
       //==============================================================
  @@ -132,6 +147,7 @@
        * @exception NullPointerException if the type list is null
        */
       public DefaultTypeRepository( Logger logger, ClassLoader classloader, List 
types )
  +      throws Exception
       {
           this( logger, classloader, null, types );
       }
  @@ -144,7 +160,7 @@
        */
       public DefaultTypeRepository( 
         final Logger logger, final ClassLoader classloader, final TypeRepository 
parent, 
  -      final List types )
  +      final List types ) throws Exception
       {
           if( types == null )
           {
  @@ -188,20 +204,20 @@
           {
               Type type = (Type) iterator.next();
               final String classname = type.getInfo().getClassname();
  +            Class clazz = m_classloader.loadClass( classname );
   
  -            //
  -            // we should add a test to make sure that the type is 
  -            // not already defined in parent or locally
  -            //
  +            ProfilePackage pack = 
  +              PACKAGE_BUILDER.createProfilePackage( clazz );
  +            m_profiles.put( classname, pack );
  +            int n = pack.getDeploymentProfiles().length;
   
  +            m_types.put( classname, type );
               if( getLogger().isDebugEnabled() )
               {
                   final String message = 
  -                  REZ.getString( "type.repository.addition", classname );
  +                  REZ.getString( "type.repository.addition", classname, new 
Integer( n ) );
                   getLogger().debug( "add: " + classname );
               }
  -
  -            m_types.put( classname, type );
           }
       }
   
  @@ -210,7 +226,7 @@
       //==============================================================
   
       /**
  -     * Return all availble types.
  +     * Return all available types.
        * @return the array of types
        */
       public Type[] getTypes()
  @@ -366,6 +382,36 @@
           }
   
           return (Type[]) list.toArray( new Type[0] );
  +    }
  +
  +   /**
  +    * Return the set of deployment profiles for the supplied type. An 
  +    * implementation is required to return a array of types > 0 in length
  +    * or throw a TypeUnknownException.
  +    * @param type the type
  +    * @return a profile array containing at least one deployment profile
  +    * @exception TypeUnknownException if the supplied type is unknown
  +    */
  +    public DeploymentProfile[] getProfiles( Type type ) 
  +      throws TypeUnknownException
  +    {
  +        final String classname = type.getInfo().getClassname();
  +        ProfilePackage profiles = (ProfilePackage) m_profiles.get( classname );
  +        if( profiles != null )
  +        {
  +            return profiles.getDeploymentProfiles();
  +        }
  +        else
  +        {
  +            if( m_parent != null )
  +            {
  +                return m_parent.getProfiles( type );
  +            }
  +            else
  +            {
  +                throw new TypeUnknownException( classname );
  +            }
  +        }
       }
   
       protected Logger getLogger()
  
  
  
  1.6       +1 -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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Resources.properties      6 Jul 2003 10:08:16 -0000       1.5
  +++ Resources.properties      7 Jul 2003 08:31:18 -0000       1.6
  @@ -30,7 +30,7 @@
   type.repository.null-create.error=Internal error while creating NullComponent type 
defintion. {0}
   type.repository.bootstrap.error=bootstrap: {0}
   type.repository.count=type install count: {0}
  -type.repository.addition=add: {0}
  +type.repository.addition=add: {0}, ({1}).
   
   #Scanner
   scanner.scanning=scanning: {0}
  
  
  
  1.3       +18 -6     
avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/Scanner.java
  
  Index: Scanner.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/Scanner.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Scanner.java      6 Jul 2003 03:00:25 -0000       1.2
  +++ Scanner.java      7 Jul 2003 08:31:18 -0000       1.3
  @@ -64,6 +64,7 @@
   import java.util.ArrayList;
   import java.util.Enumeration;
   import java.util.List;
  +import java.util.Map;
   import java.util.jar.JarFile;
   import java.util.jar.JarInputStream;
   import java.util.zip.ZipEntry;
  @@ -74,6 +75,8 @@
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.meta.data.Profile;
  +import org.apache.avalon.meta.data.ProfilePackage;
  +import org.apache.avalon.meta.data.builder.ProfilePackageBuilder;
   import org.apache.avalon.meta.info.Service;
   import org.apache.avalon.meta.info.ServiceDescriptor;
   import org.apache.avalon.meta.info.Type;
  @@ -116,6 +119,12 @@
       private static final ServiceBuilder SERVICE_BUILDER = 
         new ServiceBuilder();
   
  +    /**
  +     * The packaged profile builder.
  +     */
  +    private static final ProfilePackageBuilder PACKAGE_BUILDER = 
  +      new ProfilePackageBuilder();
  +
       //===================================================================
       // state
       //===================================================================
  @@ -152,8 +161,9 @@
       /**
        * Scan the supplied url for Service and Type defintions.
        * @param urls the URL array to scan
  -     * @return an object array containing [EMAIL PROTECTED] Service} and 
  -     *   [EMAIL PROTECTED] Type} instances
  +     * @param types the map to populate with types as keys and 
  +     *   and packaged profiles as values
  +     * @param services a list to be populated with service descriptors
        */
       public void scan( URL[] urls, List types, List services ) throws ModelException
       {
  @@ -361,10 +371,12 @@
           }
       }
   
  -    private void addType( List list, String name ) throws Exception
  +    private void addType( List types, String name ) throws Exception
       {
           String classname = parseResourceName( name );
  -        Type type = TYPE_BUILDER.build( classname, m_classloader );
  +        Class clazz = m_classloader.loadClass( classname );
  +        Type type = TYPE_BUILDER.build( clazz );
  +
           try
           {
               verifyType( type );
  @@ -374,7 +386,7 @@
                     REZ.getString( "scanner.type.addition", classname );
                   getLogger().debug( message );
               }
  -            list.add( type );
  +            types.add( type );
           }
           catch( Throwable e )
           {
  
  
  
  1.1                  
avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultModelSelector.java
  
  Index: DefaultModelSelector.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation. All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software
   *    itself, if and wherever such third-party acknowledgments
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.avalon.composition.model.impl;
  
  import java.util.ArrayList;
  
  import org.apache.avalon.composition.model.Model;
  import org.apache.avalon.composition.model.ModelSelector;
  import org.apache.avalon.meta.info.DependencyDescriptor;
  import org.apache.avalon.meta.info.StageDescriptor;
  import org.apache.avalon.meta.data.Mode;
  
  /**
   * Default selector class. The default selector selcts profiles based
   * of ranking of profile relative to EXPLICIT, PACKAGED and IMPLICIT
   * status. For each category, if a supplied profile matches the category
   * the first profile matching the category is returned.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
   * @version $Revision: 1.1 $ $Date: 2003/07/07 08:31:18 $
   */
  class DefaultModelSelector implements ModelSelector
  {
      //==============================================================
      // ModelSelector
      //==============================================================
  
      /**
       * Returns the preferred model from an available selection of
       * candidates capable of fulfilling a supplied service dependency.
       *
       * @param models the set of candidate models
       * @param dependency a service dependency
       * @return the preferred model or null if no satisfactory 
       *    provider can be established
       */
      public Model select( Model[] models, DependencyDescriptor dependency )
      {
          Model[] candidates = filterCandidateProviders( models, dependency );
          return select( candidates );
      }
  
      /**
       * Returns the preferred model from an available selection of candidates
       * @param models the set of candidate models 
       * @param stage the stage dependency
       * @return the preferred provider or null if no satisfactory 
       *    provider can be established
       */
      public Model select( Model[] models, StageDescriptor stage )
      {
          Model[] candidates = filterCandidateProviders( models, stage );
          return select( candidates );
      }
  
      //==============================================================
      // implementation
      //==============================================================
  
      private Model[] filterCandidateProviders( 
        Model[] models, DependencyDescriptor dependency )
      {
          ArrayList list = new ArrayList();
          for( int i = 0; i < models.length; i++ )
          {
              Model model = models[i];
              if( model.isaCandidate( dependency ) )
              {
                  list.add( model );
              }
          }
          return (Model[]) list.toArray( new Model[0] );
      }
  
      private Model[] filterCandidateProviders( 
        Model[] models, StageDescriptor stage )
      {
          ArrayList list = new ArrayList();
          for( int i = 0; i < models.length; i++ )
          {
              Model model = models[i];
              if( model.isaCandidate( stage ) )
              {
                  list.add( model );
              }
          }
          return (Model[]) list.toArray( new Model[0] );
      }
  
      /**
       * Select a model from a set of models based on a priority ordering
       * of EXPLICIT, PACKAGE and lastly IMPLICIT.  If multiple candidates
       * exist for a particulr mode, return the first candidate.
       *
       * @param profiles the set of candidate profiles
       * @param dependency the service dependency
       * @return the preferred profile or null if no satisfactory 
       *   provider can be established
       */
      private Model select( Model[] models )
      {
          if( models.length == 0 )
          {
              return null;
          }
  
          for( int i=0; i<models.length; i++ )
          {
              if( models[i].getMode().equals( Mode.EXPLICIT ) )
              {
                  return models[i];
              }
          }
  
          for( int i=0; i<models.length; i++ )
          {
              if( models[i].getMode().equals( Mode.PACKAGED ) )
              {
                  return models[i];
              }
          }
  
          for( int i=0; i<models.length; i++ )
          {
              if( models[i].getMode().equals( Mode.IMPLICIT ) )
              {
                  return models[i];
              }
          }
  
          return null;
      }
  }
  
  
  
  1.5       +1 -7      
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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ContainmentModel.java     6 Jul 2003 10:08:17 -0000       1.4
  +++ ContainmentModel.java     7 Jul 2003 08:31:19 -0000       1.5
  @@ -81,12 +81,6 @@
       ServiceDirective[] getServiceDirectives();
   
      /**
  -    * Return the set of dependencies
  -    * @return the block implementation model
  -    */
  -    DependencyDescriptor[] getDependencies();
  -
  -   /**
       * Return the classloader model assigned to this 
       * containment model.
       *
  
  
  
  1.2       +10 -2     
avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/Model.java
  
  Index: Model.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/Model.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Model.java        4 Jul 2003 07:28:20 -0000       1.1
  +++ Model.java        7 Jul 2003 08:31:19 -0000       1.2
  @@ -50,13 +50,15 @@
   
   package org.apache.avalon.composition.model;
   
  +import org.apache.avalon.meta.data.Mode;
  +
   /**
    * Abstract model interface.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
    * @version $Revision$ $Date$
    */
  -public interface Model
  +public interface Model extends Producer, Consumer
   {
      /**
       * Return the name of the model.
  @@ -69,5 +71,11 @@
       * @return the path
       */
       String getPath();
  +
  +   /**
  +    * Return the mode of model establishment.
  +    * @return the mode
  +    */
  +    Mode getMode();
   
   }
  
  
  
  1.4       +12 -1     
avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/TypeRepository.java
  
  Index: TypeRepository.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/TypeRepository.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TypeRepository.java       6 Jul 2003 02:57:05 -0000       1.3
  +++ TypeRepository.java       7 Jul 2003 08:31:19 -0000       1.4
  @@ -50,6 +50,7 @@
   
   package org.apache.avalon.composition.model;
   
  +import org.apache.avalon.meta.data.DeploymentProfile;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.meta.info.Type;
  @@ -109,5 +110,15 @@
        * @return a set of types that support the supplied stage
        */
       Type[] getTypes( StageDescriptor stage );
  +
  +   /**
  +    * Return the set of deployment profiles for the supplied type. An 
  +    * implementation is required to return a array of types > 0 in length
  +    * or throw a TypeUnknownException.
  +    * @param type the type
  +    * @return a profile array containing at least one deployment profile
  +    * @exception TypeUnknownException if the supplied type is unknown
  +    */
  +    DeploymentProfile[] getProfiles( Type type ) throws TypeUnknownException;
   
   }
  
  
  
  1.1                  
avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/Consumer.java
  
  Index: Consumer.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact [EMAIL PROTECTED]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.composition.model;
  
  import org.apache.avalon.meta.info.DependencyDescriptor;
  
  /**
   * Producer interface defintion.  A producer is the contract implemented by
   * a model that is capable of producing services that can be considered as 
   * candidated when assembling a model.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/07/07 08:31:19 $
   */
  public interface Consumer
  {
     /**
      * Return the set of services that this model consumes.
      * @return the cumsumed depedencies
      */
      DependencyDescriptor[] getDependencies();
  
  }
  
  
  
  1.1                  
avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/ModelSelector.java
  
  Index: ModelSelector.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact [EMAIL PROTECTED]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.composition.model;
  
  import org.apache.avalon.meta.info.DependencyDescriptor;
  import org.apache.avalon.meta.info.StageDescriptor;
  import org.apache.avalon.meta.data.Profile;
  
  /**
   * Interface implemented by a service selection implementation mechanism.  Classes
   * implementing the selector interface may be activated during the selection of
   * candidate service providers in an automated assembly process. 
   * A component author may declare a selection class explicitly via a
   * service dependency attribute with the attribute name of 
   * <code>urn:avalon:profile.selector</code> (but this will change to a model
   * driven approach).
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/07/07 08:31:19 $
   */
  public interface ModelSelector
  {
      /**
       * Returns the preferred model from an available selection of
       * candidates capable of fulfilling a supplied service dependency.
       *
       * @param models the set of candidate models
       * @param dependency a service dependency
       * @return the preferred model or null if no satisfactory provider can be 
established
       */
      Model select( Model[] models, DependencyDescriptor dependency );
  
      /**
       * Returns the preferred model from an available selection of candidates
       * @param models the set of candidate models 
       * @param stage the stage dependency
       * @return the preferred provider or null if no satisfactory provider can be 
established
       */
      Model select( Model[] models, StageDescriptor stage );
  }
  
  
  
  1.1                  
avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/Producer.java
  
  Index: Producer.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact [EMAIL PROTECTED]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.composition.model;
  
  import org.apache.avalon.meta.info.ServiceDescriptor;
  import org.apache.avalon.meta.info.StageDescriptor;
  import org.apache.avalon.meta.info.DependencyDescriptor;
  
  /**
   * Producer interface defintion.  A producer is the contract implemented by
   * a model that is capable of producing services that can be considered as 
   * candidated when assembling a model.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/07/07 08:31:19 $
   */
  public interface Producer
  {
     /**
      * Return the set of services produced by the model.
      * @return the services
      */
      ServiceDescriptor[] getServices();
  
     /**
      * Return TRUE is this model is capable of supporting a supplied 
      * depedendency.
      * @return true if this model can fulfill the dependency
      */
      boolean isaCandidate( DependencyDescriptor dependency );
  
     /**
      * Return TRUE is this model is capable of supporting a supplied 
      * stage dependency.
      * @return true if this model can fulfill the dependency
      */
      boolean isaCandidate( StageDescriptor stage );
  
  }
  
  
  
  1.3       +2 -0      avalon-sandbox/merlin/merlin-extensions/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-extensions/.cvsignore,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- .cvsignore        27 Jun 2003 22:56:10 -0000      1.2
  +++ .cvsignore        7 Jul 2003 08:31:19 -0000       1.3
  @@ -1,5 +1,7 @@
   maven.log
   velocity.log
   build.properties
  +merlin-mgr
  +merlin-jmx-agent
   target
   *.zip
  
  
  
  1.2       +27 -13    
avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/data/builder/ProfilePackageBuilder.java
  
  Index: ProfilePackageBuilder.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/data/builder/ProfilePackageBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProfilePackageBuilder.java        5 Jul 2003 03:27:56 -0000       1.1
  +++ ProfilePackageBuilder.java        7 Jul 2003 08:31:19 -0000       1.2
  @@ -57,6 +57,7 @@
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.meta.ConfigurationBuilder;
   import org.apache.avalon.meta.data.ProfilePackage;
  +import org.apache.avalon.meta.data.DeploymentProfile;
   import org.apache.avalon.meta.data.MetaDataException;
   
   import org.xml.sax.InputSource;
  @@ -71,32 +72,45 @@
    */
   public final class ProfilePackageBuilder implements ProfilePackageCreator
   {
  -
       private XMLProfilePackageCreator m_xml = 
         new XMLProfilePackageCreator( );
   
       private final SerializedProfilePackageCreator m_serial =
         new SerializedProfilePackageCreator();
   
  -
       /**
  -     * Create a [EMAIL PROTECTED] ProfilePackage} from a stream.
  +     * Create a [EMAIL PROTECTED] ProfilePackage} from a type.
        *
  -     * @param inputStream the stream that the resource is loaded from
  +     * @param type the compoent type meta-info descriptor
  +     * @param classloader the classloader
        * @return the profile package
  -     * @exception Exception if a error occurs during profile creation
  +     * @exception Exception if a error occurs during package creation
        */
  -    public ProfilePackage createProfilePackage( InputStream inputStream )
  +    public ProfilePackage createProfilePackage( Class clazz )
           throws Exception
       {
  -        final ProfilePackage profile = buildFromSerDescriptor( inputStream);
  -        if( null != profile )
  +        ProfilePackage profiles = m_serial.createProfilePackage( clazz );
  +        if( profiles != null )
           {
  -            return profile;
  +            return profiles;
           }
           else
           {
  -            return buildFromXMLDescriptor( inputStream );
  +            final String classname = clazz.getName();
  +            final String xprofile =
  +              classname.replace( '.', '/' ) + ".xprofile";
  +            final InputStream stream =
  +              clazz.getClassLoader().getResourceAsStream( xprofile );
  +            if( stream == null )
  +            {
  +                DeploymentProfile profile = 
  +                  new DeploymentProfile( "default", classname );
  +                return new ProfilePackage( new DeploymentProfile[]{ profile } );
  +            }
  +            else
  +            {
  +                return buildFromXMLDescriptor( classname, stream );
  +            }
           }
       }
   
  @@ -116,12 +130,12 @@
        *
        * @throws Exception if an error occurs
        */
  -    private ProfilePackage buildFromXMLDescriptor( InputStream inputStream )
  +    private ProfilePackage buildFromXMLDescriptor( String classname, InputStream 
inputStream )
           throws Exception
       {
           final InputSource inputSource = new InputSource( inputStream );
           Configuration config = ConfigurationBuilder.build( inputSource );
  -        return m_xml.createProfilePackage( config );
  +        return m_xml.createProfilePackage( classname, config );
       }
   
   }
  
  
  
  1.2       +5 -4      
avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/data/builder/ProfilePackageCreator.java
  
  Index: ProfilePackageCreator.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/data/builder/ProfilePackageCreator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProfilePackageCreator.java        5 Jul 2003 03:27:56 -0000       1.1
  +++ ProfilePackageCreator.java        7 Jul 2003 08:31:20 -0000       1.2
  @@ -52,6 +52,7 @@
   
   import java.io.InputStream;
   import org.apache.avalon.meta.data.ProfilePackage;
  +import org.apache.avalon.meta.info.Type;
   
   /**
    * Interface used to create a [EMAIL PROTECTED] ProfilePackage}
  @@ -63,13 +64,13 @@
   public interface ProfilePackageCreator
   {
       /**
  -     * Create a [EMAIL PROTECTED] ProfilePackage} from a stream.
  +     * Create a [EMAIL PROTECTED] ProfilePackage} from a class reference.
        *
  -     * @param inputStream the stream that the resource is loaded from
  +     * @param clazz the component class
        * @return the profile package
        * @exception Exception if a error occurs during package creation
        */
  -    ProfilePackage createProfilePackage( InputStream inputStream )
  +    ProfilePackage createProfilePackage( Class clazz )
           throws Exception;
   
   }
  
  
  
  1.2       +27 -1     
avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/data/builder/SerializedProfilePackageCreator.java
  
  Index: SerializedProfilePackageCreator.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/data/builder/SerializedProfilePackageCreator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SerializedProfilePackageCreator.java      5 Jul 2003 03:27:56 -0000       1.1
  +++ SerializedProfilePackageCreator.java      7 Jul 2003 08:31:20 -0000       1.2
  @@ -65,6 +65,32 @@
   public class SerializedProfilePackageCreator
       implements ProfilePackageCreator
   {
  +
  +    /**
  +     * Create a [EMAIL PROTECTED] ProfilePackage} from a class.
  +     *
  +     * @param clazz the component type class
  +     * @return the profile package
  +     * @exception Exception if a error occurs during package creation
  +     */
  +    public ProfilePackage createProfilePackage( Class clazz )
  +        throws Exception
  +    {
  +        final String classname = clazz.getName();
  +        final String zprofile =
  +          classname.replace( '.', '/' ) + ".zprofile";
  +        final InputStream stream =
  +          clazz.getClassLoader().getResourceAsStream( zprofile );
  +        if( stream == null )
  +        {
  +            return null;
  +        }
  +        else
  +        {
  +            return createProfilePackage( stream );
  +        }
  +    }
  +
       /**
        * Create a [EMAIL PROTECTED] ProfilePackage} from a stream.
        *
  
  
  
  1.2       +26 -2     
avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/data/builder/XMLDeploymentProfileCreator.java
  
  Index: XMLDeploymentProfileCreator.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/data/builder/XMLDeploymentProfileCreator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XMLDeploymentProfileCreator.java  3 Jul 2003 04:28:54 -0000       1.1
  +++ XMLDeploymentProfileCreator.java  7 Jul 2003 08:31:20 -0000       1.2
  @@ -74,9 +74,33 @@
       public DeploymentProfile createDeploymentProfile( Configuration config )
         throws Exception
       {
  +        String classname = config.getAttribute( "class", null );
  +        return createDeploymentProfile( classname, config );
  +    }
  +
  +   /**
  +    * Creation of a [EMAIL PROTECTED] DeploymentProfile} from an XML configuration.
  +    *
  +    * @param config the configuration
  +    * @return the deployment profile
  +    */
  +    public DeploymentProfile createDeploymentProfile( String classname, 
Configuration config )
  +      throws Exception
  +    {
           final String name = getName( config );
  +        return createDeploymentProfile( classname, config, name );
  +    }
  +
  +   /**
  +    * Creation of a [EMAIL PROTECTED] DeploymentProfile} from an XML configuration.
  +    *
  +    * @param config the configuration
  +    * @return the deployment profile
  +    */
  +    public DeploymentProfile createDeploymentProfile( String classname, 
Configuration config, String name )
  +      throws Exception
  +    {
           final boolean activation = getActivationPolicy( config, true );
  -        String classname = config.getAttribute( "class", null );
   
           final CategoriesDirective categories = 
             getCategoriesDirective( config.getChild( "categories", false ), name );
  
  
  
  1.3       +4 -3      
avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/data/builder/XMLProfilePackageCreator.java
  
  Index: XMLProfilePackageCreator.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/data/builder/XMLProfilePackageCreator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLProfilePackageCreator.java     6 Jul 2003 10:08:18 -0000       1.2
  +++ XMLProfilePackageCreator.java     7 Jul 2003 08:31:20 -0000       1.3
  @@ -79,7 +79,7 @@
       * @param config the configuration
       * @return the profile package
       */
  -    public ProfilePackage createProfilePackage( Configuration config )
  +    public ProfilePackage createProfilePackage( String classname, Configuration 
config )
         throws MetaDataException
       {
           ArrayList list = new ArrayList();
  @@ -93,7 +93,8 @@
                   try
                   {
                       list.add( 
  -                      DEPLOYMENT_CREATOR.createDeploymentProfile( child ) );
  +                      DEPLOYMENT_CREATOR.createDeploymentProfile( 
  +                        classname, child ) );
                   }
                   catch( Throwable e )
                   {
  
  
  
  1.7       +29 -10    
avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/info/builder/TypeBuilder.java
  
  Index: TypeBuilder.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/info/builder/TypeBuilder.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TypeBuilder.java  20 Jun 2003 19:02:18 -0000      1.6
  +++ TypeBuilder.java  7 Jul 2003 08:31:20 -0000       1.7
  @@ -90,6 +90,11 @@
       public Type build( final Class clazz )
           throws Exception
       {
  +        //
  +        // build the configuration defaults and the profiles and
  +        // supply these as arguments to thye type build
  +        //
  +
           return build( clazz.getName(), clazz.getClassLoader() );
       }
   
  @@ -125,20 +130,34 @@
        * @return the created Type
        * @throws Exception if an error occurs
        */
  -    private Type buildFromSerDescriptor( final String classname,
  -                                         final ClassLoader classLoader )
  +    private Type buildFromSerDescriptor( 
  +      final String classname, final ClassLoader classLoader )
           throws Exception
       {
  -        final String xinfo =
  -            classname.replace( '.', '/' ) + ".stype";
  -        final InputStream inputStream =
  -            classLoader.getResourceAsStream( xinfo );
  -        if( null == inputStream )
  +        Type type = buildFromSerDescriptor( classname, classLoader, ".ztype" ); 
  +        if( type != null )
           {
  -            return null;
  +            return type;
  +        }
  +        else
  +        {
  +            return buildFromSerDescriptor( classname, classLoader, ".zinfo" );
           }
  +    }
   
  -        return m_serialTypeCreator.createType( classname, inputStream );
  +    private Type buildFromSerDescriptor( 
  +      final String classname, final ClassLoader classLoader, String form )
  +        throws Exception
  +    {
  +        final String address =
  +            classname.replace( '.', '/' ) + form;
  +        final InputStream stream =
  +            classLoader.getResourceAsStream( address );
  +        if( null == stream )
  +        {
  +            return null;
  +        }
  +        return m_serialTypeCreator.createType( classname, stream );
       }
   
       /**
  
  
  
  1.3       +21 -22    
avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/ContainmentProfile.java
  
  Index: ContainmentProfile.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/ContainmentProfile.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ContainmentProfile.java   6 Jul 2003 10:08:18 -0000       1.2
  +++ ContainmentProfile.java   7 Jul 2003 08:31:20 -0000       1.3
  @@ -70,7 +70,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
    * @version $Revision$ $Date$
    */
  -public class ContainmentProfile extends DeploymentProfile
  +public class ContainmentProfile extends Profile
   {
       //========================================================================
       // static
  @@ -81,12 +81,12 @@
        */
       public static final String DELIMITER = "/";
   
  +    private static final ServiceDirective[] EMPTY_SERVICE_DIRECTIVES =
  +      new ServiceDirective[0];
  +
       private static final DependencyDescriptor[] EMPTY_DEPENDENCIES =
         new DependencyDescriptor[0];
   
  -    private static final ServiceDirective[] EMPTY_SERVICES =
  -      new ServiceDirective[0];
  -
       private static final ContainmentProfile EMPTY_IMPLEMENTATION =
         new ContainmentProfile();
   
  @@ -110,7 +110,7 @@
      /**
       * The block dependencies.
       */
  -    private final DependencyDescriptor[] m_import;
  +    private final DependencyDescriptor[] m_imports;
   
       /**
        * The profiles described within the scope of the containment profile.
  @@ -136,22 +136,21 @@
           m_classloader = classloader;
           m_profiles = profiles;
   
  -        if( imports == null )
  +        if( exports == null )
           {
  -            m_import = EMPTY_DEPENDENCIES;
  +            m_export = EMPTY_SERVICE_DIRECTIVES;
           }
           else
           {
  -            m_import = imports;
  +            m_export = exports;
           }
  -
  -        if( exports == null )
  +        if( imports == null )
           {
  -            m_export = EMPTY_SERVICES;
  +            m_imports = EMPTY_DEPENDENCIES;
           }
           else
           {
  -            m_export = exports;
  +            m_imports = imports;
           }
       }
   
  @@ -184,15 +183,6 @@
       }
   
       /**
  -     * Get the imported dependencies.
  -     * @return the dependecy import
  -     */
  -     public DependencyDescriptor[] getDependencies()
  -     {
  -         return m_import;
  -     }
  -
  -    /**
        * Return the set of service directives.
        *
        * @return the service directive set
  @@ -201,6 +191,15 @@
       {
           return m_export;
       }
  +
  +    /**
  +     * Get the imported dependencies.
  +     * @return the dependecy import
  +     */
  +     public DependencyDescriptor[] getDependencies()
  +     {
  +         return m_imports;
  +     }
   
       /**
        * Retrieve a service directive matching a supplied class.
  
  
  
  1.2       +5 -3      
avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/DeploymentProfile.java
  
  Index: DeploymentProfile.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/DeploymentProfile.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeploymentProfile.java    3 Jul 2003 04:28:55 -0000       1.1
  +++ DeploymentProfile.java    7 Jul 2003 08:31:20 -0000       1.2
  @@ -173,9 +173,11 @@
       // constructor
       //--------------------------------------------------------------------------
   
  -    public DeploymentProfile( String name, boolean activation, Mode mode )
  +    public DeploymentProfile( 
  +           final String name, 
  +           final String classname )
       {
  -        super( name, activation, mode );
  +        this( name, false, classname, null, null, null, null, Mode.IMPLICIT );
       }
   
       public DeploymentProfile( 
  
  
  
  1.2       +10 -4     
avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/Profile.java
  
  Index: Profile.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/Profile.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Profile.java      3 Jul 2003 04:28:55 -0000       1.1
  +++ Profile.java      7 Jul 2003 08:31:20 -0000       1.2
  @@ -67,6 +67,10 @@
    */
   public abstract class Profile implements Serializable
   {
  +    //--------------------------------------------------------------------------
  +    // state
  +    //--------------------------------------------------------------------------
  +
       /**
        * The name of the component profile. This is an
        * abstract name used during assembly.
  @@ -78,13 +82,17 @@
        */
       private final boolean m_activation;
   
  +   /**
  +    * The mode under which this profile was established.
  +    */
       private final Mode m_mode;
   
       //--------------------------------------------------------------------------
       // constructor
       //--------------------------------------------------------------------------
   
  -    public Profile( final String name, boolean activation, Mode mode ) 
  +    public Profile( 
  +      final String name, boolean activation, Mode mode ) 
       {
           m_activation = activation;
           if( mode != null )
  @@ -104,7 +112,6 @@
           {
               m_name = name;
           }
  -
       }
   
       //--------------------------------------------------------------------------
  @@ -128,7 +135,6 @@
       {
           return m_activation;
       }
  -
   
       /**
        * Returns the creation mode for this profile.
  
  
  
  1.3       +18 -3     
avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/ProfilePackage.java
  
  Index: ProfilePackage.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/ProfilePackage.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProfilePackage.java       6 Jul 2003 10:08:18 -0000       1.2
  +++ ProfilePackage.java       7 Jul 2003 08:31:20 -0000       1.3
  @@ -60,15 +60,30 @@
    */
   public class ProfilePackage implements Serializable
   {
  +    //--------------------------------------------------------------------------
  +    // static
  +    //--------------------------------------------------------------------------
  +
  +    public static final ProfilePackage EMPTY_PACKAGE = new ProfilePackage();
  +
  +    //--------------------------------------------------------------------------
  +    // immutable state
  +    //--------------------------------------------------------------------------
  +
       /**
        * The set of deployment profiles contained within the package.
        */
  -    private DeploymentProfile[] m_profiles;
  +    private final DeploymentProfile[] m_profiles;
   
       //--------------------------------------------------------------------------
       // constructor
       //--------------------------------------------------------------------------
   
  +    public ProfilePackage() 
  +    {
  +        this( new DeploymentProfile[0] );
  +    }
  +
       public ProfilePackage( final DeploymentProfile[] profiles ) 
       {
           m_profiles = profiles;
  @@ -83,7 +98,7 @@
        *
        * @return the profiles
        */
  -    public DeploymentProfile[] getProfile()
  +    public DeploymentProfile[] getDeploymentProfiles()
       {
           return m_profiles;
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to