avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/type TypeManagerTestCase.java
Date Mon, 23 Dec 2002 00:13:35 GMT
mcconnell    2002/12/22 16:13:35

  Modified:    assembly build.xml
               assembly/src/java/org/apache/avalon/assembly/appliance
                        Appliance.java ApplianceSelector.java
                        ContextBuilder.java DefaultAppliance.java
                        DefaultApplianceSelector.java
               assembly/src/java/org/apache/avalon/assembly/engine
                        DefaultRepositoryManager.java
                        EngineClassLoader.java RepositoryManager.java
               assembly/src/java/org/apache/avalon/assembly/lifestyle
                        AbstractLifestyleHandler.java
               assembly/src/java/org/apache/avalon/assembly/locator
                        Locator.java LocatorException.java
               assembly/src/test/org/apache/avalon/assembly/profile
                        ProfileManagerTestCase.java
               assembly/src/test/org/apache/avalon/assembly/service
                        DefaultServiceManagerTestCase.java
               assembly/src/test/org/apache/avalon/assembly/type
                        TypeManagerTestCase.java
  Added:       assembly/src/java/org/apache/avalon/assembly/engine/profile
                        DefaultProfileSelector.java
                        DuplicateProfileException.java
                        ProfileException.java ProfileManager.java
                        ProfileSelector.java UnknownProfileException.java
                        package.html
               assembly/src/java/org/apache/avalon/assembly/engine/service
                        DuplicateServiceException.java
                        ServiceException.java ServiceManager.java
                        ServiceRuntimeException.java
                        UnknownServiceException.java package.html
               assembly/src/java/org/apache/avalon/assembly/engine/type
                        DuplicateTypeException.java TypeException.java
                        TypeManager.java TypeRuntimeException.java
                        UnknownTypeException.java package.html
               assembly/src/java/org/apache/avalon/assembly/locator
                        DefaultLocator.java Reclaimable.java
                        Resolvable.java
  Removed:     assembly/src/java/org/apache/avalon/assembly/profile
                        DefaultProfileSelector.java
                        DuplicateProfileException.java
                        ProfileException.java ProfileManager.java
                        ProfileSelector.java UnknownProfileException.java
                        package.html
               assembly/src/java/org/apache/avalon/assembly/service
                        DuplicateServiceException.java
                        ServiceException.java ServiceManager.java
                        ServiceRuntimeException.java
                        UnknownServiceException.java package.html
               assembly/src/java/org/apache/avalon/assembly/type
                        DuplicateTypeException.java TypeException.java
                        TypeManager.java TypeRuntimeException.java
                        UnknownTypeException.java package.html
  Log:
  Some package reshuffling.
  
  Revision  Changes    Path
  1.10      +15 -3     avalon-sandbox/assembly/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/build.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- build.xml	20 Dec 2002 11:54:28 -0000	1.9
  +++ build.xml	23 Dec 2002 00:13:33 -0000	1.10
  @@ -150,6 +150,7 @@
             description="Generates the javadocs" unless="skip.javadocs">
       <mkdir dir="${build.javadocs}"/>
       <javadoc packagenames="org.apache.avalon.assembly.*"
  +       use="true"
          sourcepath="${java.dir}"
          destdir="${build.javadocs}">
         <classpath refid="project.class.path" />
  @@ -160,9 +161,10 @@
           <param name="-windowtitle" value="${Name} API"/>
           <param name="-link" value="http://java.sun.com/j2se/1.4/docs/api/"/>
           <param name="-link" value="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/"/>
  -        <param name="-link" value="http://jakarta.apache.org/avalon/api/"/>
  +        <param name="-link" value="../../avalon"/>
           <param name="-link" value="../../meta/api"/>
           <param name="-link" value="../../lifecycle/api"/>
  +        <param name="-link" value="../../merlin/api"/>
          <param name="-bottom"
              value="&quot;Copyright &#169; ${year} Apache Avalon Project. All Rights Reserved.&quot;"/>
         </doclet>
  @@ -427,8 +429,18 @@
   
     <target name="patch">
       <replace dir="src" summary="true"
  -       token=".getProfile().getType()"
  -       value=".getType()" >
  +       token="org.apache.avalon.assembly.profile"
  +       value="org.apache.avalon.assembly.engine.profile" >
  +     <include name="**/*.*"/>
  +    </replace>
  +    <replace dir="src" summary="true"
  +       token="org.apache.avalon.assembly.type"
  +       value="org.apache.avalon.assembly.engine.type" >
  +     <include name="**/*.*"/>
  +    </replace>
  +    <replace dir="src" summary="true"
  +       token="org.apache.avalon.assembly.service"
  +       value="org.apache.avalon.assembly.engine.service" >
        <include name="**/*.*"/>
       </replace>
     </target>
  
  
  
  1.15      +1 -31     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/Appliance.java
  
  Index: Appliance.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/Appliance.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Appliance.java	21 Dec 2002 09:26:33 -0000	1.14
  +++ Appliance.java	23 Dec 2002 00:13:33 -0000	1.15
  @@ -113,12 +113,6 @@
       Type getType();
   
       /**
  -     * Return the component class
  -     * @return the class
  -     */
  -    Class getComponentClass();
  -
  -    /**
        * Return the profile backing the appliance.
        * @return the profile that this appliance is managing
        */
  @@ -175,30 +169,6 @@
       * @return the component context
       */
       Context getContext();
  -
  -    /**
  -     * Return the context directive for the profile. A context directive
  -     * is declared in a component profile and may contain information 
  -     * unabling the selection of a component implementation class and 
  -     * constructed context values.  This information may be used by the 
  -     * the context management framework during creation and population
  -     * of the of the context supplied to the target component.
  -     *
  -     * @return the ContextDirective for the profile.
  -     * @see #getDeploymentContext()
  -     */
  -    ContextDirective getContextDirective();
  -
  -   /**
  -    * Get the deployment context. The deployment context includes
  -    * supplimentary context values provided by the client that can be
  -    * used by the context management framework during the creation 
  -    * and population of the context supplied to the target component.
  -    *
  -    * @return the deployment context
  -    * @see #getContextDirective()
  -    */
  -    Map getDeploymentContext();
   
       /**
        * Set the context provider.
  
  
  
  1.4       +2 -2      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceSelector.java
  
  Index: ApplianceSelector.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceSelector.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ApplianceSelector.java	3 Dec 2002 06:57:25 -0000	1.3
  +++ ApplianceSelector.java	23 Dec 2002 00:13:33 -0000	1.4
  @@ -52,7 +52,7 @@
   
   import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.meta.info.DependencyDescriptor;
  -import org.apache.avalon.assembly.profile.ProfileSelector;
  +import org.apache.avalon.assembly.engine.profile.ProfileSelector;
   
   /**
    * Interface implemented by a service selection implementation mechanism.  Classes
  
  
  
  1.2       +7 -52     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/ContextBuilder.java
  
  Index: ContextBuilder.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/ContextBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContextBuilder.java	21 Dec 2002 09:26:33 -0000	1.1
  +++ ContextBuilder.java	23 Dec 2002 00:13:33 -0000	1.2
  @@ -67,7 +67,7 @@
   import org.apache.avalon.assembly.appliance.Appliance;
   import org.apache.avalon.assembly.engine.RepositoryManager;
   import org.apache.avalon.assembly.engine.EngineClassLoader;
  -import org.apache.avalon.assembly.service.UnknownServiceException;
  +import org.apache.avalon.assembly.engine.service.UnknownServiceException;
   import org.apache.avalon.meta.model.Entry;
   import org.apache.avalon.meta.model.Import;
   import org.apache.avalon.meta.model.Profile;
  @@ -88,46 +88,6 @@
    */
   class ContextBuilder
   {
  -    /**
  -     * Internal utility to construct a context map using a descriptor, directive and source
  -     * context instances.
  -     *
  -     * @param engine the service management engine
  -     * @param appliance the appliance containing the context dependency declarations
  -     * @param map supplimentary context values supplied by the client
  -     * @param system th system context
  -     * @return a context map containing only those context entries required under the
  -     *   supplied descriptor
  -     * @exception Exception if a required context value cannot be resolved or an error
  -     *   occurs during context value creation
  -     */
  -    static Map buildContextMap( 
  -      EngineClassLoader engine, Appliance appliance, Map map, Context system )
  -      throws ContextException
  -    {
  -        //
  -        // get the type descriptor for the context and the profile
  -        // directive
  -        //
  -
  -        ContextDescriptor descriptor = appliance.getType().getContext();
  -        ContextDirective directive = appliance.getContextDirective();
  -        RepositoryManager repository = engine.getRepository();
  -
  -        //
  -        // create a temporary context object to hold both the system context
  -        // and any context values supplied by the client
  -        //
  -
  -        Context source = new DefaultContext( map, system );
  -
  -        //
  -        // construct a new map based on the target components requirements
  -        //
  -
  -        return buildContext( engine, repository, descriptor, directive, source );
  -    }
  -
   
       /**
        * Internal utility to construct a context map using a descriptor, directive and source
  @@ -141,10 +101,10 @@
        *   supplied descriptor
        * @exception ContextException if a required context value cannot be resolved
        */
  -    private static Map buildContext( 
  -      ClassLoader classloader, RepositoryManager repository, ContextDescriptor descriptor, 
  -      ContextDirective directive, Context context )
  -      throws ContextException
  +     static Map buildContextMap( 
  +       ClassLoader classloader, RepositoryManager repository, ContextDescriptor descriptor, 
  +       ContextDirective directive, Context context )
  +       throws ContextException
       {
   
           //
  @@ -172,15 +132,10 @@
               String key = entry.getKey();
   
               //
  -            // if the entry is already in the supplied context then use it
  +            // lookup the context entry from the supplied context object
               //
   
  -            // ### converge next two operation into a if then else on 
  -            // system context entries with the next line as the final else
  -            // case
  -
               Object object = getContextValue( context, key );
  -            //object = resolveStandardKey( appliance, context, key );
   
               //
               // If the context value is unresolved, try to handle resolution
  
  
  
  1.19      +31 -48    avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java
  
  Index: DefaultAppliance.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- DefaultAppliance.java	21 Dec 2002 09:26:33 -0000	1.18
  +++ DefaultAppliance.java	23 Dec 2002 00:13:33 -0000	1.19
  @@ -64,6 +64,7 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.service.ServiceManager;
  @@ -72,6 +73,7 @@
   
   import org.apache.avalon.assembly.engine.Engine;
   import org.apache.avalon.assembly.engine.EngineClassLoader;
  +import org.apache.avalon.assembly.engine.RepositoryManager;
   import org.apache.avalon.assembly.lifestyle.LifestyleException;
   import org.apache.avalon.assembly.lifestyle.LifestyleService;
   import org.apache.avalon.assembly.lifestyle.LifestyleHandler;
  @@ -300,15 +302,6 @@
           return m_applianceContext.getType();
       }
   
  -    /**
  -     * Return the component class
  -     * @return the class
  -     */
  -    public Class getComponentClass()
  -    {
  -        return m_class;
  -    }
  -
      /**
       * Get the appliance URL.
       * @return the appliance URL
  @@ -357,20 +350,6 @@
           return m_context;
       }
   
  -   /**
  -    * Get the deployment context. The deployment context includes
  -    * supplimentary context values provided by the client that can be
  -    * used by the context management framework during the creation 
  -    * and population of the context supplied to the target component.
  -    *
  -    * @return the deployment context
  -    * @see #getContextDirective()
  -    */
  -    public Map getDeploymentContext()
  -    {
  -        return m_deployment;
  -    }
  -
       /**
        * Return the context directive for the profile. A context directive
        * is declared in a component profile and may contain information 
  @@ -380,12 +359,11 @@
        * of the of the context supplied to the target component.
        *
        * @return the ContextDirective for the profile.
  -     * @see #getDeploymentContext()
        */
  -    public ContextDirective getContextDirective()
  -    {
  -        return m_applianceContext.getContextDirective();
  -    }
  +    //public ContextDirective getContextDirective()
  +    //{
  +    //    return m_applianceContext.getContextDirective();
  +    //}
   
       /**
        * Return the Parameters to be applied to the appliance.
  @@ -507,9 +485,9 @@
           // make sure that the deployment context is fully populated
           //
   
  +        Map map = m_applianceContext.getDeploymentContext();
           try
           {
  -            Map map = m_applianceContext.getDeploymentContext();
   
               //
               // setup the name and the partition
  @@ -519,19 +497,22 @@
               map.put( "urn:avalon:partition.name", m_applianceContext.getPartitionName() );
   
               //
  -            // setup the home and working directory for the component
  +            // setup the home and working directory for the components but don't 
  +            // actually create the directories - that needs to be handled in a context
  +            // object on demand
               //
   
               File base = (File) m_system.get( "urn:assembly:home" );
  -            File dir = new File( base, "work" );
  -            dir.mkdirs();
  -            File home = new File( dir, m_path );
  -            File work = new File( home, "temp" );
  -            home.mkdir();
  -            work.mkdir();
  +            File working = new File( base, "working" );
  +            File home = new File( working, "home" );
  +            File work = new File( working, "temp" );
               work.deleteOnExit();
  -            map.put( "urn:avalon:home", home );
  -            map.put( "urn:avalon:work", work );
  +
  +            File tmp = new File( work, m_path );
  +            tmp.deleteOnExit();
  +
  +            map.put( "urn:avalon:home", new File( home, m_path ) );
  +            map.put( "urn:avalon:work", tmp );
   
               //
               // assign the updated map as the deployment context
  @@ -540,12 +521,6 @@
               m_deployment = map;
   
           }
  -        catch( ContextException e )
  -        {
  -            final String error = "System context does not contain the entry 'urn:assembly:home'"
  -             + " in appliance: " + this;
  -            throw new IllegalStateException( error );
  -        }
           catch( Throwable e )
           {
               final String error = 
  @@ -553,9 +528,18 @@
               throw new AssemblyException( error, e );
           }
   
  +        //
  +        // create a temporary context object to hold both the system context
  +        // and any context values supplied by the client and use this as the 
  +        // context information source that is supplied to the context builder
  +        //
  +
           try
           {
  -            return BUILDER.buildContextMap( m_engine, this, m_deployment, m_system );
  +            Context source = new DefaultContext( map, m_system );
  +            ContextDirective directive = m_applianceContext.getContextDirective();
  +            RepositoryManager repository = m_engine.getRepository();
  +            return BUILDER.buildContextMap( m_engine, repository, descriptor, directive, source );
           }
           catch( Throwable e )
           {
  @@ -565,14 +549,13 @@
           }
       }
   
  -
      /**
       * Assemble the appliance.
       * @exception AssemblyException if an error occurs during appliance assembly
       */
       private Context buildContextObject( Map map ) throws AssemblyException
       {
  -        ContextDirective directive = getContextDirective();
  +        ContextDirective directive = m_applianceContext.getContextDirective();
           try
           {
               return BUILDER.createContextInstance( m_engine, directive, map );
  
  
  
  1.4       +2 -2      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceSelector.java
  
  Index: DefaultApplianceSelector.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceSelector.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultApplianceSelector.java	14 Dec 2002 21:04:40 -0000	1.3
  +++ DefaultApplianceSelector.java	23 Dec 2002 00:13:33 -0000	1.4
  @@ -52,7 +52,7 @@
   
   import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.meta.info.DependencyDescriptor;
  -import org.apache.avalon.assembly.profile.ProfileSelector;
  +import org.apache.avalon.assembly.engine.profile.ProfileSelector;
   
   /**
    * Interface implemented by a service selection implementation mechanism.  Classes
  
  
  
  1.4       +4 -4      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/DefaultRepositoryManager.java
  
  Index: DefaultRepositoryManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/DefaultRepositoryManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultRepositoryManager.java	9 Dec 2002 03:03:47 -0000	1.3
  +++ DefaultRepositoryManager.java	23 Dec 2002 00:13:34 -0000	1.4
  @@ -73,9 +73,9 @@
   import java.util.jar.Manifest;
   import java.util.jar.JarFile;
   import java.util.zip.ZipEntry;
  -import org.apache.avalon.assembly.type.TypeManager;
  -import org.apache.avalon.assembly.profile.ProfileManager;
  -import org.apache.avalon.assembly.service.ServiceManager;
  +import org.apache.avalon.assembly.engine.type.TypeManager;
  +import org.apache.avalon.assembly.engine.profile.ProfileManager;
  +import org.apache.avalon.assembly.engine.service.ServiceManager;
   import org.apache.avalon.assembly.engine.model.*;
   import org.apache.avalon.excalibur.extension.Extension;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
  
  
  
  1.16      +3 -3      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java
  
  Index: EngineClassLoader.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- EngineClassLoader.java	21 Dec 2002 05:17:22 -0000	1.15
  +++ EngineClassLoader.java	23 Dec 2002 00:13:34 -0000	1.16
  @@ -64,8 +64,8 @@
   import java.util.jar.Attributes;
   import java.util.ArrayList;
   
  -import org.apache.avalon.assembly.type.TypeManager;
  -import org.apache.avalon.assembly.profile.ProfileManager;
  +import org.apache.avalon.assembly.engine.type.TypeManager;
  +import org.apache.avalon.assembly.engine.profile.ProfileManager;
   import org.apache.avalon.assembly.appliance.Appliance;
   import org.apache.avalon.assembly.appliance.ApplianceContext;
   import org.apache.avalon.assembly.appliance.DefaultApplianceContext;
  
  
  
  1.3       +4 -4      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/RepositoryManager.java
  
  Index: RepositoryManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/RepositoryManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RepositoryManager.java	9 Dec 2002 03:03:47 -0000	1.2
  +++ RepositoryManager.java	23 Dec 2002 00:13:34 -0000	1.3
  @@ -52,9 +52,9 @@
   
   import java.net.URL;
   
  -import org.apache.avalon.assembly.profile.ProfileManager;
  -import org.apache.avalon.assembly.service.ServiceManager;
  -import org.apache.avalon.assembly.type.TypeManager;
  +import org.apache.avalon.assembly.engine.profile.ProfileManager;
  +import org.apache.avalon.assembly.engine.service.ServiceManager;
  +import org.apache.avalon.assembly.engine.type.TypeManager;
   
   /**
    * An appliance is a class that encapsulates the deployment criteria
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/profile/DefaultProfileSelector.java
  
  Index: DefaultProfileSelector.java
  ===================================================================
  /* ==================================================================== 
   * The Apache Software License, Version 1.1 
   * 
   * Copyright (c) 2002 The Apache Software Foundation. All rights 
   * reserved. 
   * 
   * Redistribution and use in source and binary forms, with or without 
   * modification, are permitted provided that the following conditions 
   * are met: 
   * 
   * 1. Redistributions of source code must retain the above copyright 
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software 
   *    itself, if and wherever such third-party acknowledgments  
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" 
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see 
   * <http://www.apache.org/>.
   */ 
  
  package org.apache.avalon.assembly.engine.profile;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.meta.info.StageDescriptor;
  import org.apache.avalon.meta.info.DependencyDescriptor;
  import org.apache.avalon.meta.model.Profile;
  import org.apache.avalon.meta.model.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:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  class DefaultProfileSelector extends AbstractLogEnabled
      implements ProfileSelector
  {
  
      /**
       * Returns the preferred profile form an available selection of 
       * candidate profiles.
       * @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
       */
      public Profile select( Profile[] profiles, DependencyDescriptor dependency )
      {
          if( profiles.length == 0 )
          {
              return null;
          }
  
          Profile profile = select( profiles, dependency, Mode.EXPLICIT );
          if( profile == null )
          {
              profile = select( profiles, dependency, Mode.PACKAGED );
          }
          if( profile == null )
          {
              profile = select( profiles, dependency, Mode.IMPLICIT );
          }
          if( profile != null )
          {
              return profile;
          }
          if( profiles.length > 0 )
          {
              return profiles[ 0 ];
          }
          else
          {
              return null;
          }
      }
  
      /**
       * Returns the preferred profile form an available selection of 
       * candidate profiles.
       * @param profiles the set of candidate profiles
       * @param stage the service stage depedency
       * @return the prefered profile or null if no satisfactory provider can be established
       */
      public Profile select( Profile[] profiles, StageDescriptor stage )
      {
          if( profiles.length == 0 )
          {
              return null;
          }
  
          Profile profile = select( profiles, stage, Mode.EXPLICIT );
          if( profile == null )
          {
              profile = select( profiles, stage, Mode.PACKAGED );
          }
          if( profile == null )
          {
              profile = select( profiles, stage, Mode.IMPLICIT );
          }
          if( profile != null )
          {
              return profile;
          }
          if( profiles.length > 0 )
          {
              return profiles[ 0 ];
          }
          else
          {
              return null;
          }
      }
  
  
     /**
      * Returns the fist profile that matches the depedency and mode criteria.
      * @param profiles a set of candidate profiles
      * @param dependency the service dependency
      * @param mode the slection mode
      * @return the selected profile
      */
      private Profile select( Profile[] profiles, DependencyDescriptor dependency, Mode mode )
      {
          for( int i = 0; i < profiles.length; i++ )
          {
              Profile profile = profiles[ i ];
              if( profile.getType().getService( dependency.getReference() ) != null )
              {
                  if( profile.getMode().equals( mode ))
                  {
                      return profile;
                  }
              }
          }
          return null;
      }
  
     /**
      * Returns the fist profile that matches the stage and mode criteria.
      * @param profiles a set of candidate profiles
      * @param dependency the service dependency
      * @param mode the slection mode
      * @return the selected profile
      */
      private Profile select( Profile[] profiles, StageDescriptor stage, Mode mode )
      {
          for( int i = 0; i < profiles.length; i++ )
          {
              Profile profile = profiles[ i ];
              if( profile.getType().getExtension( stage ) != null )
              {
                  if( profile.getMode().equals( mode ))
                  {
                      return profile;
                  }
              }
          }
          return null;
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/profile/DuplicateProfileException.java
  
  Index: DuplicateProfileException.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.engine.profile;
  
  /**
   * Exception raised in response to an attempt to override the defintion
   * of an existing profile.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  public final class DuplicateProfileException
      extends ProfileException
  {
  
      /**
       * Construct a new <code>DuplicateProfileException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public DuplicateProfileException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>DuplicateProfileException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public DuplicateProfileException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/profile/ProfileException.java
  
  Index: ProfileException.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.engine.profile;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * Exception to indicate that there was a profile related error.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  public class ProfileException
      extends CascadingException
  {
  
      /**
       * Construct a new <code>ProfileException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public ProfileException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>ProfileException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public ProfileException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/profile/ProfileManager.java
  
  Index: ProfileManager.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.engine.profile;
  
  import java.util.Hashtable;
  import java.util.List;
  import java.util.ArrayList;
  import java.util.Enumeration;
  import java.util.Iterator;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.assembly.engine.type.TypeManager;
  import org.apache.avalon.assembly.engine.type.UnknownTypeException;
  import org.apache.excalibur.configuration.ConfigurationUtil;
  import org.apache.avalon.meta.model.Profile;
  import org.apache.avalon.meta.model.builder.ProfileBuilder;
  import org.apache.avalon.meta.model.verifier.ProfileVerifier;
  import org.apache.avalon.meta.info.ReferenceDescriptor;
  import org.apache.avalon.meta.info.DependencyDescriptor;
  import org.apache.avalon.meta.info.StageDescriptor;
  import org.apache.avalon.meta.info.Type;
  
  /**
   * A profile manager implemetation provides support for the creation, 
   * storage and retrival of component types.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  public class ProfileManager extends AbstractLogEnabled 
  {
      //==============================================================
      // static
      //==============================================================
  
     /**
      * The profile builder.
      */
      private static final ProfileBuilder PROFILE_BUILDER = new ProfileBuilder();
  
      //==============================================================
      // state
      //==============================================================
  
     /**
      * The classloader supplied to the manager.
      */
      private ClassLoader m_classloader;
  
     /**
      * The parent profile manager (may be null)
      */
      private ProfileManager m_parent;
  
      /**
       * Table of component profiles keyed by profile name.
       */
      private final List m_profiles = new ArrayList();
  
     /**
      * The default profile selector.
      */
      private final DefaultProfileSelector m_selector = new DefaultProfileSelector();
  
      //==============================================================
      // constructor
      //==============================================================
  
     /**
      * Creation of a new root profile manager.
      * @param classloader the classloder to use
      * @exception NullPointerException if the classloader is null
      */
      public ProfileManager( ClassLoader classloader ) throws NullPointerException
      {
          this( classloader, null );
      }
  
     /**
      * Creation of a new profile manager.
      * @param classloader the classloder to use
      * @param parent the parent type manager
      * @exception NullPointerException if the classloader is null
      */
      public ProfileManager( ClassLoader classloader, ProfileManager parent ) throws NullPointerException
      {
          if( classloader == null )
          {
              throw new NullPointerException("classloader");
          }
          m_classloader = classloader;
          m_parent = parent;
      }
  
      //==============================================================
      // implemetation
      //==============================================================
  
      /**
       * Load a set of packaged profiles associated with the supplied class.
       * Profiles returned from this operation are not included within the 
       * manager.  To register a profile with the manager use the {@link #addProfile}
       * operation.
       *
       * @param type the component type used to locate an packaged profiles
       * @return the set of packaged component profiles
       * @exception ProfileException if an error occurs while loading package profiles
       */
      public Profile[] loadProfiles( Type type ) throws ProfileException
      {
          if( type == null )
          {
              throw new NullPointerException("type");
          }
          
          try
          {
              return PROFILE_BUILDER.build( m_classloader, type );
          }
          catch( Throwable e )
          {
              final String error = 
                "Unable to create packaged profiles for type: " 
                + type.getInfo().getClassname();
              throw new ProfileException( error, e );
          }
      }
  
      /**
       * Create a profile from a supplied configuration.
       *
       * @param type the component type that the profile qualifies
       * @param config a configuration fragment describing the deployment profile
       * @return the deployment profile
       * @exception ProfileException if an error occurs while attempting to create a profiles
       */
      public Profile createProfile( Type type, Configuration config ) 
        throws ProfileException
      {
          if( type == null )
          {
              throw new NullPointerException("type");
          }
          if( config == null )
          {
              throw new NullPointerException("config");
          }
  
          try
          {
              return PROFILE_BUILDER.build( type, config );
          }
          catch( Throwable e )
          {
              final String error = 
                "Profile build error while constructing a profile from supplied configuration:\n"
                + ConfigurationUtil.list( config );
              throw new ProfileException( error, e );
          }
      }
  
     /**
      * Add a set of profiles to the manager.
      * @param profiles the deployment profiles to added to the manager
      * @exception DuplicateProfileException if a profile of the same name 
      *   is already registered with the manager and the supplied profile 
      *   is a equal or lower in priority
      * @exception ProfileException if a profile verification failure occurs
      * @see #createProfile
      */
      public void addProfiles( Profile[] profiles ) throws DuplicateProfileException, ProfileException
      {
          for( int i=0; i<profiles.length; i++ )
          {
              Profile profile = profiles[i];
              addProfile( profile );
          }
      }
  
     /**
      * Add or replace profile to the manager.
      * @param profile the deployment profile to add to the manager
      * @exception DuplicateProfileException if a profile of the same name 
      *   is already registered with the manager and the replacement policy is true
      * @exception ProfileException if a profile verification failure occurs
      * @see #createProfile
      */
      public void addProfile( Profile profile ) throws DuplicateProfileException, ProfileException
      {
          addProfile( profile, true );
      }
  
     /**
      * Add a profile to the manager using the supplied profile and replacement policy
      * @param profile the deployment profile to add to the manager
      * @exception DuplicateProfileException if a profile of the same name 
      *   is already registered with the manager and the replacement policy is true
      * @exception ProfileException if a profile verification failure occurs
      * @see #createProfile
      */
      public void addProfile( Profile profile, boolean replace ) 
        throws DuplicateProfileException, ProfileException
      {
          boolean flag = false;
          if( profile == null )
          {
              throw new NullPointerException("profile");
          }
  
          if( getLogger() == null )
          {
              throw new IllegalStateException("logging");
          }
  
          try
          {
              verify( profile );
          }
          catch( Throwable e )
          {
              final String error = 
                "Could not register the profile: " + profile
                + " due to a verification failure.";
              throw new ProfileException( error, e );
          }
  
          if( getLogger().isDebugEnabled() )
          {
              getLogger().debug(
                    "add: " + profile + " " + profile.getMode() );
          }
  
          m_profiles.add( profile );
  
      }
      
      /**
       * Get the preferred profile for a supplied type.
       * @param type the component type
       * @return the profile matching the type
       * @exception UnknownTypeException if the type is unknown to the manager
       */
      public Profile getProfile( Type type ) throws UnknownTypeException
      {
          Iterator iterator = m_profiles.iterator();
          while( iterator.hasNext() )
          {
              Profile profile = (Profile) iterator.next();
              if( profile.getType().equals( type ) )
              {
                  return profile;
              }
          }
  
          if( m_parent != null )
          {
              return m_parent.getProfile( type );
          }
          else
          {
              return null;
          }
      }
  
      /**
       * Get the set of profiles declared for a particular type.
       * @param type the component type
       * @return the set of profile matching the type.
       * @exception UnknownTypeException if the type is unknown to the manager
       */
      public Profile[] getProfiles( Type type ) throws UnknownTypeException
      {
          if( type == null )
          {
              throw new NullPointerException("type");
          }
  
          ArrayList list = new ArrayList();
          if( m_parent != null )
          {
              Profile[] profiles = m_parent.getProfiles( type );
              for( int i=0; i<profiles.length; i++ )
              {
                   list.add( profiles[i] );
              }
          }
          
          Iterator iterator = m_profiles.iterator();
          while( iterator.hasNext() )
          {
              Profile profile = (Profile) iterator.next();
              if( profile.getType().equals( type ) )
              {
                  list.add( type );
              }
          }
  
          return (Profile[]) list.toArray( new Profile[0] );
      }
  
     /**
      * Locate the set of component profiles capable of services the supplied 
      * dependency.
      * @param dependency a service dependency descriptor
      * @return a set of profiles capable of servicing the supplied dependency
      */
      public Profile[] getProfiles( DependencyDescriptor dependency )
      {
          if( dependency == null )
          {
              throw new NullPointerException("dependency");
          }
  
          ArrayList list = new ArrayList();
          if( m_parent != null )
          {
              Profile[] profiles = m_parent.getProfiles( dependency );
              for( int i=0; i<profiles.length; i++ )
              {
                  list.add( profiles[i] );
              }
          }
  
          ReferenceDescriptor reference = dependency.getReference();
  
          Iterator iterator = m_profiles.iterator();
          while( iterator.hasNext() )
          {
              Profile profile = (Profile) iterator.next();
              Object service = profile.getType().getService( reference );
              if( service != null )
              {
                  list.add( profile );
              }
          }
  
          return (Profile[]) list.toArray( new Profile[0] );
      }
  
     /**
      * Locate the set of component profiles that provide the supplied extension.
      * @param stage a stage descriptor
      * @return a set of types that provide the supplied service
      */
      public Profile[] getProfiles( StageDescriptor stage )
      {
          if( stage == null )
          {
              throw new NullPointerException("stage");
          }
  
          ArrayList list = new ArrayList();
          if( m_parent != null )
          {
              Profile[] profiles = m_parent.getProfiles( stage );
              for( int i=0; i<profiles.length; i++ )
              {
                  list.add( profiles[i] );
              }
          }
  
          Iterator iterator = m_profiles.iterator();
          while( iterator.hasNext() )
          {
              Profile profile = (Profile) iterator.next();
              if( profile.getType().getExtension( stage ) != null )
              {
                  list.add( profile );
              }
          }
  
          return (Profile[]) list.toArray( new Profile[0] );
      }
  
     /**
      * Locate the set of profiles tied to a type capable of supporting a service 
      * referenced by a supplied dependency descriptor using the default selector.
      * @param dependency a service depedency descriptor
      * @return a set of profiles capable of servicing the supplied dependency
      */
      public Profile getProfile( DependencyDescriptor dependency )
      {
          return getProfile( dependency, m_selector );
      }
  
     /**
      * Locate the set of profiles tied to a type capable of supporting a service 
      * referenced by a supplied dependency descriptor using a supplied selector.
      * @param dependency a service depedency descriptor
      * @param selector a profile selector
      * @return a set of profiles capable of servicing the supplied dependency
      */
      public Profile getProfile( DependencyDescriptor dependency, ProfileSelector selector )
      {
          Profile[] profiles = getProfiles( dependency );
          return selector.select( profiles, dependency );
      }
  
     /**
      * Locate a profile tied to a type capable of supporting an extension 
      * referenced by a supplied stage descriptor usign the default selector.
      * @param stage a stage descriptor
      * @return a set of types that provide the supplied service
      */
      public Profile getProfile( StageDescriptor stage )
      {
          return getProfile( stage, m_selector );
      }
  
     /**
      * Locate a profile tied to a type capable of supporting an extension 
      * referenced by a supplied stage descriptor usign the a suplied selector.
      * @param stage a stage descriptor
      * @param selector a profile selector
      * @return a set of types that provide the supplied service
      */
      public Profile getProfile( StageDescriptor stage, ProfileSelector selector )
      {
          Profile[] profiles = getProfiles( stage );
          return selector.select( profiles, stage );
      }
  
     /**
      * Verify the supplied profile.
      * @param profile the profile to verify
      * @exception ProfileException if the verification failes
      */
      private void verify( Profile profile ) throws ProfileException
      {
          if( profile == null )
          {
              throw new NullPointerException("profile");
          }
  
          ProfileVerifier verifier = new ProfileVerifier();
          try
          {
              verifier.verifyType( profile, m_classloader );
          }
          catch( Throwable e )
          {
              final String error = "Verification failure for profile: " 
                + profile.getName() + " from type: "
                + profile.getType().getInfo().getClassname();
              throw new ProfileException( error, e );
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/profile/ProfileSelector.java
  
  Index: ProfileSelector.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.engine.profile;
  
  import org.apache.avalon.meta.model.Profile;
  import org.apache.avalon.meta.info.StageDescriptor;
  import org.apache.avalon.meta.info.DependencyDescriptor;
  
  /**
   * 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 autom assembly process.  A selector my be
   * declared via inclusion a implemetation class nameed <code>&lt;service-type&gt;Selector</code>.
   * Alternatively, a component author may declare a selection class explicitly via a
   * service dependency attribute with the attribute name of <code>urn:avalon:service.selector</code>.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  public interface ProfileSelector
  {
  
      /**
       * Returns the preferred profile form an available selection of 
       * candidate profiles.
       * @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
       */
      Profile select( Profile[] profiles, DependencyDescriptor dependency );
  
      /**
       * Returns the preferred profile form an available selection of candidates
       * @param profiles the set of profiles of potential extension providers
       * @param stage the stage dependency
       * @return the preferred provider or null if no satisfactory provider can be established
       */
      Profile select( Profile[] profiles, StageDescriptor stage );
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/profile/UnknownProfileException.java
  
  Index: UnknownProfileException.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.engine.profile;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * Exception to indicate that a profile is unknown.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  public final class UnknownProfileException
      extends CascadingException
  {
  
      /**
       * Construct a new <code>ApplianceException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public UnknownProfileException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>ApplianceException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public UnknownProfileException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/profile/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The <code>profile</code> package contains classes and interfaces for the {@link org.apache.avalon.assembly.engine.profile.ProfileManager} and related default implementations supporting the management of a repository of profiles.
  </p>
  </body>
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/service/DuplicateServiceException.java
  
  Index: DuplicateServiceException.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.engine.service;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * Exception raised in response to an attempt to override 
   * an existing service defintion.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  public final class DuplicateServiceException
      extends CascadingException
  {
  
      /**
       * Construct a new <code>DuplicateServiceException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public DuplicateServiceException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>DuplicateServiceException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public DuplicateServiceException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/service/ServiceException.java
  
  Index: ServiceException.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.engine.service;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * Exception to indicate that there was a service related error.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  public class ServiceException
      extends CascadingException
  {
  
      /**
       * Construct a new <code>ServiceException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public ServiceException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>ServiceException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public ServiceException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/service/ServiceManager.java
  
  Index: ServiceManager.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.engine.service;
  
  import java.util.List;
  import java.util.ArrayList;
  import java.util.Iterator;
  
  import org.apache.avalon.framework.Version;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.meta.info.Service;
  import org.apache.avalon.meta.info.builder.ServiceBuilder;
  import org.apache.avalon.meta.info.ReferenceDescriptor;
  
  /**
   * A service manager implemetation provides support for the creation, 
   * storage and retrival of service defintions.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  public class ServiceManager extends AbstractLogEnabled
  {
      //==============================================================
      // state
      //==============================================================
  
     /**
      * The classloader supplied to the manager.
      */
      private ClassLoader m_classloader;
  
     /**
      * The parent service manager (may be null)
      */
      private ServiceManager m_parent;
  
     /**
      * The service builder.
      */
      private static final ServiceBuilder DEFAULT_BUILDER = new ServiceBuilder();
  
      /**
       * List of service entries.
       */
      private List m_services = new ArrayList();
  
      //==============================================================
      // constructor
      //==============================================================
  
     /**
      * Creation of a new root service manager.
      * @param classloader the classloder to use
      * @exception NullPointerException if the classloader is null
      */
      public ServiceManager( ClassLoader classloader ) throws NullPointerException
      {
          this( classloader, null );
      }
  
     /**
      * Creation of a new service manager.
      * @param classloader the classloder to use
      * @param parent the parent type manager
      * @exception NullPointerException if the classloader is null
      */
      public ServiceManager( ClassLoader classloader, ServiceManager parent ) throws NullPointerException
      {
          if( classloader == null )
          {
              throw new NullPointerException("classloader");
          }
          m_classloader = classloader;
          m_parent = parent;
      }
  
      //==============================================================
      // implemetation
      //==============================================================
  
      /**
       * Create a services associated from a supplied path. 
       *
       * @param clazz the service class
       * @return the service defintions
       * @exception ServiceException if an error occurs during service creation
       */
      public Service createService( Class clazz ) throws ServiceException
      {
          if( clazz == null )
          {
              throw new NullPointerException("clazz");
          }
  
          try
          {
              return DEFAULT_BUILDER.build( clazz.getName(), clazz.getClassLoader() );
          }
          catch( Throwable e )
          {
              final String error = 
                 "Could not create a service relative to the path: " 
                 + clazz.getName() + " due to a service build error.";
              throw new ServiceException( error, e );
          }
      }
  
      /**
       * Create a service instance based on a supplied classname.
       *
       * @param classname the component implementation classname
       * @return the service defintion
       * @exception ServiceException if an error occurs during service creation
       */
      public Service createService( String classname ) throws ServiceException
      {
          if( classname == null )
          {
              throw new NullPointerException("classname");
          }
  
          try
          {
              Class clazz = m_classloader.loadClass( classname );
              return createService( clazz );
          }
          catch( Throwable e )
          {
              final String error = 
                "Unexpected error while attempting to build a service from the classname: " + classname;
              throw new ServiceException( error, e );
          }
      }
  
      /**
       * Locate a {@link Service} instances associated with the 
       * supplied classname and version. If a service defintion is not
       * found locally, the implementation redirects the request to 
       * the parent service manager.
       *
       * @param classname the service class name
       * @param version the service version
       * @return the service matching the supplied classname and version.
       * @exception UnknownServiceException if a matching service cannot be found
       */
      public Service getService( String classname, Version version ) throws UnknownServiceException
      {
          return getService( new ReferenceDescriptor( classname, version ) );
      }
  
      /**
       * Locate a {@link Service} instances associated with the 
       * supplied referecne descriptor. If a service defintion is not
       * found locally, the implementation redirects the request to 
       * the parent service manager.
       *
       * @param classname the service class name
       * @param reference the reference descriptor
       * @return the service matching the supplied descriptor.
       * @exception UnknownServiceException if a matching service cannot be found
       */
      public Service getService( ReferenceDescriptor reference ) throws UnknownServiceException
      {
          Service service = getLocalService( reference );
          if( service == null )
          {
              if( m_parent != null )
              {
                  return m_parent.getService( reference );
              }
              else
              {
                  final String error = "Unknown service defintion: " + reference;
                  throw new UnknownServiceException( error );
              }
          }
          return service;
      }
  
      private Service getLocalService( ReferenceDescriptor reference )
      {
          Iterator iterator = m_services.iterator();
          while( iterator.hasNext() )
          {
              Service service = (Service) iterator.next();
              if( service.equals( reference ) )
              {
                  return service;
              }
          }
          return null;
      }
  
      /**
       * Add a service to the manager.
       *
       * @param service the service defintion
       * @exception DuplicateServiceException if the service already exists
       * @exception ServiceException if the service definition is invalid
      */
      public void addService( Service service ) throws DuplicateServiceException, ServiceException
      {
          if( getLogger() == null )
          {
              throw new IllegalStateException("logging");
          }
  
          //
          // make sure that there is not already a local defintion for 
          // this service
          //
  
          try
          {
              getService( service.getReference() );
              throw new DuplicateServiceException( service.toString() );
          }
          catch( UnknownServiceException use )
          {
              // continue
          }
          
          //
          // make sure we are dealing with a service that is verified
          //
  
          verifyService( service );
  
          //
          // make sure that there is not already a local defintion for 
          // this service
          //
  
          m_services.add( service );
   
          if( getLogger().isDebugEnabled() )
          {
              StringBuffer buffer = new StringBuffer();
              buffer.append( "add: " + service.getClassname() );
              buffer.append( ":" + service.getVersion() );
              String[] names = service.getAttributeNames();
              buffer.append( ", entries: " + service.getEntries().length );
              buffer.append( ", attributes: " + service.getAttributeNames().length );
              getLogger().debug( buffer.toString() );
          }
      }
  
     /**
      * Verify that a class exists within the classloader representing the 
      * service type.
      * @param service the service to verify
      * @exception ServiceException if a verification error occurs
      */
      private void verifyService( Service service ) throws ServiceException
      {
          Class clazz;
          try
          {
              clazz = m_classloader.loadClass( service.getClassname() );
          }
          catch( Throwable e )
          {
              final String error = "Unresolvable service class.";
              throw new ServiceException( error, e );
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/service/ServiceRuntimeException.java
  
  Index: ServiceRuntimeException.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.engine.service;
  
  import org.apache.avalon.framework.CascadingRuntimeException;
  
  /**
   * Exception to indicate that there was a seervice related runtime error.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  public final class ServiceRuntimeException
      extends CascadingRuntimeException
  {
  
      /**
       * Construct a new <code>ServiceRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public ServiceRuntimeException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>ServiceRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public ServiceRuntimeException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/service/UnknownServiceException.java
  
  Index: UnknownServiceException.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.engine.service;
  
  /**
   * Exception to indicate that a service defintioon is unknown within 
   * the scope of a service manager.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  public final class UnknownServiceException
      extends ServiceException
  {
  
      /**
       * Construct a new <code>UnknownServiceException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public UnknownServiceException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>UnknownServiceException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public UnknownServiceException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/service/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The <code>service</code> package contains classes and interfaces for the {@link org.apache.avalon.assembly.engine.service.ServiceManager} and related default implementations supporting the management of a repository of service defintions.
  </p>
  </body>
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/type/DuplicateTypeException.java
  
  Index: DuplicateTypeException.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.engine.type;
  
  /**
   * Exception raised in response to an attempt to override the defintion
   * of an existing type.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  public final class DuplicateTypeException
      extends TypeException
  {
  
      /**
       * Construct a new <code>DuplicateTypeException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public DuplicateTypeException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>DuplicateTypeException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public DuplicateTypeException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/type/TypeException.java
  
  Index: TypeException.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.engine.type;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * Exception to indicate that there was a type related error.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  public class TypeException
      extends CascadingException
  {
  
      /**
       * Construct a new <code>TypeException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public TypeException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>TypeException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public TypeException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/type/TypeManager.java
  
  Index: TypeManager.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.engine.type;
  
  import java.util.Hashtable;
  import java.util.Iterator;
  import java.util.Enumeration;
  import java.util.ArrayList;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.meta.info.Type;
  import org.apache.avalon.meta.info.builder.TypeBuilder;
  import org.apache.avalon.meta.info.ReferenceDescriptor;
  import org.apache.avalon.meta.info.DependencyDescriptor;
  import org.apache.avalon.meta.info.ServiceDescriptor;
  import org.apache.avalon.meta.info.StageDescriptor;
  import org.apache.avalon.meta.verifier.ComponentVerifier;
  
  /**
   * A type manager implemetation provides support for the creation, 
   * storage and retrival of component types.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  public class TypeManager extends AbstractLogEnabled
  {
      //==============================================================
      // static
      //==============================================================
  
     /**
      * The type builder.
      */
      private static final TypeBuilder DEFAULT_BUILDER = new TypeBuilder();
  
      //==============================================================
      // state
      //==============================================================
  
     /**
      * The classloader supplied to the manager.
      */
      private ClassLoader m_classloader;
  
     /**
      * The parent type manager (may be null)
      */
      private TypeManager m_parent;
  
      /**
       * Table of component types keyed by implementation classname.
       */
      private final Hashtable m_types = new Hashtable();
  
      //==============================================================
      // constructor
      //==============================================================
  
     /**
      * Creation of a new root type manager.
      * @param classloader the classloder to use
      * @exception NullPointerException if the classloader is null
      */
      public TypeManager( ClassLoader classloader ) throws NullPointerException
      {
          this( classloader, null );
      }
  
     /**
      * Creation of a new type manager.
      * @param classloader the classloder to use
      * @param parent the parent type manager
      * @exception NullPointerException if the classloader is null
      */
      public TypeManager( ClassLoader classloader, TypeManager parent ) throws NullPointerException
      {
          if( classloader == null )
          {
              throw new NullPointerException("classloader");
          }
          m_classloader = classloader;
          m_parent = parent;
      }
  
      //==============================================================
      // TypeManager
      //==============================================================
  
      /**
       * Create a new type instance.  The type instance returned is not 
       * registered with the manager.  To register the type the client 
       * must explicity declare the type using the {@link #addType} 
       * operation.
       *
       * @param clazz the component implementation class
       * @return the component type
       * @exception TypeException is a type creation error occurs
       * @see #addType
       */
      public Type createType( Class clazz ) throws TypeException
      {
          if( clazz == null )
          {
              throw new NullPointerException("clazz");
          }
  
          try
          {
              return DEFAULT_BUILDER.build( clazz.getName(), clazz.getClassLoader() );
          }
          catch( Throwable e )
          {
              final String error = 
                "Could not register a type relative to the path: " 
                + clazz.getName()
                + " due to a type build error.";
              throw new TypeException( error, e );
          }
      }
  
      /**
       * Create a type instance based on a supplied classname and classloader.
       *
       * @param classname the component implementation classname
       * @return the component type
       * @exception TypeException is a type creation error occurs
       */
      public Type createType( String classname ) throws TypeException
      {
          if( classname == null )
          {
              throw new NullPointerException("classname");
          }
  
          try
          {
              Class clazz = m_classloader.loadClass( classname );
              return createType( clazz );
          }
          catch( Throwable e )
          {
              final String error = 
                "Unexpected error while attempting to build a type from the classname: " + classname;
              throw new TypeException( error, e );
          }
      }
  
     /**
      * Add a type to the manager.
      * @param type the component type description.
      * @exception DuplicateTypeException if the supplied type is already registered
      * @exception TypeException if a type verification failure occurs
      * @see #createType
      */
      public void addType( Type type ) throws DuplicateTypeException, TypeException
      {
          if( type == null )
          {
              throw new NullPointerException("type");
          }
  
          if( getLogger() == null )
          {
              throw new IllegalStateException("logging");
          }
  
          final String classname = type.getInfo().getClassname();
  
          try
          {
              type = getType( classname );
              //throw new DuplicateTypeException( classname );
              return;
          }
          catch( UnknownTypeException ute )
          {
              try
              {
                  verify( type );
              }
              catch( Throwable e )
              {
                  final String error = 
                    "Could not register the type: " + classname
                    + " due to a verification failure.";
                  throw new TypeException( error, e );
              }
  
              if( getLogger().isDebugEnabled() )
              {
                  getLogger().debug("add: " + type );
              }
  
              m_types.put( classname, type );
          }
      }
  
      /**
       * Locate a {@link Type} instances associated with the 
       * supplied implementation classname.
       * @param clazz the component type implementation class.
       * @return the type matching the supplied implementation classname.
       * @exception UnknownTypeException if a matching type cannot be found
       */
      public Type getType( Class clazz ) throws UnknownTypeException
      {
          if( clazz == null )
          {
              throw new NullPointerException("clazz");
          }
  
          return getType( clazz.getName() );
      }
  
      /**
       * Locate a {@link Type} instances associated with the 
       * supplied implementation classname.
       * @param classname the component type implementation class name.
       * @return the type matching the supplied implementation classname.
       * @exception UnknownTypeException if a matching type cannot be found
       */
      public Type getType( String classname ) throws UnknownTypeException
      {
          if( classname == null )
          {
              throw new NullPointerException("classname");
          }
  
          Type type = (Type) m_types.get( classname );
          if( type == null )
          {
              if( m_parent != null )
              {
                  return m_parent.getType( classname );
              }
              else
              {
                  throw new UnknownTypeException( classname );
              }
          }
          return type;
      }
  
     /**
      * Locate the set of component types capable of services the supplied 
      * dependency.
      * @param dependency a service dependency descriptor
      * @return a set of types capable of servicing the supplied dependency
      */
      public Type[] getTypes( DependencyDescriptor dependency )
      {
          if( dependency == null )
          {
              throw new NullPointerException("dependency");
          }
  
          ArrayList list = new ArrayList();
          if( m_parent != null )
          {
              Type[] types = m_parent.getTypes( dependency );
              for( int i=0; i<types.length; i++ )
              {
                  list.add( types[i] );
              }
          }
  
          ReferenceDescriptor reference = dependency.getReference();
          Enumeration enum = m_types.elements();
          while( enum.hasMoreElements() )
          {
              Type type = (Type) enum.nextElement();
              Object service = type.getService( reference );
              if( service != null )
              {
                  list.add( type );
              }
          }
          return (Type[]) list.toArray( new Type[0] );
      }
  
     /**
      * Locate the set of component types that provide the supplied extension.
      * @param stage a stage descriptor
      * @return a set of types that support the supplied stage
      */
      public Type[] getTypes( StageDescriptor stage )
      {
          if( stage == null )
          {
              throw new NullPointerException("stage");
          }
  
          ArrayList list = new ArrayList();
          if( m_parent != null )
          {
              Type[] types = m_parent.getTypes( stage );
              for( int i=0; i<types.length; i++ )
              {
                  list.add( types[i] );
              }
          }
  
          Iterator iterator = m_types.entrySet().iterator();
          while( iterator.hasNext() )
          {
              Type type = (Type) iterator.next();
              if( type.getExtension( stage ) != null )
              {
                  list.add( type );
              }
          }
  
          return (Type[]) list.toArray( new Type[0] );
      }
  
     /**
      * Verify the intergrity of the supplied type.
      * @param type the type to verify
      * @exception Exception if an verification failure occurs
      */
      private void verify( Type type ) throws Exception
      {
          String name = type.getInfo().getName();
          Class clazz = getComponentClass( type );
          Class[] classes = getServiceClasses( type );
          ComponentVerifier verifier = new ComponentVerifier();
          verifier.verifyComponent( name, clazz, classes );
      }
  
      /**
       * Return the set of interface classes for a given type that are declared
       * or default to the "native" service access protocol and where the
       * service access model is undefined (i.e. native implementation).
       * access mode.
       *
       * @param type the component type
       * @return an array of classes represnting the type's service interfaces
       */
      private Class[] getServiceClasses( Type type )
      {
          ArrayList list = new ArrayList();
          ServiceDescriptor[] services = type.getServices();
          for( int i = 0; i < services.length; i++ )
          {
              ServiceDescriptor service = services[ i ];
              if( ( service.getAttribute( 
                "urn:avalon:service.protocol", "native" ).equals( "native" ) )
                && ( service.getAttribute( "urn:avalon:service.accessor", null ) == null ) )
              {
                  list.add( getServiceClass( services[ i ] ) );
              }
          }
          return ( Class[]) list.toArray( new Class[0] );
      }
  
      /**
       * Returns the component type implementation class.
       * @param type the component type descriptor
       * @return the class implementing the component type
       * @exception TypeException if a classloader error occurs
       */
      private Class getComponentClass( Type type ) throws TypeException
      {
          if( null == type )
          {
              throw new NullPointerException( "type" );
          }
  
          final String classname = type.getInfo().getClassname();
  
          try
          {
              return m_classloader.loadClass( classname );
          }
          catch( Throwable e )
          {
              final String error = 
                "Could not load implementation class for component type: "
                + classname;
              throw new TypeException( error, e );
          }
      }
  
      /**
       * Returns the service type implementation class.
       * @param service the service type descriptor
       * @return the class implementing the service type
       * @exception TypeRuntimeException if a classloader error occurs
       */
      private Class getServiceClass( ServiceDescriptor service ) throws TypeRuntimeException
      {
          final String classname = service.getReference().getClassname();
          try
          {
              return m_classloader.loadClass( classname );
          }
          catch( Throwable e )
          {
              final String error = 
                "Could not load implementation class for service type: "
                + classname;
              throw new TypeRuntimeException( error, e );
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/type/TypeRuntimeException.java
  
  Index: TypeRuntimeException.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.engine.type;
  
  import org.apache.avalon.framework.CascadingRuntimeException;
  
  /**
   * Exception to indicate that there was a type related runtime error.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  public final class TypeRuntimeException
      extends CascadingRuntimeException
  {
  
      /**
       * Construct a new <code>TypeRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public TypeRuntimeException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>TypeRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public TypeRuntimeException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/type/UnknownTypeException.java
  
  Index: UnknownTypeException.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.engine.type;
  
  /**
   * Exception to indicate that a type is unknown within the scope of a type manager.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/12/23 00:13:34 $
   */
  public final class UnknownTypeException
      extends TypeException
  {
  
      /**
       * Construct a new <code>UnknownTypeException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public UnknownTypeException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>UnknownTypeException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public UnknownTypeException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/type/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The <code>type</code> package contains classes and interfaces for the {@link org.apache.avalon.assembly.engine.type.TypeManager} and related default implementations supporting the management of a repository of component types.
  </p>
  </body>
  
  
  
  1.15      +1 -2      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/AbstractLifestyleHandler.java
  
  Index: AbstractLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/AbstractLifestyleHandler.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AbstractLifestyleHandler.java	21 Dec 2002 09:26:34 -0000	1.14
  +++ AbstractLifestyleHandler.java	23 Dec 2002 00:13:34 -0000	1.15
  @@ -70,7 +70,6 @@
   import org.apache.avalon.meta.model.Profile;
   import org.apache.avalon.assembly.appliance.Appliance;
   import org.apache.avalon.assembly.lifecycle.DeploymentService;
  -import org.apache.avalon.assembly.lifecycle.ContextHandler;
   import org.apache.avalon.lifecycle.Accessor;
   
   /**
  
  
  
  1.2       +11 -6     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/locator/Locator.java
  
  Index: Locator.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/locator/Locator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Locator.java	9 Dec 2002 12:11:36 -0000	1.1
  +++ Locator.java	23 Dec 2002 00:13:35 -0000	1.2
  @@ -65,23 +65,28 @@
       * @param key the lookup key URN
       * @return TRUE if the key is know else FALSE
       */
  -    boolean hasEntry( String key );
  +    boolean hasEntry( Object key );
   
      /**
       * Locate an object using a supplied key
  -    * @param key the lookup key URN
  +    * @param key the lookup key
       * @return object the object referenced by the key
       */
  -    Object locate( String key ) throws LocatorException;
  +    Object locate( Object key ) throws LocatorException;
   
       /**
        * Return the <code>Object</code> when you are finished with it.  This
        * allows the <code>Locator</code> to handle the End-Of-Life Lifecycle
  -     * events associated with the <code>Object</code>.  Please note, that no
  -     * Exception should be thrown at this point.
  +     * events associated with the <code>Object</code>.  
        *
        * @param object The <code>Object</code> to release.
        */
       void release( Object object );
  +
  +    /**
  +     * Notify the locator that it is free to release any reclaimable resources
  +     * it is referencing as a result of client locate requests.
  +     */
  +    void release();
   
   }
  
  
  
  1.2       +18 -7     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/locator/LocatorException.java
  
  Index: LocatorException.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/locator/LocatorException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LocatorException.java	9 Dec 2002 12:11:36 -0000	1.1
  +++ LocatorException.java	23 Dec 2002 00:13:35 -0000	1.2
  @@ -62,25 +62,25 @@
       extends CascadingException
   {
   
  -     final String m_key;
  +     final Object m_key;
   
       /**
        * Construct a new <code>LocatorException</code> instance.
        *
        * @param key the lookup URN.
        */
  -    public LocatorException( final String key )
  +    public LocatorException( final Object key )
       {
  -        this( key, null );
  +        this( key, null, null );
       }
   
       /**
        * Construct a new <code>LocatorException</code> instance.
        *
  -     * @param key the lookup URN.
        * @param message The detail message for this exception.
  +     * @param key the lookup URN.
        */
  -    public LocatorException( final String key, final String message )
  +    public LocatorException( final Object key, final String message )
       {
           this( key, message, null );
       }
  @@ -88,11 +88,22 @@
       /**
        * Construct a new <code>LocatorException</code> instance.
        *
  +     * @param message The detail message for this exception.
  +     * @param key the lookup URN.
  +     */
  +    public LocatorException( final Object key, final Throwable throwable )
  +    {
  +        this( key, null, throwable );
  +    }
  +
  +    /**
  +     * Construct a new <code>LocatorException</code> instance.
  +     *
        * @param key the lookup URN.
        * @param message The detail message for this exception.
        * @param throwable the root cause of the exception
        */
  -    public LocatorException( final String key, final String message, final Throwable throwable )
  +    public LocatorException( final Object key, final String message, final Throwable throwable )
       {
           super( message, throwable );
           m_key = key;
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/locator/DefaultLocator.java
  
  Index: DefaultLocator.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1997-2002 The Apache Software Foundation. All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software
   *    itself, if and wherever such third-party acknowledgments
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.avalon.assembly.locator;
  
  import java.io.Serializable;
  import java.util.Hashtable;
  import java.util.Iterator;
  import java.util.Map;
  
  import org.apache.avalon.framework.activity.Disposable;
  
  /**
   * Default implementation of Locator.
   * This implementation is a static hierarchial store of objects
   * accessible via a key.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   */
  public class DefaultLocator
      implements Locator
  {
      //--------------------------------------------------------------------
      // static
      //--------------------------------------------------------------------
  
      private static final class Hidden implements Serializable
      {
      }
  
      private static final Hidden m_hiddenMarker = new Hidden();
  
      //--------------------------------------------------------------------
      // state
      //--------------------------------------------------------------------
  
     /**
      * A map of data values keyed by entry label.
      */
      private final Map m_data;
  
     /**
      * A possibly null parent locator.
      */
      private final Locator m_parent;
  
     /**
      * The readonly state of the locator.
      */
      private boolean m_readOnly;
  
     /**
      * If a object in the locator data implements the {@link Reclaimable} 
      * interface, that object will be added to a list of reclaimers keyed
      * by the object it supplies through invocation of resolve under the
      * {@link Resolvable} interface.
      */
      private final Map m_reclaimers = new Hashtable();
  
      //--------------------------------------------------------------------
      // constructors
      //--------------------------------------------------------------------
  
      /**
       * Create a Locator with no parent.
       */
      public DefaultLocator()
      {
          this( (Locator)null );
      }
  
      /**
       * Create a Locator with specified data.
       *
       * @param contextData the context data
       */
      public DefaultLocator( final Map data )
      {
          this( data, null );
      }
  
      /**
       * Create a Locator with specified parent.
       *
       * @param parent the parent Locator (may be null)
       */
      public DefaultLocator( final Locator parent )
      {
          this( new Hashtable(), parent );
      }
  
      /**
       * Create a Locator with specified data and parent locator.
       *
       * @param data the locator data
       * @param parent the parent Locator (may be null)
       */
      public DefaultLocator( final Map data, final Locator parent )
      {
          m_parent = parent;
          m_data = data;
      }
  
      //--------------------------------------------------------------------
      // Locator
      //--------------------------------------------------------------------
  
     /**
      * Returns TRUE if the supplied key is know by the locator.
      * @param key the lookup key
      * @return TRUE if the key is know else FALSE
      */
      public boolean hasEntry( Object key )
      {
          try
          {
              get( key );
              return true;
          }
          catch( LocatorException le )
          {
              return false;
          }
      }
  
      /**
       * Retrieve an object from the Locator without applying 
       * resolution.
       *
       * @param key the key of the locator entry
       * @return the object resolved from the supplied key
       * @throws LocatorException if the key is unknown
       */
      protected Object get( final Object key )
          throws LocatorException
      {
          final Object data = m_data.get( key );
  
          if( null != data )
          {
              if( data instanceof Hidden )
              {
                  // Always fail.
                  final String message = "Unable to locate key: " + key;
                  throw new LocatorException( key, message );
              }
              return data;
          }
  
          // If data was null, check the parent
          if( null == m_parent )
          {
              // There was no parent, and no data
              final String message =
                  "Unable to resolve key: " + key;
              throw new LocatorException( key, message );
          }
  
          if( m_parent instanceof DefaultLocator )
          {
              return ((DefaultLocator)m_parent).get( key );
          }
          else
          {
              return m_parent.locate( key );
          }
      }
  
      /**
       * Retrieve an object from the Locator.
       *
       * @param key the key of the locator entry
       * @return the object resolved from the supplied key
       * @throws LocatorException if the key is unknown
       */
      public Object locate( final Object key )
          throws LocatorException
      {
  
          final Object data = get( key );
  
          if( data instanceof Reclaimable )
          {
              Object object = ( (Resolvable)data ).resolve( this );
              m_reclaimers.put( object, data );
              return object;
          }
  
          if( data instanceof Resolvable )
          {
              return ( (Resolvable)data ).resolve( this );
          }
  
          return data;
      }
  
     /**
      * Release all reclaimable resources referenced by the locator.
      */
      public void release()
      {
          Iterator iterator = m_reclaimers.entrySet().iterator();
          while( iterator.hasNext() )
          {
              release( iterator.next() );
          }
      }
  
      /**
       * Return the <code>Object</code> when you are finished with it.  This
       * allows the <code>Locator</code> to handle the End-Of-Life Lifecycle
       * events associated with the <code>Object</code>.
       *
       * @param object The <code>Object</code> to release.
       */
      public void release( Object object )
      {
          Reclaimable reclaimer = (Reclaimable) m_reclaimers.get( object );
          if( reclaimer != null )
          {
              m_reclaimers.remove( object );
              reclaimer.release( object, this );
          }
      }
  
      /**
       * Helper method for adding items to the locator.
       *
       * @param key the entry key
       * @param value the entry value
       * @throws IllegalStateException if context is read only
       */
      public void put( final Object key, final Object value )
          throws IllegalStateException
      {
          checkWriteable();
          if( null == value )
          {
              m_data.remove( key );
          }
          else
          {
              m_data.put( key, value );
          }
      }
  
      /**
       * Hides the entry in the locator.
       * After remove(key) has been called, a get(key)
       * will always fail, even if the parent context
       * has such a mapping.
       *
       * @param key the items key
       * @throws IllegalStateException if context is read only
       */
      public void hide( final Object key )
          throws IllegalStateException
      {
          checkWriteable();
          m_data.put( key, m_hiddenMarker );
      }
  
      //--------------------------------------------------------------------
      // internal
      //--------------------------------------------------------------------
  
      /**
       * Utility method to retrieve context data.
       *
       * @return the context data
       */
      protected final Map getData()
      {
          return m_data;
      }
  
      /**
       * Get parent context if any.
       *
       * @return the parent Locator (may be null)
       */
      protected final Locator getParent()
      {
          return m_parent;
      }
  
      /**
       * Make the context read-only.
       * Any attempt to write to the context via put()
       * will result in an IllegalStateException.
       */
      public void makeReadOnly()
      {
          m_readOnly = true;
      }
  
      /**
       * Utility method to check if context is writeable and if not throw exception.
       *
       * @throws IllegalStateException if context is read only
       */
      protected final void checkWriteable()
          throws IllegalStateException
      {
          if( m_readOnly )
          {
              final String message =
                  "Locator is write protected.";
              throw new IllegalStateException( message );
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/locator/Reclaimable.java
  
  Index: Reclaimable.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1997-2002 The Apache Software Foundation. All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software
   *    itself, if and wherever such third-party acknowledgments
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.avalon.assembly.locator;
  
  /**
   * This interface is used to indicate objects that need to be
   * reclaimed in some particular context.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version 1.0
   */
  public interface Reclaimable extends Resolvable
  {
      /**
       * Release an object
       *
       * @param the object to reclaim
       * @param locator the context with respect which to reclain the object
       */
      void release( Object object, Locator locator );
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/locator/Resolvable.java
  
  Index: Resolvable.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1997-2002 The Apache Software Foundation. All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software
   *    itself, if and wherever such third-party acknowledgments
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.avalon.assembly.locator;
  
  /**
   * This interface is used to indicate objects that need to be
   * resolved in some particular context.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version 1.0
   */
  public interface Resolvable
  {
      /**
       * Resolve a object to a value.
       *
       * @param context the contextwith respect which to resolve
       * @return the resolved object
       * @throws ContextException if an error occurs
       */
      Object resolve( Locator locator )
          throws LocatorException;
  }
  
  
  
  1.8       +4 -4      avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/profile/ProfileManagerTestCase.java
  
  Index: ProfileManagerTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/profile/ProfileManagerTestCase.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ProfileManagerTestCase.java	19 Dec 2002 10:46:16 -0000	1.7
  +++ ProfileManagerTestCase.java	23 Dec 2002 00:13:35 -0000	1.8
  @@ -6,16 +6,16 @@
   * the LICENSE.txt file.
   */
   
  -package org.apache.avalon.assembly.profile;
  +package org.apache.avalon.assembly.engine.profile;
   
   import java.io.File;
   import junit.framework.TestCase;
   import org.apache.avalon.framework.Version;
   import org.apache.avalon.framework.context.*;
   import org.apache.avalon.framework.logger.*;
  -import org.apache.avalon.assembly.service.*;
  -import org.apache.avalon.assembly.type.*;
  -import org.apache.avalon.assembly.profile.*;
  +import org.apache.avalon.assembly.engine.service.*;
  +import org.apache.avalon.assembly.engine.type.*;
  +import org.apache.avalon.assembly.engine.profile.*;
   import org.apache.avalon.meta.info.*;
   import org.apache.avalon.meta.model.*;
   import org.apache.avalon.assembly.TestCaseBase;
  
  
  
  1.5       +3 -3      avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/service/DefaultServiceManagerTestCase.java
  
  Index: DefaultServiceManagerTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/service/DefaultServiceManagerTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultServiceManagerTestCase.java	19 Dec 2002 10:46:17 -0000	1.4
  +++ DefaultServiceManagerTestCase.java	23 Dec 2002 00:13:35 -0000	1.5
  @@ -6,15 +6,15 @@
   * the LICENSE.txt file.
   */
   
  -package org.apache.avalon.assembly.service;
  +package org.apache.avalon.assembly.engine.service;
   
   import java.io.File;
   import junit.framework.TestCase;
   import org.apache.avalon.framework.Version;
   import org.apache.avalon.framework.context.*;
   import org.apache.avalon.framework.logger.*;
  -import org.apache.avalon.assembly.service.*;
  -import org.apache.avalon.assembly.type.*;
  +import org.apache.avalon.assembly.engine.service.*;
  +import org.apache.avalon.assembly.engine.type.*;
   import org.apache.avalon.meta.info.*;
   import org.apache.avalon.assembly.TestCaseBase;
   
  
  
  
  1.5       +3 -3      avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/type/TypeManagerTestCase.java
  
  Index: TypeManagerTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/type/TypeManagerTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TypeManagerTestCase.java	19 Dec 2002 10:46:17 -0000	1.4
  +++ TypeManagerTestCase.java	23 Dec 2002 00:13:35 -0000	1.5
  @@ -6,14 +6,14 @@
   * the LICENSE.txt file.
   */
   
  -package org.apache.avalon.assembly.type;
  +package org.apache.avalon.assembly.engine.type;
   
   import java.io.File;
   import junit.framework.TestCase;
   import org.apache.avalon.framework.context.*;
   import org.apache.avalon.framework.logger.*;
  -import org.apache.avalon.assembly.service.*;
  -import org.apache.avalon.assembly.type.*;
  +import org.apache.avalon.assembly.engine.service.*;
  +import org.apache.avalon.assembly.engine.type.*;
   import org.apache.avalon.meta.info.*;
   import org.apache.avalon.assembly.TestCaseBase;
   
  
  
  

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


Mime
View raw message