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/playground BasicComponent.xconfig
Date Fri, 29 Nov 2002 13:04:56 GMT
mcconnell    2002/11/29 05:04:56

  Modified:    assembly build.xml default.properties
               assembly/src/java/org/apache/avalon/assembly/appliance
                        Appliance.java ApplianceManager.java
                        ApplianceSelector.java DefaultAppliance.java
                        DefaultApplianceManager.java
               assembly/src/java/org/apache/avalon/assembly/profile
                        DefaultProfileManager.java ProfileManager.java
               assembly/src/test/org/apache/avalon/assembly
                        TestCaseBase.java
               assembly/src/test/org/apache/avalon/playground
                        BasicComponent.xconfig
  Added:       assembly/src/java/org/apache/avalon/assembly/lifecycle/composition
                        AbstractManager.java CompositionService.java
                        DefaultCompositionService.java
                        DefaultServiceManager.java package.html
               assembly/src/java/org/apache/avalon/assembly/lifecycle/configuration
                        ConfigurationService.java
                        DefaultConfigurationService.java package.html
               assembly/src/java/org/apache/avalon/assembly/lifecycle/context
                        AbstractContextHandler.java
                        ContextualizationService.java
                        DefaultContextualizationService.java package.html
               assembly/src/java/org/apache/avalon/assembly/lifecycle/disposal
                        DefaultDisposalService.java DisposalService.java
                        ExtendedDisposalService.java package.html
               assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization
                        DefaultInitializationService.java
                        ExtendedInitializationService.java
                        InitializationService.java package.html
               assembly/src/java/org/apache/avalon/assembly/lifecycle/logging
                        DefaultLoggingService.java LoggingService.java
                        package.html
               assembly/src/java/org/apache/avalon/assembly/lifecycle/parameters
                        DefaultParameterizationService.java
                        ParameterizationService.java package.html
               assembly/src/java/org/apache/avalon/assembly/lifecycle/startup
                        DefaultStartupService.java StartupService.java
                        package.html
               assembly/src/java/org/apache/avalon/assembly/lifestyle
                        AbstractLifestyleHandler.java
                        DefaultLifestyleService.java
                        LifestyleException.java LifestyleHandler.java
                        LifestyleRuntimeException.java
                        LifestyleService.java PooledLifestyleHandler.java
                        SingletonLifestyleHandler.java
                        ThreadLocalLifestyleHandler.java
                        TransientLifestyleHandler.java package.html
               assembly/src/java/org/apache/avalon/assembly/util
                        ExceptionHelper.java package.html
  Log:
  Factoring out of generic tools, managers and services from classloading and
  containment.
  
  Revision  Changes    Path
  1.2       +4 -0      avalon-sandbox/assembly/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/build.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.xml	24 Nov 2002 12:50:44 -0000	1.1
  +++ build.xml	29 Nov 2002 13:04:54 -0000	1.2
  @@ -27,6 +27,10 @@
       <pathelement location="${avalon-lifecycle.jar}"/>
       <pathelement location="${excalibur-logger.jar}"/>
       <pathelement location="${excalibur-configuration.jar}"/>
  +    <pathelement location="${excalibur-thread.jar}"/>
  +    <pathelement location="${excalibur-event.jar}"/>
  +    <pathelement location="${util.concurrent.jar}"/>
  +    <pathelement location="${commons-collections.jar}"/>
       <pathelement location="${build.classes}"/>
       <pathelement location="${checkstyle.jar}"/>
       <pathelement location="${xml-apis.jar}"/>
  
  
  
  1.2       +12 -0     avalon-sandbox/assembly/default.properties
  
  Index: default.properties
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/default.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- default.properties	24 Nov 2002 12:50:44 -0000	1.1
  +++ default.properties	29 Nov 2002 13:04:54 -0000	1.2
  @@ -53,6 +53,18 @@
   excalibur-logger.lib=${excalibur-logger.home}/build/lib
   excalibur-logger.jar=${excalibur-logger.lib}/excalibur-logger-1.0.jar
   
  +# ----- Excalibur event, version 1.0 or later -----
  +excalibur-event.home=${excalibur.home}/event
  +excalibur-event.lib=${excalibur-event.home}/build/lib
  +excalibur-event.jar=${excalibur-event.lib}/excalibur-event-1.0.1.jar
  +util.concurrent.jar=${excalibur-event.home}/lib/util.concurrent-1.3.1.jar
  +commons-collections.jar=${excalibur-event.home}/lib/commons-collections-20021002.jar
  +
  +# ----- Excalibur thread, version 1.0 or later -----
  +excalibur-thread.home=${excalibur.home}/thread
  +excalibur-thread.lib=${excalibur-thread.home}/build/lib
  +excalibur-thread.jar=${excalibur-thread.lib}/excalibur-thread-1.0.jar
  +
   # ----- Logkit -----
   logkit.home=${basedir}/../../jakarta-avalon-logkit
   logkit.lib=${logkit.home}/build/lib
  
  
  
  1.2       +20 -1     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Appliance.java	24 Nov 2002 12:50:44 -0000	1.1
  +++ Appliance.java	29 Nov 2002 13:04:54 -0000	1.2
  @@ -50,6 +50,8 @@
   
   package org.apache.avalon.assembly.appliance;
   
  +import org.apache.avalon.assembly.lifestyle.LifestyleException;
  +import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.meta.model.Profile;
   
  @@ -146,5 +148,22 @@
        * @param appliance the appliance that will handle the stage
        */
       void addExtensionProvider( StageDescriptor stage, Appliance appliance );
  +
  +   /**
  +    * Activate a service provided by the appliance.
  +    * @param appliance the appliance to deploy
  +    */
  +    Object access( DependencyDescriptor dependency ) throws LifestyleException;
  +
  +   /**
  +    * Activate an extension handler provided by the appliance.
  +    * @param appliance the appliance to deploy
  +    */
  +    Object access( StageDescriptor stage ) throws LifestyleException;
  +
  +   /**
  +    * Release a reference to a service provided by this appliance.
  +    */
  +    void release( Object object );
   
   }
  
  
  
  1.3       +40 -1     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceManager.java
  
  Index: ApplianceManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ApplianceManager.java	26 Nov 2002 18:04:22 -0000	1.2
  +++ ApplianceManager.java	29 Nov 2002 13:04:54 -0000	1.3
  @@ -50,6 +50,10 @@
   
   package org.apache.avalon.assembly.appliance;
   
  +import java.util.Map;
  +
  +import org.apache.avalon.framework.logger.Logger;
  +import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
  @@ -87,6 +91,27 @@
         throws ApplianceException;
   
      /**
  +    * Creation of a new Appliance instance based on a supplied profile, enabled 
  +    * state and activation policy.
  +    * @param profile the component deployment profile
  +    * @param enabled the enabled state of the appliance
  +    * @param activation the activation policy 
  +    * @param map a map of supplimentary deployment context entries
  +    * @return the appliance
  +    */
  +    public Appliance createAppliance( 
  +      Profile profile, boolean enabled, boolean activation, Map map )
  +      throws ApplianceException;
  +
  +    /**
  +     * Add a appliance to the manager.
  +     * @param appliance the appliance to add to the manager
  +     * @exception DuplicateApplianceException if an appliance has already been registered
  +     *   for the underlying profile
  +     */
  +    void addAppliance( Appliance appliance ) throws DuplicateApplianceException, AssemblyException;
  +
  +   /**
       * Return the set of appliance istances capable of supporting the supplied dependency.
       * @param dependency a service dependency descriptor
       * @return a matching appliance
  @@ -115,5 +140,19 @@
       * @return the selected appliance (possibly null)
       */
       Appliance getAppliance( StageDescriptor stage, ApplianceSelector selector );
  +
  +   /**
  +    * Select an appliance supporting the supplied dependency using a default selector.
  +    * @param dependency a service depedency descriptor
  +    * @return the selected appliance (possibly null)
  +    */
  +    Appliance getAppliance( DependencyDescriptor dependency );
  +
  +   /**
  +    * Select an appliance capable of supporting the supplied stage 
  +    * @param stage a lifecycle stage
  +    * @return the selected appliance (possibly null)
  +    */
  +    Appliance getAppliance( StageDescriptor stage );
   
   }
  
  
  
  1.2       +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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ApplianceSelector.java	24 Nov 2002 12:50:44 -0000	1.1
  +++ ApplianceSelector.java	29 Nov 2002 13:04:54 -0000	1.2
  @@ -64,7 +64,7 @@
    * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
    * @version $Revision$ $Date$
    */
  -public interface ApplianceSelector extends ProfileSelector
  +public interface ApplianceSelector
   {
       /**
        * Returns the preferred appliance form an available selection of 
  
  
  
  1.2       +186 -23   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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultAppliance.java	24 Nov 2002 12:50:44 -0000	1.1
  +++ DefaultAppliance.java	29 Nov 2002 13:04:54 -0000	1.2
  @@ -52,6 +52,23 @@
   
   import java.util.Hashtable;
   
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.logger.Logger;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.configuration.Configuration;
  +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.ContextException;
  +import org.apache.avalon.framework.context.Contextualizable;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.Serviceable;
  +import org.apache.avalon.framework.service.ServiceException;
  +
  +import org.apache.avalon.assembly.lifestyle.LifestyleException;
  +import org.apache.avalon.assembly.lifestyle.LifestyleService;
  +import org.apache.avalon.assembly.lifestyle.LifestyleHandler;
  +import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.meta.model.Profile;
   
  @@ -59,7 +76,7 @@
    * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
    * @version $Revision$ $Date$
    */
  -public class DefaultAppliance implements Appliance
  +public class DefaultAppliance extends AbstractLogEnabled implements Appliance, Serviceable, Contextualizable, Initializable
   {
       //=====================================================================
       // state
  @@ -81,6 +98,26 @@
        */
       private boolean m_activation = true;
   
  +   /**
  +    * The classloader that will be supplied to the lifestyle manager.
  +    */
  +    private ClassLoader m_classloader;
  +
  +    /**
  +     * The lifestyle service from which the appliance lifestyle handler is established.
  +     */
  +    private LifestyleService m_lifestyle;
  +
  +    /**
  +     * The lifestyle handler.
  +     */
  +    private LifestyleHandler m_handler;
  +
  +    /**
  +     * The deployment context.
  +     */
  +    private Context m_context;
  +
       /**
        * The dependencies providers keyed by role name.
        */
  @@ -91,35 +128,130 @@
        */
       private final Hashtable m_managers = new Hashtable();
   
  -    //=====================================================================
  -    // constructor
  -    //=====================================================================
  -
       /**
  -     * Create an new Appliance instance.
  -     *
  -     * @param profile the component profile to be managed by the appliance
  -     * @param enabled the enabled state of the appliance
  -     * @param policy the appliance activation policy - TRUE if the appliance should 
  -     *   should be auto-activated on startup of the host container
  +     * Flag holding the initialized state of the appliance.
        */
  -    public DefaultAppliance( final Profile profile,
  -                    final boolean enabled,
  -                    final boolean policy )
  +    private boolean m_initialized = false;
  +
  +    //==============================================================
  +    // Contextualizable
  +    //==============================================================
  +
  +   /**
  +    * <p>Application of a runtime context to this appliance.
  +    * Context entries that may be supplied to an appliance manager are 
  +    * detailed in the following table.</p>
  +    * <table>
  +    *   <tr>
  +    *     <td>key</td><td>type</td><td>default</td>
  +    *   </tr>
  +    *   <tr>
  +    *     <td>avalon:classloader</td>
  +    *     <td>{@link ClassLoader}</td>
  +    *     <td>The classloader from to be supplied to the lifestyle manager.</td> 
  +    *   </tr>
  +    *   <tr>
  +    *     <td>assembly:appliance.profile</td>
  +    *     <td>{@link Profile}</td>
  +    *     <td>The profile backing this appliance.</td> 
  +    *   </tr>
  +    *   <tr>
  +    *     <td>assembly:appliance.enabled</td>
  +    *     <td>{@link Boolean}</td>
  +    *     <td>The enabled state of the appliance.</td> 
  +    *   </tr>
  +    *   <tr>
  +    *     <td>assembly:appliance.activation</td>
  +    *     <td>{@link Boolean}</td>
  +    *     <td>The activation policy for the appliance.</td> 
  +    *   </tr>
  +    *   <tr>
  +    *     <td>assembly:appliance.context</td>
  +    *     <td>{@link Context}</td>
  +    *     <td>Supplimentary (option) deployment context.</td> 
  +    *   </tr>
  +    * </table>
  +    * @param context the runtime context
  +    */
  +    public void contextualize( Context context ) throws ContextException
  +    {
  +        m_context = context;
  +        m_classloader = (ClassLoader) context.get( "assembly:appliance.classloader" );
  +        m_profile = (Profile)context.get( "assembly:appliance.profile" );
  +
  +        try
  +        {
  +            m_enabled = ((Boolean)context.get( "assembly:appliance.enabled" )).booleanValue();
  +        }
  +        catch( ContextException e )
  +        {
  +            m_enabled = true;
  +        }
  +
  +        try
  +        {
  +            m_activation = ((Boolean)context.get( "assembly:appliance.activation" )).booleanValue();
  +        }
  +        catch( ContextException e )
  +        {
  +            m_activation = false;
  +        }
  +    }
  +
  +    //==============================================================
  +    // Serviceable
  +    //==============================================================
  +
  +   /**
  +    * Supply of supporting services to this componet by its manager.
  +    * This includes a deployment service that will assigned to the 
  +    * lifecycle handler.
  +    */
  +    public void service( ServiceManager manager ) throws ServiceException
  +    {
  +        m_lifestyle = (LifestyleService) manager.lookup( "assembly:lifestyle-service" );
  +    }
  +
  +    //==============================================================
  +    // Initializable
  +    //==============================================================
  +
  +   /**
  +    * Initialization of the appliance.  The implementation verifies  
  +    * initial appliance state including verification of logging channel
  +    * assignment and context provision, followed by establishment of a 
  +    * lifestyle handler.
  +    *
  +    * @exception if a invalid state is encounter
  +    */
  +    public void initialize() throws Exception 
       {
  -        if( profile == null )
  +        if( getLogger() == null )
  +        {
  +            throw new ApplianceException("logger");
  +        }
  +        if( m_profile == null )
           {
  -            throw new NullPointerException("profile");
  +            throw new ApplianceException("context");
           }
   
  -        m_profile = profile;
  -        m_enabled = enabled;
  -        m_activation = policy;
  +        try
  +        {
  +            m_handler = m_lifestyle.createHandler( this, m_classloader, getLogger(), m_context );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Could not initialize appliance due to a lifestyle handler establishment failure.";
  +            throw new ApplianceException( error, e );
  +        }
  +
  +        m_initialized = true;
       }
   
  -     //=====================================================================
  -     // implementation
  -     //=====================================================================
  +    //=====================================================================
  +    // implementation
  +    //=====================================================================
   
       /**
        * Return the profile backing the appliance.
  @@ -236,6 +368,37 @@
       public Appliance getExtensionProvider( StageDescriptor stage )
       {
           return (Appliance)m_managers.get( stage );
  +    }
  +
  +   /**
  +    * Activate a service provided by the appliance.
  +    * @param appliance the appliance to deploy
  +    */
  +    public Object access( DependencyDescriptor dependency ) throws LifestyleException
  +    {
  +        return m_handler.access( dependency );
  +    }
  +
  +   /**
  +    * Activate an extension handler provided by the appliance.
  +    * @param appliance the appliance to deploy
  +    */
  +    public Object access( StageDescriptor stage ) throws LifestyleException
  +    {
  +        return m_handler.access( stage );
  +    }
  +
  +   /**
  +    * Release a reference to a service provided by this appliance.
  +    */
  +    public void release( Object object )
  +    {
  +        m_handler.release( object );
  +    }
  +
  +    public String toString()
  +    {
  +        return "[appliance: " + getProfile() + " id:" + System.identityHashCode( this ) + "]";
       }
   
   }
  
  
  
  1.2       +243 -37   avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceManager.java
  
  Index: DefaultApplianceManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultApplianceManager.java	24 Nov 2002 12:50:44 -0000	1.1
  +++ DefaultApplianceManager.java	29 Nov 2002 13:04:54 -0000	1.2
  @@ -55,18 +55,24 @@
   import java.util.Iterator;
   import java.util.ArrayList;
   
  -import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.DefaultServiceManager;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.Serviceable;
   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.activity.Initializable;
  -
  -import org.apache.avalon.meta.model.Profile;
  -import org.apache.avalon.assembly.appliance.builder.ApplianceBuilder;
  +import org.apache.avalon.framework.logger.Logger;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.meta.info.ReferenceDescriptor;
  +import org.apache.avalon.meta.model.Profile;
  +import org.apache.avalon.assembly.lifestyle.LifestyleService;
  +import org.apache.avalon.assembly.lifestyle.DefaultLifestyleService;
   
   /**
    * The default appliance manager provides support for {@link Appliance}
  @@ -76,17 +82,14 @@
    * @version $Revision$ $Date$
    */
   public final class DefaultApplianceManager extends AbstractLogEnabled 
  -  implements ApplianceManager, Contextualizable, Initializable
  +  implements ApplianceManager, Contextualizable, Serviceable, Initializable
   {
   
       //==================================================================
       // static
       //==================================================================
   
  -   /**
  -    * The default appliacnce buildier.
  -    */
  -    private static final ApplianceBuilder DEFAULT_BUILDER = new ApplianceBuilder();
  +    public static final String ASSEMBLY_SERVICE_KEY = "assembly:assembly-service";
   
       //==================================================================
       // state
  @@ -113,9 +116,62 @@
       private ClassLoader m_classloader;
   
       /**
  -     * Table of component profiles keyed by profile name.
  +     * Table of registered appliance instances keyed by profile name.
        */
  -    private final Map m_appliances = new Hashtable();
  +    private final ArrayList m_appliances = new ArrayList();
  +
  +    /**
  +     * The service manager holding the lifestyle service.
  +     */
  +    private ServiceManager m_manager;
  +    
  +    /**
  +     * The supplied context.
  +     */
  +    private Context m_context;
  +    
  +    /**
  +     * The assembly service.
  +     */
  +    private AssemblyService m_assembly;
  +    
  +
  +    //==============================================================
  +    // Serviceable
  +    //==============================================================
  +
  +   /**
  +    * <p>Application of a supporting service to the appliance manager.</p>
  +    * <table>
  +    *   <tr>
  +    *     <td>key</td><td>type</td><td>description</td>
  +    *   </tr>
  +    *   <tr>
  +    *     <td>assembly:lifecycle-service</td>
  +    *     <td>{@link org.apache.avalon.assembly.lifestyle.LifestyleService}</td>
  +    *     <td>The lifestyle service to provide to appliance instances created 
  +    *         by this manager.</td> 
  +    *   </tr>
  +    *   <tr>
  +    *     <td>assembly:assembly-service</td>
  +    *     <td>{@link org.apache.avalon.assembly.AssemblyService}</td>
  +    *     <td>The assembly service.</td> 
  +    *   </tr>
  +    * </table>
  +    * @param context the runtime context
  +    */
  +    public void service( ServiceManager manager ) throws ServiceException
  +    {
  +        m_manager = manager;
  +        try
  +        {
  +            m_assembly = (AssemblyService) manager.lookup( ASSEMBLY_SERVICE_KEY );
  +        }
  +        catch( ServiceException se )
  +        {
  +            m_assembly = bootstrapAssemblyService( manager );
  +        }
  +    }
   
       //==============================================================
       // Contextualizable
  @@ -130,20 +186,26 @@
       *     <td>key</td><td>type</td><td>default</td>
       *   </tr>
       *   <tr>
  -    *     <td>avalon:type.classloader</td>
  +    *     <td>assembly:classloader</td>
       *     <td>java.lang.ClassLoader</td>
  -    *     <td>The context classloader will be used by default if not value is supplied.</td> 
  +    *     <td>The context classloader will be used by default if no value is supplied.</td> 
       *   </tr>
       *   <tr>
       *     <td>assembly:parent</td>
       *     <td>{@link org.apache.avalon.assembly.appliance.ApplianceManager}</td>
       *     <td>In no value suppled, this appliance manager will be considered as a root manager.</td> 
       *   </tr>
  +    *   <tr>
  +    *     <td>assembly:logger</td>
  +    *     <td>{@link org.apache.avalon.framework.logger.Logger}</td>
  +    *     <td>The base logger from which component loggers will be created.</td> 
  +    *   </tr>
       * </table>
       * @param context the runtime context
       */
       public void contextualize( Context context )
       {
  +        m_context = context;
           try
           {
               m_parent = (ApplianceManager) context.get( "assembly:parent" );
  @@ -179,16 +241,27 @@
       */
       public void initialize() throws Exception
       {
  +        if( getLogger() == null )
  +        {
  +            throw new IllegalStateException("logger");
  +        }
           if( !m_contextualized )
           {
               throw new IllegalStateException("contextualize");
           }
  -        if( getLogger() == null )
  +        if( m_manager == null )
           {
  -            throw new IllegalStateException("logger");
  +            throw new IllegalStateException("service");
           }
   
  -        m_initialized = true;
  +        final String key = "assembly:lifestyle-service";
  +        if( !m_manager.hasService( key ) )
  +        {
  +            DefaultServiceManager manager = new DefaultServiceManager( m_manager );
  +            manager.put( key, bootstrapLifestyleService( m_manager ) );
  +            manager.makeReadOnly();
  +            m_manager = manager;
  +        }
       }
   
       //==================================================================
  @@ -205,17 +278,18 @@
       public Appliance createAppliance( Profile profile, Configuration config )
         throws ApplianceException
       {
  -        try
  +        if( profile == null )
           {
  -            return DEFAULT_BUILDER.createAppliance( profile, config );
  +            throw new NullPointerException( "profile" );
           }
  -        catch( Throwable e )
  +        if( config == null )
           {
  -            final String error = 
  -              "Build failure while attempting to create appliance for profile: " 
  -              + profile;
  -            throw new ApplianceException( error, e );
  +            throw new NullPointerException( "config" );
           }
  +
  +        final boolean enabled = config.getAttributeAsBoolean( "enabled", true );
  +        final boolean activation = getActivationMode( config );
  +        return createAppliance( profile, enabled, activation );
       }
   
      /**
  @@ -227,8 +301,65 @@
       * @return the appliance
       */
       public Appliance createAppliance( Profile profile, boolean enabled, boolean activation )
  +      throws ApplianceException
  +    {
  +        return createAppliance( profile, enabled, activation, null );
  +    }
  +
  +   /**
  +    * Creation of a new Appliance instance based on a supplied profile, enabled 
  +    * state and activation policy.
  +    * @param profile the component deployment profile
  +    * @param enabled the enabled state of the appliance
  +    * @param activation the activation policy 
  +    * @param map a map of context entries to be included in the deployment context 
  +    * @return the appliance
  +    */
  +    public Appliance createAppliance( 
  +      Profile profile, boolean enabled, boolean activation, Map map )
  +      throws ApplianceException
       {
  -        return DEFAULT_BUILDER.createAppliance( profile, enabled, activation );
  +        if( profile == null )
  +        {
  +            throw new NullPointerException( "profile" );
  +        }
  +
  +        try
  +        {
  +            DefaultAppliance appliance = new DefaultAppliance();
  +
  +            appliance.enableLogging(
  +              getLogger().getChildLogger( profile.getName() ) );
  +
  +            DefaultContext context;
  +            if( map == null )
  +            {
  +                context = new DefaultContext( m_context );
  +            }
  +            else 
  +            {
  +                context = new DefaultContext( map, m_context );
  +            }
  +            context.put( "assembly:appliance.profile", profile );
  +            context.put( "assembly:appliance.enabled", new Boolean( enabled ) );
  +            context.put( "assembly:appliance.activation", new Boolean( activation ) );
  +            context.put( "assembly:appliance.classloader", m_classloader );
  +            context.makeReadOnly();
  +            appliance.contextualize( context );
  +            appliance.service( m_manager );
  +            appliance.initialize();
  +
  +            m_assembly.assemble( appliance );
  +
  +            return appliance;
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Build failure while attempting to create appliance from a qualified profile: " 
  +              + profile;
  +            throw new ApplianceException( error, e );
  +        }
       }
   
      /**
  @@ -249,7 +380,7 @@
           }
   
           ReferenceDescriptor reference = dependency.getReference();
  -        Iterator iterator = m_appliances.entrySet().iterator();
  +        Iterator iterator = m_appliances.iterator();
           while( iterator.hasNext() )
           {
               Appliance appliance = (Appliance) iterator.next();
  @@ -280,7 +411,7 @@
               }
           }
   
  -        Iterator iterator = m_appliances.entrySet().iterator();
  +        Iterator iterator = m_appliances.iterator();
           while( iterator.hasNext() )
           {
               Appliance appliance = (Appliance) iterator.next();
  @@ -319,9 +450,25 @@
           return selector.select( appliances, stage );
       }
   
  -    //==================================================================
  -    // implemetation
  -    //==================================================================
  +   /**
  +    * Select an appliance supporting the supplied dependency using a default selector.
  +    * @param dependency a service depedency descriptor
  +    * @return the selected appliance (possibly null)
  +    */
  +    public Appliance getAppliance( DependencyDescriptor dependency )
  +    {
  +        return getAppliance( dependency, new DefaultApplianceSelector() );
  +    }
  +
  +   /**
  +    * Select an appliance capable of supporting the supplied stage 
  +    * @param stage a lifecycle stage
  +    * @return the selected appliance (possibly null)
  +    */
  +    public Appliance getAppliance( StageDescriptor stage )
  +    {
  +        return getAppliance( stage, new DefaultApplianceSelector() );
  +    }
   
       /**
        * Add a appliance to the manager.
  @@ -329,22 +476,81 @@
        * @exception DuplicateApplianceException if an appliance has already been registered
        *   for the undrlying profile
        */
  -    public void addAppliance( Appliance appliance ) throws DuplicateApplianceException
  +    public void addAppliance( Appliance appliance ) throws DuplicateApplianceException, AssemblyException
       {
           if( appliance == null )
           {
               throw new NullPointerException( "appliance" );
           }
  +        if( m_appliances.contains( appliance ) )
  +        {
  +            throw new DuplicateApplianceException( appliance.toString() );
  +        }
  +        m_appliances.add( appliance );
  +    }
   
  -        final String key = appliance.getProfile().getName();
  +    //==================================================================
  +    // implemetation
  +    //==================================================================
   
  -        if( m_appliances.get( key ) != null )
  +    /**
  +     * Utility method to get the activation mode for the profile.
  +     * If the activation attribute value is equal to "startup"
  +     * TRUE is returned.  If the value if "lazy", FALSE is returned.
  +     * Otherwise the value will be resolved as a boolean.
  +     *
  +     * @param config the profile configuration
  +     * @return boolean TRUE if activation on startup
  +     */
  +    private boolean getActivationMode( Configuration config )
  +    {
  +        String value = config.getAttribute( "activation", "lazy" );
  +        if( value.equalsIgnoreCase( "startup" ) )
           {
  -            throw new DuplicateApplianceException( key );
  +            return true;
           }
  -
  -        m_appliances.put( key, appliance );
  +        if( value.equalsIgnoreCase( "lazy" ) )
  +        {
  +            return false;
  +        }
  +        return config.getAttributeAsBoolean( "activation", false );
       }
   
  +   /**
  +    * Utility to create the default lifestyle service.
  +    * @param manager a service manager
  +    * @return the bootstrap lifestyle service
  +    */
  +    private LifestyleService bootstrapLifestyleService( ServiceManager manager ) throws Exception
  +    {
  +        DefaultLifestyleService lifestyle = new DefaultLifestyleService();
  +        lifestyle.enableLogging( getLogger().getChildLogger( "lifestyle" ) );
  +        lifestyle.service( manager );
  +        lifestyle.contextualize( m_context );
  +        lifestyle.initialize();
  +        return lifestyle;
  +    }
   
  +   /**
  +    * Utility to create the default assembly service.
  +    * @param manager a service manager
  +    * @return the bootstrap assembly service
  +    */
  +    private AssemblyService bootstrapAssemblyService( ServiceManager manager ) throws ServiceException
  +    {
  +        try
  +        {
  +            DefaultAssemblyService assembly = new DefaultAssemblyService();
  +            assembly.enableLogging( getLogger().getChildLogger( "assembly" ) );
  +            assembly.service( manager );
  +            assembly.contextualize( m_context );
  +            assembly.initialize();
  +            return assembly;
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Internal error while preparing boostrap assembly service.";
  +            throw new ServiceException( ASSEMBLY_SERVICE_KEY, error, e );
  +        }
  +    }
   }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/AbstractManager.java
  
  Index: AbstractManager.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.lifecycle.composition;
  
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.meta.info.DependencyDescriptor;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  /**
   * Internal helper class the handles the functional requirements of
   * both ServiceManager and ServiceLocator.
   * @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
   */
  class AbstractManager
  {
      /**
       * A map of resources keyed by lookup role.
       */
      private Appliance m_appliance;
  
      /**
       * Creation of a new manager.
       * @param providers the resource map
       * @exception if an error occurs while mapping the service providers to roles
       */
      public AbstractManager( Appliance appliance )
      {
          m_appliance = appliance;
      }
  
      /**
       * Return TRUE is the manager has a resoruce for the role.
       * @param role the role name to look for in the resource map
       * @return TRUE is a resource exists for the role
       */
      public boolean has( String role )
      {
          return ( m_appliance.getServiceProvider( role ) != null );
      }
  
      /**
       * Returns the service object.
       * @return the service instance
       */
      public Object get( String role ) throws ServiceException
      {
          if( role == null )
          {
              throw new NullPointerException( "role" );
          }
  
          DependencyDescriptor dependency = 
            m_appliance.getProfile().getType().getDependency( role );
          Appliance provider = m_appliance.getServiceProvider( role );
          if( provider == null )
          {
              final String error =
                "Internal error - incorrect assembly in appliance: " + m_appliance
                + ". A null provider was retured for the dependency: " + dependency;
              throw new ServiceException( role, error );
          }
  
          try
          {
              return provider.access( dependency );
          }
          catch( Throwable e )
          {
              final String error = 
                "Unexpected internal error while accessing a service provider in appliance: "
                + m_appliance
                + " for the role: " + role;
              throw new ServiceException( role, error, e );
          }
      }
  
      /**
       * Release a pooled object.
       * @param object a pooled object
       */
      public void put( Object object )
      {
          m_appliance.release( object );
      }
  
  }
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/CompositionService.java
  
  Index: CompositionService.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.lifecycle.composition;
  
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  
  /**
   * A composition service is responsible for the assignment of of a component 
   * service depedencies vioa service or component managers.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:54 $
   */
  public interface CompositionService
  {
  
     /**
      * Service the supplied object.
      * @param appliance the object to contextualize
      * @param object the object to contextualize
      */
      void service( Appliance appliance, Object object ) throws ServiceException;
  
     /**
      * Runtime composition of a target object.
      * @param appliance the appliance
      * @param object the object to service
      */
      public void compose( Appliance appliance, Object object ) throws ComponentException;
  
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/DefaultCompositionService.java
  
  Index: DefaultCompositionService.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.lifecycle.composition;
  
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.component.WrapperComponentManager;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.service.Serviceable;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  /**
   * A assembly service is responsible for the resolution of a component 
   * service depedencies, and the construction supply of a component or
   * service manager to a target object.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:54 $
   */
  public class DefaultCompositionService extends AbstractLogEnabled 
    implements CompositionService
  {
  
      //==============================================================
      // AssemblyService
      //==============================================================
  
     /**
      * Runtime servicing of a target object.
      * @param appliance the appliance
      * @param object the object to service
      */
      public void service( Appliance appliance, Object object ) throws ServiceException
      {
          if( appliance == null )
          {
              throw new NullPointerException( "appliance" );
          }
          if( object == null )
          {
              throw new NullPointerException( "object" );
          }
  
          if( object instanceof Serviceable )
          {
              ServiceManager manager = new DefaultServiceManager( appliance );
              ((Serviceable)object).service( manager );
  
              if( getLogger().isDebugEnabled() )
              {
                  final String message =  
                    "[" + appliance.getProfile().getName() + "]";
                  getLogger().debug( message );
              }
          }
      }
  
     /**
      * Runtime composition of a target object.
      * @param appliance the appliance
      * @param object the object to service
      */
      public void compose( Appliance appliance, Object object ) throws ComponentException
      {
          if( appliance == null )
          {
              throw new NullPointerException( "appliance" );
          }
          if( object == null )
          {
              throw new NullPointerException( "object" );
          }
  
          if( object instanceof Composable )
          {
              ServiceManager manager = new DefaultServiceManager( appliance );
              ((Composable)object).compose( new WrapperComponentManager( manager ) );
              if( getLogger().isDebugEnabled() )
              {
                  final String message =  
                    "[" + appliance.getProfile().getName() + "]";
                  getLogger().debug( message );
              }
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/DefaultServiceManager.java
  
  Index: DefaultServiceManager.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.lifecycle.composition;
  
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  /**
   * Internal helper class the implements the <code>ServiceManager</code> interface and
   * is supplied to dynamically created componets during lifecyle pipeline processing.
   * @author Stephen McConnell <mcconnell@osm.net>
   */
  class DefaultServiceManager
      extends AbstractManager
      implements ServiceManager
  {
      /**
       * Construct a new ServiceManager.
       * @param profile the component profile
       */
      public DefaultServiceManager( Appliance appliance )
      {
          super( appliance );
      }
  
      /**
       * Returns true if a provider exists for the supplied role.
       * @param role the service identifier
       * @return boolean TRUE if the service is available else FALSE
       */
      public boolean hasService( String role )
      {
          return super.has( role );
      }
  
      /**
       * Retrieve Object by role from ComponentLocator.
       * @param role the role
       * @return the Object
       * @throws ServiceException if an error occurs
       */
      public Object lookup( String role ) throws ServiceException
      {
          try
          {
              return super.get( role );
          }
          catch( Throwable e )
          {
              final String error = "Service resolution failure for role: " + role;
              throw new ServiceException( role, error, e );
          }
      }
  
      /**
       * Release a pooled object.
       * @param object a pooled object
       */
      public void release( Object object )
      {
          super.put( object );
      }
  }
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The <code>composition</code> package includes interfaces and classes supporting the assignment of service and component managers backed by appliane instances.  This enables deferral of the activation of services until they are requested.
  </p>
  </body>
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/configuration/ConfigurationService.java
  
  Index: ConfigurationService.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.lifecycle.configuration;
  
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  
  /**
   * A deployment service is responsible for the deployment of a component 
   * in response to a request from a lifestyle manager.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public interface ConfigurationService
  {
     /**
      * Configure a supplied object in accordance with the profile 
      * directives assiacted with the supplied appliance.
      * @param appliance the appliace
      * @param object the object to configure
      */
      void configure( Appliance appliance, Object object ) 
        throws ConfigurationException;
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/configuration/DefaultConfigurationService.java
  
  Index: DefaultConfigurationService.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.lifecycle.configuration;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.configuration.DefaultConfiguration;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  /**
   * The default configuration service provides support for the configuration of a 
   * supplied component instance relative to the criteria establihsed under a 
   * supplied appliance.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public class DefaultConfigurationService extends AbstractLogEnabled implements ConfigurationService
  {
     /**
      * Configure a supplied object in accordance with the profile 
      * directives assiacted with the supplied appliance.
      * @param appliance the appliace
      * @param object the object to configure
      */
      public void configure( Appliance appliance, Object object ) 
        throws ConfigurationException
      {
          if( appliance == null )
          {
              throw new NullPointerException( "appliance" );
          }
          if( object == null )
          {
              throw new NullPointerException( "object" );
          }
  
          if( object instanceof Configurable )
          {
              Configuration config = appliance.getProfile().getConfiguration();
              if( config == null )
              {
                  config = new DefaultConfiguration( "configuration", null );
              }
              ((Configurable)object).configure( config );
              if( getLogger().isDebugEnabled() )
              {
                  final String message =  
                    "[" + appliance.getProfile().getName() + "]";
                  getLogger().debug( message );
              }
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/configuration/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The <code>congiuration</code> package includes interfaces and classes supporting the asignment of a configuration to a target component.
  </p>
  </body>
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/context/AbstractContextHandler.java
  
  Index: AbstractContextHandler.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.lifecycle.context;
  
  import java.util.Map;
  import java.lang.reflect.Constructor;
  import java.util.HashMap;
  
  import org.apache.avalon.framework.context.Contextualizable;
  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.logger.AbstractLogEnabled;
  import org.apache.avalon.assembly.appliance.Appliance;
  import org.apache.avalon.meta.model.Entry;
  import org.apache.avalon.meta.model.Import;
  import org.apache.avalon.meta.model.Profile;
  import org.apache.avalon.meta.model.ContextDirective;
  import org.apache.avalon.meta.info.ContextDescriptor;
  import org.apache.avalon.meta.info.EntryDescriptor;
  
  /**
   * The context service provides support for the contextualization of a 
   * supplied component instance relative to the criteria establihsed under a 
   * supplied appliance.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public class AbstractContextHandler extends AbstractLogEnabled implements Contextualizable
  {
      //==============================================================
      // state
      //==============================================================
  
      private Context m_context;
  
      private ClassLoader m_classloader;
  
      //==============================================================
      // Contextualizable
      //==============================================================
  
     /**
      * <p>Application of a runtime context to this appliance.
      * The supplied context contains standard and container specific context
      * entries and may be used by the context service in establish the 
      * context to apply to components.</p>
      * @param context the containerment context
      */
      public void contextualize( Context context ) throws ContextException
      {
          m_context = context;
          m_classloader = (ClassLoader) context.get( "assembly:classloader" );
      }
  
      //==============================================================
      // utilities
      //==============================================================
  
      /**
       * Internal utility to construct a context instance using a descriptor, directive and source
       * context instances.
       *
       * @param descriptors the descriptor containing the context dependency declarations
       * @param directive an optional context directive containing import and context value
       *    creation parameters
       * @param context a supplimentary context object to used during value resolution
       * @return a context object containing only those context entries desribed under the
       *   supplied descriptor
       * @exception Exception if a required context value cannot be resolved or an error
       *   occurs during context value creation
       */
      protected Context buildContext(
                             ContextDescriptor descriptors,
                             ContextDirective directive,
                             Context context )
        throws Exception
      {
          Map map = new HashMap();
          Context result;
  
          if( directive != null )
          {
              final String classname = directive.getClassname();
              Class clazz;
              try
              {
                  clazz = m_classloader.loadClass( classname );
              }
              catch( ClassNotFoundException cnfe )
              {
                  throw new ContextException(
                      "Could not find context class " + classname, cnfe );
              }
  
              try
              {
                  Constructor constructor = clazz.getConstructor(
                      new Class[]{Map.class, Context.class} );
                  result = (Context)constructor.newInstance( new Object[]{map, null} );
              }
              catch( Throwable e )
              {
                  throw new ContextException(
                      "Unexpected exception while creating context form "
                      + classname, e );
              }
          }
          else
          {
              result = new DefaultContext( map );
          }
  
          EntryDescriptor[] entries = descriptors.getEntrys();
          for( int i = 0; i < entries.length; i++ )
          {
              EntryDescriptor entry = entries[ i ];
              String key = entry.getKey();
  
              //
              // if the entry is already in the supplied context then use it
              //
  
              Object object = getContextValue( context, key );
  
              //
              // If the context value is unresolved, try to handle resolution
              // using an import directive supplied under the directive
              //
  
              if( object == null )
              {
  
                  //
                  // check if the profile declares an import directive
                  // for the context
                  //
  
                  if( directive != null )
                  {
                      Import imp = directive.getImport( key );
                      if( imp != null )
                      {
                          String name = imp.getImportName();
                          object = getContextValue( context, name );
                          if( object == null )
                          {
                              final String error =
                                  "Import directive for key: " + key + " via name: " + name
                                  + " cannot be resolved.";
                              getLogger().warn( error );
                          }
                      }
  
                      //
                      // if the context value is unresolved, try to construct a context
                      // value using an entry constructor directive
                      //
  
                      if( object == null )
                      {
                          //
                          // check if the directive declares a context value constructor
                          //
  
                          Entry ent = directive.getEntry( key );
                          if( ent != null )
                          {
                              object = ent.getValue( m_classloader, map );
                          }
                      }
                  }
              }
  
              //
              // finally, if the object is still null, and its not optional, then
              // throw an exception, otherwise, add the object to the context
              //
  
              if( object != null )
              {
                  try
                  {
                      boolean ok = objectImplementsType( object, entry.getType() );
                      if( ok )
                      {
                          map.put( key, object );
                      }
                      else
                      {
                          final String error =
                              "Object resolved for the key '" + key + "' of class '"
                              + object.getClass().getName() + "' does not implement the type '"
                              + entry.getType();
                          throw new ContextException( error );
                      }
                  }
                  catch( ClassNotFoundException cnfe )
                  {
                      final String error =
                          "Context criteria for the key '" + key + "' specifies an unknown type '"
                          + entry.getType() + "'.";
                      throw new ContextException( error );
                  }
              }
              else
              {
                  if( entry.isRequired() )
                  {
                      final String error =
                        "Unable to resolve a context value for the entry: '" 
                        + key + "' type: "
                        + entry.getType();
                      throw new ContextException( error );
                  }
              }
          }
  
          if( result instanceof DefaultContext )
          {
              ( (DefaultContext)result ).makeReadOnly();
          }
  
          return result;
      }
  
      /**
       * Internal utility to get a context value or null if the context key
       * is unknown.
       * @param context the context object
       * @param key the context key to lookup
       * @return the context value derived from the key or null if the key is unknown
       */
      protected Object getContextValue( Context context, String key )
      {
          if( context == null )
          {
              return null;
          }
  
          try
          {
              return context.get( key );
          }
          catch( ContextException e )
          {
              return null;
          }
      }
  
      /**
       * Check whether the specified value is compatible with specified type.
       *
       * @param value the value
       * @param type the desired type
       * @return true if value is compatible with type, false otherwise
       */
      protected boolean objectImplementsType( final Object value, final String type )
          throws ClassNotFoundException
      {
          if( type == null )
          {
              throw new NullPointerException( "type" );
          }
  
          if( value == null )
          {
              throw new NullPointerException( "value" );
          }
  
          final Class clazz = value.getClass();
          final Class typeClass = m_classloader.loadClass( type );
          return typeClass.isAssignableFrom( clazz );
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/context/ContextualizationService.java
  
  Index: ContextualizationService.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.lifecycle.context;
  
  import org.apache.avalon.assembly.appliance.Appliance;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  
  
  /**
   * A context service is responsible for the contextualization of a component 
   * in response to a request from a lifestyle manager.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public interface ContextualizationService
  {
     /**
      * Contextualize the supplied object.
      * @param appliance the object to contextualize
      * @param object the object to contextualize
      */
      void contextualize( 
        Appliance appliance, Object object, Context context ) 
        throws ContextException;
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/context/DefaultContextualizationService.java
  
  Index: DefaultContextualizationService.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.lifecycle.context;
  
  import java.util.Map;
  import java.lang.reflect.Constructor;
  import java.util.HashMap;
  
  import org.apache.avalon.framework.context.Contextualizable;
  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.logger.AbstractLogEnabled;
  import org.apache.avalon.assembly.appliance.Appliance;
  import org.apache.avalon.meta.model.Entry;
  import org.apache.avalon.meta.model.Import;
  import org.apache.avalon.meta.model.Profile;
  import org.apache.avalon.meta.model.ContextDirective;
  import org.apache.avalon.meta.info.ContextDescriptor;
  import org.apache.avalon.meta.info.EntryDescriptor;
  
  /**
   * The context service provides support for the contextualization of a 
   * supplied component instance relative to the criteria establihsed under a 
   * supplied appliance.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public class DefaultContextualizationService extends AbstractContextHandler 
    implements ContextualizationService
  {
      //==============================================================
      // state
      //==============================================================
  
      private Context m_context;
  
      //==============================================================
      // Contextualizable
      //==============================================================
  
     /**
      * <p>Application of a runtime context to this appliance.
      * The supplied context contains standard and container specific context
      * entries and may be used by the context service in establish the 
      * context to apply to components.</p>
      * @param context the containerment context
      */
      public void contextualize( Context context ) throws ContextException
      {
          super.contextualize( context );
          m_context = context;
      }
  
      //==============================================================
      // ContextService
      //==============================================================
  
     /**
      * Contextualization of a supplied object in accordance with the profile 
      * directives assiacted with the supplied appliance.
      * @param appliance the appliace
      * @param object the object to configure
      */
      public void contextualize( 
        Appliance appliance, Object object, Context context ) throws ContextException
      {
          if( appliance == null )
          {
              throw new NullPointerException( "appliance" );
          }
          if( object == null )
          {
              throw new NullPointerException( "object" );
          }
  
  
          if( object instanceof Contextualizable )
          {
              Context standard =
                createStandardContext( appliance.getProfile(), context );
              ((Contextualizable)object).contextualize( standard );
              if( getLogger().isDebugEnabled() )
              {
                  final String message =  
                    "[" + appliance.getProfile().getName() + "]";
                  getLogger().debug( message );
              }
          }
      }
  
      /**
       * Create a new Context for component.
       *
       * @param profile the profile
       * @param context a supplimentary context usable during import resolution
       * @return a new Context for service
       * @throws DeploymentException if an error occurs in standard
       *   context creation
       */
      public Context createStandardContext( Profile profile, Context context )
          throws ContextException
      {
          try
          {
              ContextDescriptor descriptor = profile.getType().getContext();
              ContextDirective directive = profile.getContext();
              return buildContext( descriptor, directive, context );
          }
          catch( Throwable e )
          {
              final String error =
                "Unexpected error while preparing standard context for the profile: " 
                + profile.getName();
              throw new ContextException( error, e );
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/context/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The <code>context</code> package includes interfaces and classes supporting the assignment of runtime context to a target component.  The includes resources for context value creation and import from a supplied system context.
  </p>
  </body>
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/disposal/DefaultDisposalService.java
  
  Index: DefaultDisposalService.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.lifecycle.disposal;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  /**
   * The default configuration service provides support for the configuration of a 
   * supplied component instance relative to the criteria establihsed under a 
   * supplied appliance.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public class DefaultDisposalService extends AbstractLogEnabled implements DisposalService
  {
     /**
      * Disposal of a supplied object in accordance with the profile 
      * directives assiacted with the supplied appliance.
      * @param appliance the appliace
      * @param object the object to configure
      */
      public void dispose( Appliance appliance, Object object )
      {
          if( appliance == null )
          {
              throw new NullPointerException( "appliance" );
          }
          if( object == null )
          {
              throw new NullPointerException( "object" );
          }
  
          if( object instanceof Disposable )
          {
              try
              {
                  ((Disposable)object).dispose();
                  if( getLogger().isDebugEnabled() )
                  {
                      final String message = "Appliance disposal: " + appliance.getProfile().getName();
                      getLogger().debug( message );
                  }
              }
              catch( Throwable e )
              {
                  if( getLogger().isWarnEnabled() )
                  {
                      final String warning = 
                        "Error during disposal ignored - appliance: " + appliance;
                      getLogger().warn( warning, e );
                  }
              }
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/disposal/DisposalService.java
  
  Index: DisposalService.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.lifecycle.disposal;
  
  import org.apache.avalon.assembly.appliance.Appliance;
  
  
  /**
   * A deployment service is responsible for the deployment of a component 
   * in response to a request from a lifestyle manager.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public interface DisposalService
  {
     /**
      * Dispose of the supplied object.
      * @param appliance the appliance
      * @param object the object to dispose
      */
      void dispose( Appliance appliance, Object object );
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/disposal/ExtendedDisposalService.java
  
  Index: ExtendedDisposalService.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.lifecycle.disposal;
  
  import java.util.Map;
  import java.util.Hashtable;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.activity.Disposable;
  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.assembly.appliance.Appliance;
  import org.apache.avalon.assembly.lifecycle.context.AbstractContextHandler;
  import org.apache.avalon.assembly.lifecycle.DeploymentException;
  import org.apache.avalon.assembly.engine.Engine;
  import org.apache.avalon.meta.info.StageDescriptor;
  import org.apache.avalon.meta.info.Type;
  import org.apache.avalon.meta.info.ExtensionDescriptor;
  import org.apache.avalon.meta.info.ContextDescriptor;
  import org.apache.avalon.meta.model.Profile;
  import org.apache.avalon.lifecycle.Creator;
  
  /**
   * The initialization service provides support for the initialization of a 
   * supplied component instance relative to the criteria established under a 
   * supplied appliance.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public class ExtendedDisposalService extends AbstractContextHandler implements DisposalService
  {
      Context m_context;
  
      //==============================================================
      // Contextualizable
      //==============================================================
  
     /**
      * <p>Application of a runtime context to this appliance.
      * The supplied context contains standard and container specific context
      * entries and may be used by the context service in establish the 
      * context to apply to components.</p>
      * @param context the containerment context
      */
      public void contextualize( Context context ) throws ContextException
      {
          super.contextualize( context );
          m_context = context;
      }
  
     /**
      * Dispose of the supplied object.
      * @param appliance the appliance
      * @param object the object to dispose
      */
      public void dispose( Appliance appliance, Object object ) 
      {
          if( m_context == null )
          {
              throw new IllegalStateException("context");
          }
  
          if( appliance == null )
          {
              throw new NullPointerException("appliance");
          }
          if( object == null )
          {
              throw new NullPointerException("object");
          }
  
          StageDescriptor[] stages = appliance.getProfile().getType().getStages();
          if( stages.length > 0 )
          {
              for( int i = 0; i < stages.length; i++ )
              {
                  StageDescriptor stage = stages[i];
                  processDestroy( appliance, stage, object );
              }
          }
  
          //
          // and finally, dispose of the component
          //
  
          if( object instanceof Disposable )
          {
              ((Disposable)object).dispose();
              if( getLogger().isDebugEnabled() )
              {
                  final String message =  
                    "[" + appliance.getProfile().getName() + "]";
                  getLogger().debug( message );
              }
          }
      }
  
      private void processDestroy( Appliance appliance, StageDescriptor stage, Object object )
      {
          try
          {
              Appliance provider;
              try
              {
                  provider = appliance.getExtensionProvider( stage );
              }
              catch( Throwable e )
              {
                  final String error = 
                    "Extension provider location failure in appliance: '"
                    + appliance 
                    + "' under the stage: '" + stage;
                  throw new DeploymentException( error, e );
              }
  
              if( provider == null )
              {
                  final String error = 
                    "Missing extension provider in appliance: '" + appliance
                    + "' for the stage: " + stage;
                  throw new DeploymentException( error );
              }
  
              Context context;
              try
              {
                  Type type = provider.getProfile().getType();
                  final ExtensionDescriptor descriptor = type.getExtension( stage );
                  context = createContext( descriptor, m_context );
              }
              catch( Throwable e )
              {
                  final String error = 
                    "Extension handler context establishment error on appliance: '"
                    + appliance 
                    + "' under stage: '" + stage
                    + "' for provider: '" + provider;
                  throw new DeploymentException( error, e );
              }
  
              Creator handler = null;
              try
              {
                  handler = (Creator) provider.access( stage );
              }
              catch( Throwable e )
              {
                  final String error = 
                    "Extension handler deployment error on appliance: '"
                   + appliance 
                   + "' under stage: '" + stage
                   + "' with handler: '" + handler;
                  throw new DeploymentException( error, e );
              }
  
              try
              {
                  handler.destroy( object, context );
              }
              catch( Throwable e )
              {
                  final String error = 
                    "Extension handler execution error in appliance: '"
                    + appliance 
                    + "' under stage: '" + stage
                    + "' with handler: '" + handler
                    + "' for target: '" + object + "'";
                  throw new DeploymentException( error, e );
              }
          }
          catch( Throwable e )
          {
              if( getLogger().isWarnEnabled() )
              {
                  final String warning = 
                    "Ignoring externsion related error during destroy stage.";
                  getLogger().warn( warning, e );
              }
          }
      }
  
      /**
       * Create a new Context for an extension.
       *
       * @param extension the extension descriptor
       * @param context a supplimentary context used during import resolution
       * @return a new Context for service
       * @throws Exception if unable to create context
       */
      private Context createContext( ExtensionDescriptor extension, Context context )
          throws Exception
      {
          ContextDescriptor descriptor = extension.getContext();
          return buildContext( descriptor, null, context );
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/disposal/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The <code>disposal</code> package includes interfaces and classes supporting the component disposal.
  </p>
  </body>
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization/DefaultInitializationService.java
  
  Index: DefaultInitializationService.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.lifecycle.initialization;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  /**
   * The initialization service provides support for the initialization of a 
   * component instance relative to the criteria established under a 
   * supplied appliance.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public class DefaultInitializationService extends AbstractLogEnabled implements InitializationService
  {
     /**
      * Initialize a supplied object in accordance with the parameters 
      * associated with the supplied appliance.
      * @param appliance the appliace
      * @param object the object to initialized
      */
      public void initialize( Appliance appliance, Object object ) 
        throws Exception
      {
         if( object instanceof Initializable )
         {
             ((Initializable)object).initialize();
              if( getLogger().isDebugEnabled() )
              {
                  final String message =  
                    "[" + appliance.getProfile().getName() + "]";
                  getLogger().debug( message );
              }
         }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization/ExtendedInitializationService.java
  
  Index: ExtendedInitializationService.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.lifecycle.initialization;
  
  import java.util.Map;
  import java.util.Hashtable;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.activity.Initializable;
  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.assembly.appliance.Appliance;
  import org.apache.avalon.assembly.lifecycle.context.AbstractContextHandler;
  import org.apache.avalon.assembly.lifecycle.DeploymentException;
  import org.apache.avalon.assembly.engine.Engine;
  import org.apache.avalon.meta.info.StageDescriptor;
  import org.apache.avalon.meta.info.Type;
  import org.apache.avalon.meta.info.ExtensionDescriptor;
  import org.apache.avalon.meta.info.ContextDescriptor;
  import org.apache.avalon.meta.model.Profile;
  import org.apache.avalon.lifecycle.Creator;
  
  /**
   * The initialization service provides support for the initialization of a 
   * supplied component instance relative to the criteria established under a 
   * supplied appliance.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public class ExtendedInitializationService extends AbstractContextHandler implements InitializationService
  {
      Context m_context;
  
      //==============================================================
      // Contextualizable
      //==============================================================
  
     /**
      * <p>Application of a runtime context to this appliance.
      * The supplied context contains standard and container specific context
      * entries and may be used by the context service in establish the 
      * context to apply to components.</p>
      * @param context the containerment context
      */
      public void contextualize( Context context ) throws ContextException
      {
          super.contextualize( context );
          m_context = context;
      }
  
     /**
      * Initialize a supplied object in accordance with the parameters 
      * associated with the supplied appliance.
      * @param appliance the appliace
      * @param object the object to initialized
      */
      public void initialize( Appliance appliance, Object object ) 
        throws Exception
      {
          if( m_context == null )
          {
              throw new IllegalStateException("context");
          }
  
          if( appliance == null )
          {
              throw new NullPointerException("appliance");
          }
          if( object == null )
          {
              throw new NullPointerException("object");
          }
  
          StageDescriptor[] stages = appliance.getProfile().getType().getStages();
          if( stages.length > 0 )
          {
              for( int i = 0; i < stages.length; i++ )
              {
                  StageDescriptor stage = stages[ i ];
  
                  Appliance provider;
                  try
                  {
                      provider = appliance.getExtensionProvider( stage );
                  }
                  catch( Throwable e )
                  {
                      final String error = 
                        "Extension provider location failure in appliance: '"
                        + appliance 
                        + "' under the stage: '" + stage;
                      throw new DeploymentException( error, e );
                  }
  
                  if( provider == null )
                  {
                      final String error = 
                        "Missing extension provider in appliance: '" + appliance
                        + "' for the stage: " + stage;
                      throw new DeploymentException( error );
                  }
  
                  Context context;
                  try
                  {
                      Type type = provider.getProfile().getType();
                      final ExtensionDescriptor descriptor = type.getExtension( stage );
                      context = createContext( descriptor, m_context );
                  }
                  catch( Throwable e )
                  {
                      final String error = 
                        "Extension handler context establiahment error on appliance: '"
                        + appliance 
                        + "' under stage: '" + stage
                        + "' for provider: '" + provider;
                      throw new DeploymentException( error, e );
                  }
  
                  Creator handler = null;
                  try
                  {
                      handler = (Creator) provider.access( stage );
                  }
                  catch( Throwable e )
                  {
                      final String error = 
                        "Extension handler deployment error on appliance: '"
                        + appliance 
                        + "' under stage: '" + stage
                        + "' with handler: '" + handler;
                      throw new DeploymentException( error, e );
                  }
  
                  try
                  {
                      handler.create( object, context );
                  }
                  catch( Throwable e )
                  {
                      final String error = 
                        "Extension handler execution error in appliance: '"
                        + appliance 
                        + "' under stage: '" + stage
                        + "' with handler: '" + handler
                        + "' for target: '" + object + "'";
                      throw new DeploymentException( error, e );
                  }
              }
          }
  
          //
          // and finally, initialize the component
          //
  
          if( object instanceof Initializable )
          {
              ((Initializable)object).initialize();
              if( getLogger().isDebugEnabled() )
              {
                  final String message =  
                    "[" + appliance.getProfile().getName() + "]";
                  getLogger().debug( message );
              }
          }
      }
  
      /**
       * Create a new Context for an extension.
       *
       * @param extension the extension descriptor
       * @param context a supplimentary context used during import resolution
       * @return a new Context for service
       * @throws Exception if unable to create context
       */
      private Context createContext( ExtensionDescriptor extension, Context context )
          throws Exception
      {
          ContextDescriptor descriptor = extension.getContext();
          return buildContext( descriptor, null, context );
      }
  
  
      /**
       * Gat the context for a extension stage.
       *
       * @param map the map of context entries keyed by stage
       * @param stage the stage descriptor
       * @return a the Context for the extension
       */
      protected Context getContext( Map map, StageDescriptor stage )
      {
          return (Context) map.get( stage );
      }
  
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization/InitializationService.java
  
  Index: InitializationService.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.lifecycle.initialization;
  
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  
  /**
   * A initalization service is responsible for the initialization of a component 
   * in response to a request from a lifestyle manager.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public interface InitializationService
  {
     /**
      * Initialize a supplied object in accordance with the parameters 
      * associated with the supplied appliance.
      * @param appliance the appliace
      * @param object the object to parameterize
      */
      void initialize( Appliance appliance, Object object ) 
        throws Exception;
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The <code>context</code> package includes interfaces and classes supporting the component initialization including te optional support for lifecycle extensions.
  </p>
  </body>
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/logging/DefaultLoggingService.java
  
  Index: DefaultLoggingService.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.lifecycle.logging;
  
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  /**
   * Service that handles the assignment of logging channels to a component.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public class DefaultLoggingService extends AbstractLogEnabled implements LoggingService
  {
     /**
      * Applies logging channels to a supplied object in accordance with the profile 
      * directives associated with the supplied appliance.
      * @param appliance the appliace
      * @param object the object to which logging channels will be assigned
      * @param the base logging channel
      */
      public void enableLogging( Appliance appliance, Object object, Logger logger ) 
        throws Exception
      {
          if( appliance == null )
          {
              throw new NullPointerException( "appliance" );
          }
          if( object == null )
          {
              throw new NullPointerException( "object" );
          }
  
          if( object instanceof LogEnabled )
          {
              if( logger == null )
              {
                  throw new NullPointerException( "logger" );
              }
              ((LogEnabled)object).enableLogging( logger );
              if( getLogger().isDebugEnabled() )
              {
                  final String message =  
                    "[" + appliance.getProfile().getName() + "]";
                  getLogger().debug( message );
              }
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/logging/LoggingService.java
  
  Index: LoggingService.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.lifecycle.logging;
  
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  
  /**
   * Service that handles the assignment of logging channels to a component.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public interface LoggingService
  {
     /**
      * Applies logging channels to a supplied object in accordance with the profile 
      * directives associated with the supplied appliance.
      * @param appliance the appliace
      * @param object the object to which logging channels will be assigned
      */
      void enableLogging( Appliance appliance, Object object, Logger logger ) 
        throws Exception;
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/logging/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The <code>logging</code> package includes interfaces and classes supporting the assignment of logging channels to a target component.
  </p>
  </body>
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/parameters/DefaultParameterizationService.java
  
  Index: DefaultParameterizationService.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.lifecycle.parameters;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.parameters.Parameterizable;
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  /**
   * The default configuration service provides support for the configuration of a 
   * supplied component instance relative to the criteria establihsed under a 
   * supplied appliance.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public class DefaultParameterizationService extends AbstractLogEnabled 
    implements ParameterizationService
  {
     /**
      * Parameterize a supplied object in accordance with the profile 
      * directives assiacted with the supplied appliance.
      * @param appliance the appliace
      * @param object the object to parameterize
      */
      public void parameterize( Appliance appliance, Object object ) 
        throws ParameterException
      {
          if( appliance == null )
          {
              throw new NullPointerException( "appliance" );
          }
          if( object == null )
          {
              throw new NullPointerException( "object" );
          }
  
          if( object instanceof Parameterizable )
          {
              Parameters params = appliance.getProfile().getParameters();
              if( params == null )
              {
                  params = Parameters.EMPTY_PARAMETERS;
              }
              ((Parameterizable)object).parameterize( params );
              if( getLogger().isDebugEnabled() )
              {
                  final String message =  
                    "[" + appliance.getProfile().getName() + "]";
                  getLogger().debug( message );
              }
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/parameters/ParameterizationService.java
  
  Index: ParameterizationService.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.lifecycle.parameters;
  
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  
  /**
   * A paramterization service is responsible for the parameterization of a component 
   * in response to a request from a lifestyle manager.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public interface ParameterizationService
  {
     /**
      * Paramatarize a supplied object in accordance with the parameters 
      * associated with the supplied appliance.
      * @param appliance the appliace
      * @param object the object to parameterize
      */
      void parameterize( Appliance appliance, Object object ) 
        throws ParameterException;
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/parameters/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The <code>parameters</code> package includes interfaces and classes supporting the assignment of parameters to a target component.
  </p>
  </body>
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/startup/DefaultStartupService.java
  
  Index: DefaultStartupService.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.lifecycle.startup;
  
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  /**
   * The default start service provides support for the startup of a 
   * supplied component instance relative to the criteria established under a 
   * supplied appliance.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public class DefaultStartupService extends AbstractLogEnabled implements StartupService
  {
     /**
      * Startup of a supplied object in accordance with the profile 
      * directives assiacted with the supplied appliance.
      * @param appliance the appliace
      * @param object the object to configure
      */
      public void start( Appliance appliance, Object object ) throws Exception
      {
          if( appliance == null )
          {
              throw new NullPointerException( "appliance" );
          }
          if( object == null )
          {
              throw new NullPointerException( "object" );
          }
  
          if( object instanceof Startable )
          {
              ((Startable)object).start();
              if( getLogger().isDebugEnabled() )
              {
                  final String message =  
                    "[" + appliance.getProfile().getName() + "]";
                  getLogger().debug( message );
              }
          }
      }
  
     /**
      * Stop a supplied object in accordance with the profile 
      * directives associated with the supplied appliance.
      * @param appliance the appliace
      * @param object the object to configure
      */
      public void stop( Appliance appliance, Object object ) throws Exception
      {
          if( appliance == null )
          {
              throw new NullPointerException( "appliance" );
          }
          if( object == null )
          {
              throw new NullPointerException( "object" );
          }
  
          if( object instanceof Startable )
          {
              ((Startable)object).stop();
              if( getLogger().isDebugEnabled() )
              {
                  final String message =  
                    "[" + appliance.getProfile().getName() + "]";
                  getLogger().debug( message );
              }
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/startup/StartupService.java
  
  Index: StartupService.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.lifecycle.startup;
  
  import org.apache.avalon.assembly.appliance.Appliance;
  
  
  /**
   * A startup service provides support for startup and shutdown 
   * stages of a component lifecycle.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:55 $
   */
  public interface StartupService
  {
     /**
      * Startup of a supplied object in accordance with the profile 
      * directives assiacted with the supplied appliance.
      * @param appliance the appliace
      * @param object the object to configure
      */
      void start( Appliance appliance, Object object ) throws Exception;
  
     /**
      * Stop a supplied object in accordance with the profile 
      * directives associated with the supplied appliance.
      * @param appliance the appliace
      * @param object the object to stop
      */
      void stop( Appliance appliance, Object object ) throws Exception;
  
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/startup/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The <code>logging</code> package includes interfaces and classes supporting the starting and stopping of a target component.
  </p>
  </body>
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/AbstractLifestyleHandler.java
  
  Index: AbstractLifestyleHandler.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.lifestyle;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.activity.Initializable;
  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.service.ServiceManager;
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.framework.service.Serviceable;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.meta.info.DependencyDescriptor;
  import org.apache.avalon.meta.info.StageDescriptor;
  import org.apache.avalon.assembly.appliance.Appliance;
  import org.apache.avalon.assembly.lifecycle.DeploymentService;
  
  /**
   * The abstract lifestyle handler provides support for object instantiation and 
   * lifecycle processing.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:56 $
   */
  public abstract class AbstractLifestyleHandler extends AbstractLogEnabled implements Contextualizable, Serviceable, Initializable, Disposable, LifestyleHandler
  {
      //==============================================================
      // state
      //==============================================================
  
     /**
      * The appliance that this handler is handling.
      */
      private Appliance m_appliance;
  
     /**
      * The classloader to use to when instantiating new instances 
      * of the component implementation class.
      */
      private ClassLoader m_classloader;
  
     /**
      * The logging channel to assign to instance creeated by this handler.
      */
      private Logger m_logger;
  
     /**
      * The deplyment service to handle lifecycle processing of 
      * component implementations established by this handler.
      */
      private DeploymentService m_deployment;
  
     /**
      * The deplyment context.
      */
      private Context m_context;
  
      //==============================================================
      // Contextualizable
      //==============================================================
  
     /**
      * <p>Application of a runtime context to this component.
      * Context entries that may be supplied to a lifestyle handler 
      * are detailed in the following table.</p>
      * <table>
      *   <tr>
      *     <td>key</td><td>type</td><td>description</td>
      *   </tr>
      *   <tr>
      *     <td>assembly:appliance.target</td>
      *     <td>{@link org.apache.avalon.appliance.Appliance}</td>
      *     <td>The appliance that this manager is managing.</td> 
      *   </tr>
      * </table>
      * @param context the runtime context
      */
      public void contextualize( Context context ) throws ContextException
      {
          m_logger = (Logger) context.get( "avalon:logger" );
          m_classloader = (ClassLoader) context.get( "avalon:classloader" );
          m_appliance = (Appliance) context.get( "assembly:appliance.target" );
          try
          {
              m_context = (Context) context.get( "assembly:deployment.context" );
          }
          catch( ContextException ce )
          {
              m_context = null;
          }
      }
  
      //==============================================================
      // Serviceable
      //==============================================================
  
     /**
      * <p>Application of a supporting service to the handler.</p>
      * <table>
      *   <tr>
      *     <td>key</td><td>type</td><td>description</td>
      *   </tr>
      *   <tr>
      *     <td>assembly:lifestyle.deployment</td>
      *     <td>{@link org.apache.avalon.assembly.lifecycle.DeploymentService}</td>
      *     <td>The deplyment service that will handle deployment and decommissioning
      *         of instances derived from the appliance.</td> 
      *   </tr>
      * </table>
      * @param context the runtime context
      */
      public void service( ServiceManager manager ) throws ServiceException
      {
          m_deployment = (DeploymentService) manager.lookup( "assembly:deployment-service" );
      }
  
      //==============================================================
      // Initializable
      //==============================================================
  
     /**
      * Initialization of the lifestyle manager.  The implementation verifies  
      * initial state followed by establishment of a lifestyle handler based on 
      * the policy declared within the profile underlying the appliance.
      *
      * @exception Exception if a invalid state is encounter
      */
      public void initialize() throws Exception 
      {
          if( getLogger() == null )
          {
              throw new LifestyleException("logger");
          }
          if( m_appliance == null )
          {
              throw new LifestyleException("context");
          }
          if( m_deployment == null )
          {
              throw new LifestyleException("service");
          }
      }
  
      //==============================================================
      // LifestyleHandler
      //==============================================================
  
     /**
      * Activate a service provided by the appliance.
      * @param appliance the appliance to deploy
      */
      public abstract Object access( DependencyDescriptor dependency ) throws LifestyleException;
  
     /**
      * Activate an extension handler provided by the appliance.
      * @param appliance the appliance to deploy
      */
      public abstract Object access( StageDescriptor stage ) throws LifestyleException;
  
     /**
      * Release an a service or handler established by the appliance.
      * @param object the service to be released
      */
      public abstract void release( Object object );
  
      //==============================================================
      // Disposable
      //==============================================================
  
      /**
       * Request for disposal of the handler. 
       */
      public void dispose()
      {
          m_appliance = null;
          m_classloader = null;
          m_deployment = null;
          m_context = null;
      }
  
      //==============================================================
      // utilities
      //==============================================================
  
     /**
      * Creation of a new intance of the class declared by the profile backing the 
      * appliance assigned to this handler.
      * @return Object a new instance of the component class
      */
      protected Object newInstance() throws LifestyleException
      {
          try
          {
              return m_deployment.deploy( m_appliance, m_classloader, m_logger, m_context );
          }
          catch( Throwable e )
          {
              final String error = 
                "Unable to create new instance for appliance: "
                + m_appliance;
              throw new LifestyleException( error, e );
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/DefaultLifestyleService.java
  
  Index: DefaultLifestyleService.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.lifestyle;
  
  import java.util.Hashtable;
  
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.configuration.Configuration;
  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.Contextualizable;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.DefaultContext;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.DefaultServiceManager;
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.framework.service.Serviceable;
  import org.apache.avalon.assembly.appliance.Appliance;
  import org.apache.avalon.assembly.engine.Engine;
  import org.apache.avalon.assembly.lifecycle.DeploymentService;
  import org.apache.avalon.assembly.lifecycle.DefaultDeploymentService;
  
  /**
   * A lifestyle service provides support for the creation of a lifestyle 
   * handlers.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:56 $
   */
  public class DefaultLifestyleService extends AbstractLogEnabled implements LifestyleService, Serviceable, Initializable
  {
      //==============================================================
      // state
      //==============================================================
  
      /**
       * The deployment service to assign to the lifestyle handler.
       */
      private ServiceManager m_manager;
  
      /**
       * The system context.
       */
      private Context m_context;
  
     /**
      * Flag holding the initialized state of the service.
      */
      private boolean m_initialized = false;
  
     /**
      * Table of registered handlers.  Each handler is keyed by its URN with
      * a value corresponding to the appliance for the handler.
      */
      private Hashtable m_handlers = new Hashtable();
  
     /**
      * The supplied static configuration.
      */
      private Configuration m_config;
  
      //==============================================================
      // Configurable
      //==============================================================
  
     /**
      * Supply of the static configuration for the deployment service.
      * @param config the static configuration
      */
      public void configure( Configuration config ) throws ConfigurationException
      {
          if( config == null )
          {
              throw new NullPointerException( "config" );
          }
          m_config = config;
      }
  
      //==============================================================
      // Serviceable
      //==============================================================
  
     /**
      * Supply of supporting services to this componet by its manager.
      * This includes a deployment service.
      */
      public void service( ServiceManager manager ) throws ServiceException
      {
          if( manager == null )
          {
              throw new NullPointerException( "manager" );
          }
          m_manager = manager;
      }
  
      //==============================================================
      // Contextualizable
      //==============================================================
  
     /**
      * <p>Application of a runtime context to the lifestyle service.
      * The context value will be passed directly to lifestyle handlers 
      * established by this service.
      * @param context the runtime context
      */
      public void contextualize( Context context ) throws ContextException
      {
          if( context == null )
          {
              throw new NullPointerException( "context" );
          }
          m_context = context;
      }
  
      //==============================================================
      // Initializable
      //==============================================================
  
      public void initialize() throws Exception
      {
          if( getLogger() == null )
          {
              throw new IllegalStateException("logger");
          }
          if( m_context == null )
          {
              throw new IllegalStateException("context");
          }
          if( m_manager == null )
          {
              throw new IllegalStateException("manager");
          }
  
          String key = "assembly:deployment-service";
          if( !m_manager.hasService( key ) )
          {
              DefaultServiceManager manager = new DefaultServiceManager( m_manager );
              manager.put( key, bootstrapDeploymentService( m_manager ) );
              manager.makeReadOnly();
              m_manager = manager;
          }
  
          m_initialized = true;
      }
  
      //==============================================================
      // LifestyleService
      //==============================================================
  
     /**
      * Creation of a new lifestyle handler.
      * @param appliance the appliance that the handler will manage
      * @param classloader the classloader to assign to the handler
      * @param logger the logging channel to be assigned to new 
      *    instances of the appliance
      * @param context a deployment context
      */
      public LifestyleHandler createHandler( 
        Appliance appliance, ClassLoader classloader, Logger logger, Context deploymentContext )
      {
          if( !m_initialized )
          {
              throw new IllegalStateException("initialization");
          }
  
          if( appliance == null )
          {
              throw new NullPointerException("appliance");
          }
          if( classloader == null )
          {
              throw new NullPointerException("classloader");
          }
          if( logger == null )
          {
              throw new NullPointerException("logger");
          }
  
          //
          // create the deployment context to be supplied to the handler
          //
  
          DefaultContext context = new DefaultContext( m_context );
          if( deploymentContext != null )
          {
              context.put( "assembly:deployment.context", deploymentContext );
          }
          context.put( "assembly:appliance.target", appliance );
          context.put( "avalon:classloader", classloader );
          context.put( "avalon:logger", logger );
          context.makeReadOnly();
  
          //
          // select the lifestyle handler based on the lifestyle attribute exposed
          // by the appliance profile
          //
  
          final String policy =
              appliance.getProfile().getType().getInfo().getAttribute( 
                "avalon:lifestyle", "singleton" );
  
          if( policy.equalsIgnoreCase( "singleton" ) )
          {
              try
              {
                  SingletonLifestyleHandler singleton = new SingletonLifestyleHandler();
                  singleton.enableLogging( getLogger().getChildLogger("singleton") );
                  singleton.contextualize( context );
                  singleton.service( m_manager );
                  singleton.initialize();
                  return singleton;
              }
              catch( Throwable e )
              {
                  final String error =
                    "Internal error while attempting to establish the singleton lifestyle handler.";
                  throw new LifestyleRuntimeException( error, e );
              }
          }
          else if( policy.equals( "transient" ) )
          {
              try
              {
                  TransientLifestyleHandler transientHandler = new TransientLifestyleHandler();
                  transientHandler.enableLogging( getLogger().getChildLogger("transient") );
                  transientHandler.contextualize( context );
                  transientHandler.service( m_manager );
                  transientHandler.initialize();
                  return transientHandler;
              }
              catch( Throwable e )
              {
                  final String error =
                    "Internal error while attempting to establish the transient lifestyle handler.";
                  throw new LifestyleRuntimeException( error, e );
              }
          }
          else if( policy.equals( "thread" ) )
          {
              try
              {
                  ThreadLocalLifestyleHandler thread = new ThreadLocalLifestyleHandler();
                  thread.enableLogging( getLogger().getChildLogger("transient") );
                  thread.contextualize( context );
                  thread.service( m_manager );
                  thread.initialize();
                  return thread;
              }
              catch( Throwable e )
              {
                  final String error =
                    "Internal error while attempting to establish the transient lifestyle handler.";
                  throw new LifestyleRuntimeException( error, e );
              }
          }
          else
          {
              final String error = 
                "Lifestyle policy argument '" + policy + "' within appliance: " 
                + appliance + "' is not recognized.";
              throw new LifestyleRuntimeException( error );
          }
      }
  
      private DeploymentService bootstrapDeploymentService( ServiceManager manager ) 
        throws ServiceException
      {
          try
          {
              DefaultDeploymentService deployment = new DefaultDeploymentService();
              deployment.enableLogging( getLogger().getChildLogger( "deployment" ) );
              deployment.service( manager );
              deployment.contextualize( m_context );
              deployment.initialize();
              return deployment;
          }
          catch( Throwable e )
          {
              final String error = 
                "Internal error while attempting to create bootstrap deployment service.";
              throw new ServiceException( error, e );
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleException.java
  
  Index: LifestyleException.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.lifestyle;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * Exception to indicate that there was a lifestyle related error.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:56 $
   */
  public class LifestyleException
      extends CascadingException
  {
  
      /**
       * Construct a new <code>LifestyleException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public LifestyleException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>LifestyleException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public LifestyleException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleHandler.java
  
  Index: LifestyleHandler.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.lifestyle;
  
  import org.apache.avalon.meta.info.DependencyDescriptor;
  import org.apache.avalon.meta.info.StageDescriptor;
  
  /**
   * A lifestyle handler provides support for a particular lifestyle policy.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:56 $
   */
  public interface LifestyleHandler
  {
     /**
      * Activate a service provided by the appliance.
      * @param appliance the appliance to deploy
      */
      Object access( DependencyDescriptor dependency ) throws LifestyleException;
  
     /**
      * Activate an extension handler provided by the appliance.
      * @param appliance the appliance to deploy
      */
      Object access( StageDescriptor stage ) throws LifestyleException;
  
     /**
      * Release an a service or handler established by the appliance.
      * @param object the service to be released
      */
      void release( Object object );
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleRuntimeException.java
  
  Index: LifestyleRuntimeException.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.lifestyle;
  
  import org.apache.avalon.framework.CascadingRuntimeException;
  
  /**
   * Exception to indicate that there was a lifestyle related runtime error.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:56 $
   */
  public class LifestyleRuntimeException
      extends CascadingRuntimeException
  {
  
      /**
       * Construct a new <code>LifestyleRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public LifestyleRuntimeException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>LifestyleRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public LifestyleRuntimeException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleService.java
  
  Index: LifestyleService.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.lifestyle;
  
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  /**
   * A lifestyle service provides support for the creation of a lifestyle 
   * handlers.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:56 $
   */
  public interface LifestyleService
  {
     /**
      * Creation of a new lifestyle handler.
      * @param appliance the appliance that the handler will manage
      * @param classloader the classloader to assign to the handler
      * @param logger the logging channel to be assigned to new 
      *    instances of the appliance
      * @param context a deployment context
      */
      LifestyleHandler createHandler( 
        Appliance appliance, ClassLoader classloader, Logger logger, Context context );
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/PooledLifestyleHandler.java
  
  Index: PooledLifestyleHandler.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.lifestyle;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.activity.Initializable;
  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.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.assembly.appliance.Appliance;
  import org.apache.avalon.assembly.lifecycle.DeploymentService;
  import org.apache.avalon.meta.info.DependencyDescriptor;
  import org.apache.avalon.meta.info.StageDescriptor;
  import org.apache.excalibur.mpool.Pool;
  import org.apache.excalibur.mpool.PoolManager;
  import org.apache.excalibur.mpool.ObjectFactory;
  
  /**
   * Lifestyle implementation that provides suppport for the pooled
   * policy.  Request for an instance will be served from a pool of
   * components.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:56 $
   */
  public class PooledLifestyleHandler extends AbstractLifestyleHandler implements ObjectFactory, Configurable, Contextualizable, Initializable, Disposable
  {
      //==============================================================
      // state
      //==============================================================
  
     /**
      * The appliance that this handler is handling.
      */
      private Appliance m_appliance;
  
     /**
      * The runtime context.
      */
      private Context m_context;
  
     /**
      * The deplyment service to handle lifecycle processing of 
      * component implementations established by this handler.
      */
      private DeploymentService m_deployment;
  
     /**
      * The pool manager.
      */
      private PoolManager m_poolManager;
  
     /**
      * The object pool.
      */
      private Pool m_pool;
  
     /**
      * The object pool size.
      */
      private int m_size;
  
     /**
      * The class of object managed by the pool.
      */
      private Class m_class;
  
  
      //==============================================================
      // Configurable
      //==============================================================
  
     /**
      * Supply of the static configuration for the deployment service.
      * @param config the static configuration
      */
      public void configure( Configuration config ) throws ConfigurationException
      {
          if( config == null )
          {
              throw new NullPointerException( "config" );
          }
          m_size = config.getAttributeAsInteger( "size", 5 );
      }
  
      //==============================================================
      // Contextualizable
      //==============================================================
  
     /**
      * <p>Application of a runtime context to the lifestyle service.
      * The context value will be passed directly to lifestyle handlers 
      * established by this service.
      * @param context the runtime context
      */
      public void contextualize( Context context ) throws ContextException
      {
          super.contextualize( context );
          m_poolManager = (PoolManager) context.get( "assembly:pool-manager" );
          m_context = context;
      }
  
      //==============================================================
      // Initializable
      //==============================================================
  
      /**
       * Set up the pool.
       *
       * @exception Exception if an error occurs setting up the pool
       */
      public void initialize() throws Exception
      {
          super.initialize();
          m_pool = m_poolManager.getManagedPool( this, m_size );
          m_appliance = (Appliance) m_context.get( "assembly:appliance.target" );
          ClassLoader classloader = (ClassLoader) m_context.get( "avalon:classloader" );
          m_class = classloader.loadClass( m_appliance.getProfile().getType().getInfo().getClassname() );
      }
  
      //==============================================================
      // LifestyleHandler
      //==============================================================
  
     /**
      * Activate a service provided by the appliance.
      * @param appliance the appliance to deploy
      */
      public Object access( DependencyDescriptor dependency ) throws LifestyleException
      {
          return access();
      }
  
     /**
      * Activate an extension handler provided by the appliance.
      * @param appliance the appliance to deploy
      */
      public Object access( StageDescriptor stage ) throws LifestyleException
      {
          return access();
      }
  
      /**
       * Returns an instance of the object type supported by the
       * manager to the client.
       *
       * @param context the execution context
       * @return an instance of the type defined by the profile
       * @exception Exception if an error occurs while aquiring the object
       */
      private Object access() throws LifestyleException
      {
          try
          {
              Object object = m_pool.acquire();
              //super.processAccessStage( object );
              return object;
          }
          catch( Throwable e )
          {
              final String error = 
                "Internal pool error occured while aquiring an object under appliance: " 
                + m_appliance;
              throw new LifestyleException( error, e );
          }
      }
  
     /**
      * Release an a service or handler established by the appliance.
      * @param object the service to be released
      */
      public void release( Object object )
      {
          if( object == null )
          {
              return;
          }
  
          try
          {
              m_pool.release( object );
          }
          catch( Throwable e )
          {
              if( getLogger().isWarnEnabled() )
              {
                  final String warning = 
                   "Unexpected error occured while releasing a pooled object.";
                  getLogger().warn( warning );
              }
          }
      }
  
      //==============================================================
      // ObjectFactory
      //==============================================================
  
      /**
       * Returns the implementation class managed by the pool.
       * @return the implementation class
       */
      public Class getCreatedClass()
      {
          return m_class;
      }
  
      /**
       * Handle disposal of the supplied object.
       * @param object the object to dispose of
       * @exception Exception if an error in disposal occurs
       */
      public void dispose( Object object ) throws Exception
      {
          m_deployment.decommission( m_appliance, object );
      }
  
      public Object newInstance() throws LifestyleException
      {
          return super.newInstance();
      }
  
      //==============================================================
      // Disposable
      //==============================================================
  
      /**
       * Disposal of the handler. 
       */
      public void dispose()
      {
          if( m_pool instanceof Disposable )
          {
              try
              {
                  ((Disposable)m_pool ).dispose();
              }
              catch( Throwable e )
              {
                  // ignore
              }
          }
  
          m_pool = null;
          m_poolManager = null;
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/SingletonLifestyleHandler.java
  
  Index: SingletonLifestyleHandler.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.lifestyle;
  
  import org.apache.avalon.framework.activity.Initializable;
  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.logger.Logger;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.meta.info.DependencyDescriptor;
  import org.apache.avalon.meta.info.StageDescriptor;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  /**
   * The singleton lifestyle handler provides support for object instantiation and 
   * lifecycle processing.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:56 $
   */
  public class SingletonLifestyleHandler extends AbstractLifestyleHandler
  {
      //==============================================================
      // state
      //==============================================================
  
     /**
      * The singleton instance.
      */
      private Object m_instance;
  
      //==============================================================
      // LifestyleHandler
      //==============================================================
  
     /**
      * Activate a service provided by the appliance.
      * @param appliance the appliance to deploy
      */
      public Object access( DependencyDescriptor dependency ) throws LifestyleException
      {
          return newInstance();
      }
  
     /**
      * Activate an extension handler provided by the appliance.
      * @param appliance the appliance to deploy
      */
      public Object access( StageDescriptor stage ) throws LifestyleException
      {
          return newInstance();
      }
  
     /**
      * Release an a service or handler established by the appliance.
      * @param object the service to be released
      */
      public void release( Object object )
      {
          // nothing to do
      }
  
      //==============================================================
      // Disposable
      //==============================================================
  
      /**
       * Request for disposal of the handler. 
       */
      public void dispose()
      {
          m_instance = null;
          super.dispose();
      }
  
      //==============================================================
      // utilities
      //==============================================================
  
     /**
      * Creation of a new intance of the class declared by the profile backing the 
      * appliance assigned to this handler.
      * @return Object a new instance of the component class
      */
      protected Object newInstance() throws LifestyleException
      {
          if( m_instance == null )
          {
              m_instance = super.newInstance();
          }
          return m_instance;
      }
  
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/ThreadLocalLifestyleHandler.java
  
  Index: ThreadLocalLifestyleHandler.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.lifestyle;
  
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.meta.model.Profile;
  import org.apache.avalon.meta.info.DependencyDescriptor;
  import org.apache.avalon.meta.info.StageDescriptor;
  
  /**
   * Lifestyle implementation that provides suppport for the per thread
   * policy.  Request for a single instance will allways return the
   * same instance for each request.
   */
  public class ThreadLocalLifestyleHandler extends AbstractLifestyleHandler
  {
  
      private ThreadLocalComponent m_instance;
  
     /**
      * Activate a service provided by the appliance.
      * @param appliance the appliance to deploy
      */
      public Object access( DependencyDescriptor dependency ) throws LifestyleException
      {
          return access();
      }
  
     /**
      * Activate an extension handler provided by the appliance.
      * @param appliance the appliance to deploy
      */
      public Object access( StageDescriptor stage ) throws LifestyleException
      {
          return access();
      }
  
     /**
      * Release an a service or handler established by the appliance.
      * @param object the service to be released
      */
      public void release( Object object )
      {
          if( object == null )
          {
              return;
          }
  
          if( object.equals( m_instance.get() ) )
          {
              //super.processReleaseStage( object );
          }
      }
  
      /**
       * Returns an instance of the object type supported by the
       * manager to the client.
       * @param context the execution context
       * @return an instance of the type defined by the appliance
       * @exception Exception if an access phase error occurs
       */
      private Object access()
      {
          getLogger().debug( "get" );
  
          if( m_instance == null )
          {
              m_instance = new ThreadLocalComponent( this );
          }
          Object object = m_instance.get();
          //super.processAccessStage( object );
          return object;
      }
  
     /**
      * Internal utility class to hold the thread local instance .
      */
      private static final class ThreadLocalComponent extends ThreadLocal
      {
          private final ThreadLocalLifestyleHandler m_handler;
  
          protected ThreadLocalComponent( ThreadLocalLifestyleHandler handler )
          {
              m_handler = handler;
          }
  
          protected Object initialValue()
          {
              try
              {
                  return m_handler.newInstance();
              }
              catch( Exception e )
              {
                  return null;
              }
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/TransientLifestyleHandler.java
  
  Index: TransientLifestyleHandler.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.lifestyle;
  
  import org.apache.avalon.framework.activity.Initializable;
  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.logger.Logger;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.meta.info.DependencyDescriptor;
  import org.apache.avalon.meta.info.StageDescriptor;
  import org.apache.avalon.assembly.appliance.Appliance;
  
  /**
   * The abstract lifestyle handler provides support for object instantiation and 
   * lifecycle processing.
   *
   * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/29 13:04:56 $
   */
  public class TransientLifestyleHandler extends AbstractLifestyleHandler 
  {
      //==============================================================
      // state
      //==============================================================
  
     /**
      * The singleton instance.
      */
      private Object m_instance;
  
      //==============================================================
      // LifestyleHandler
      //==============================================================
  
     /**
      * Activate a service provided by the appliance.
      * @param appliance the appliance to deploy
      */
      public Object access( DependencyDescriptor dependency ) throws LifestyleException
      {
          return newInstance();
      }
  
     /**
      * Activate an extension handler provided by the appliance.
      * @param appliance the appliance to deploy
      */
      public Object access( StageDescriptor stage ) throws LifestyleException
      {
          return newInstance();
      }
  
     /**
      * Release an a service or handler established by the appliance.
      * @param object the service to be released
      */
      public void release( Object object )
      {
          // need to stop and dispose of the object 
      }
  
      //==============================================================
      // Disposable
      //==============================================================
  
      /**
       * Request for disposal of the handler. 
       */
      public void dispose()
      {
          m_instance = null;
          super.dispose();
      }
  
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The <code>lifestyle</code> package includes interfaces and classes supporting the four standard lifestyle policies - singleton, thread, pooled and transient.
  </p>
  </body>
  
  
  
  1.3       +26 -9     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/profile/DefaultProfileManager.java
  
  Index: DefaultProfileManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/profile/DefaultProfileManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultProfileManager.java	26 Nov 2002 18:04:22 -0000	1.2
  +++ DefaultProfileManager.java	29 Nov 2002 13:04:56 -0000	1.3
  @@ -113,11 +113,6 @@
       */
       private ProfileManager m_parent;
   
  -   /**
  -    * The type manager (supplied via context).
  -    */
  -    private TypeManager m_types;
  -
       /**
        * Table of component profiles keyed by profile name.
        */
  @@ -148,8 +143,8 @@
       *   </tr>
       *   <tr>
       *     <td>assembly:parent</td>
  -    *     <td>{@link org.apache.avalon.assembly.type.TypeManager}</td>
  -    *     <td>In no value suppled, this type manager will be considered as a root manager.</td> 
  +    *     <td>{@link org.apache.avalon.assembly.profile.ProfileManager}</td>
  +    *     <td>In no value suppled, this manager will be considered as root.</td> 
       *   </tr>
       * </table>
       * @param context the runtime context
  @@ -263,8 +258,30 @@
       }
   
      /**
  +    * 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 
  +    * @exception ProfileException if a profile verification failure occurs
  +    * @see #createProfile
  +    */
  +    public void addProfiles( Profile[] profiles ) throws DuplicateProfileException, ProfileException
  +    {
  +        if( !m_initialized )
  +        {
  +            throw new IllegalStateException("initialization");
  +        }
  +
  +        for( int i=0; i<profiles.length; i++ )
  +        {
  +            Profile profile = profiles[i];
  +            addProfile( profile );
  +        }
  +    }
  +
  +   /**
       * Add a profile to the manager.
  -    * @param profile the depployment profile to add 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 
       * @exception ProfileException if a profile verification failure occurs
  
  
  
  1.3       +11 -1     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/profile/ProfileManager.java
  
  Index: ProfileManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/profile/ProfileManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProfileManager.java	26 Nov 2002 18:04:22 -0000	1.2
  +++ ProfileManager.java	29 Nov 2002 13:04:56 -0000	1.3
  @@ -88,6 +88,16 @@
         throws ProfileException;
   
      /**
  +    * 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 
  +    * @exception ProfileException if a profile verification failure occurs
  +    * @see #createProfile
  +    */
  +    public void addProfiles( Profile[] profiles ) throws DuplicateProfileException, ProfileException;
  +
  +   /**
       * Add a profile to the manager.
       * @param profile the depployment profile to add to the manager
       * @exception DuplicateProfileException if the supplied type is already registered
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/util/ExceptionHelper.java
  
  Index: ExceptionHelper.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.util;
  
  import java.io.PrintWriter;
  import java.io.StringWriter;
  import java.lang.reflect.Method;
  import java.util.StringTokenizer;
  
  /**
   * General utilities supporting the packaging of exception messages.
   * @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
   */
  public class ExceptionHelper
  {
      private static final String LINE_SEPARATOR = System.getProperty( "line.separator" );
  
      /**
       * Prints the exception to the standard error out together with
       * cause statements.
       * @param e the exception to print
       */
      public static void printException( Throwable e )
      {
          printException( null, e );
      }
  
      /**
       * Prints the exception to the standard error out together with
       * cause statements.
       * @param label label identifying the error
       * @param e the exception to print
       */
      public static void printException( String label, Throwable e )
      {
          printException( label, e, null );
      }
  
      /**
       * Prints the exception to the standard error out together with
       * source and cause statements.
       * @param label label identifying the error
       * @param e the exception to print
       * @param source the source of the request
       */
      public static void printException( String label, Throwable e, Object source )
      {
          printException( label, e, source, false );
      }
  
      /**
       * Prints the exception to the standard error out together with
       * source and cause statements.
       * @param label label identifying the error
       * @param e the exception to print
       * @param source the source of the request
       * @param trace boolean value inidication if a stack trace though be included
       */
      public static void printException( String label, Throwable e, Object source, boolean trace )
      {
          if( e == null )
          {
              throw new NullPointerException( "throwable" );
          }
          java.io.PrintStream out = System.err;
          synchronized( out )
          {
              out.println( "===================================================================" );
              if( label != null )
              {
                  out.println( "Message: " + label );
              }
              if( source != null )
              {
                  out.println( "Source: " + source );
              }
              out.println( "Exception: " + e.toString() );
              if( getCause( e ) != null )
              {
                  printCause( out, e );
              }
              out.println( "===================================================================" );
              if( trace )
              {
                  Throwable root = getLastThrowable( e );
                  root.printStackTrace();
                  out.println( "===================================================================" );
              }
          }
      }
  
      /**
       * Returns the exception and causal exceptions as a formatted string.
       * @param message the header message
       * @param e the exception
       * @return String the formatting string
       */
      public static String packException( final String message, final Throwable e )
      {
          StringBuffer buffer = new StringBuffer();
          buffer.append( "Message: " + message );
          buffer.append( "\n===================================================================" );
          if( e == null )
          {
              return buffer.toString();
          }
          else
          {
              buffer.append( "\nException: " + e.toString() );
              packCause( buffer, getCause( e ) ).toString();
              buffer.append( "\n===================================================================" );
          }
          Throwable root = getLastThrowable( e );
          if( root != null )
          {
              String[] trace = captureStackTrace( root );
              for( int i = 0; i < trace.length; i++ )
              {
                  buffer.append( "\n" + trace[ i ] );
              }
          }
          buffer.append( "\n===================================================================" );
          return buffer.toString();
      }
  
      private static StringBuffer packCause( StringBuffer buffer, Throwable cause )
      {
          if( cause == null )
          {
              return buffer;
          }
          buffer.append( "\nCause: " + cause.toString() );
          return packCause( buffer, getCause( cause ) );
      }
  
      private static Throwable getLastThrowable( Throwable exception )
      {
          Throwable cause = getCause( exception );
          if( cause != null )
          {
              return getLastThrowable( cause );
          }
          return exception;
      }
  
      private static Throwable getCause( Throwable exception )
      {
          if( exception == null )
          {
              throw new NullPointerException( "exception" );
          }
  
          try
          {
              Method method = exception.getClass().getMethod( "getCause", new Class[ 0 ] );
              return (Throwable)method.invoke( exception, new Object[ 0 ] );
          }
          catch( Throwable e )
          {
              return null;
          }
      }
  
      /**
       * Captures the stack trace associated with this exception.
       *
       * @param throwable a <code>Throwable</code>
       * @return an array of Strings describing stack frames.
       */
      private static String[] captureStackTrace( final Throwable throwable )
      {
          final StringWriter sw = new StringWriter();
          throwable.printStackTrace( new PrintWriter( sw, true ) );
          return splitString( sw.toString(), LINE_SEPARATOR );
      }
  
      /**
       * Splits the string on every token into an array of stack frames.
       *
       * @param string the string to split
       * @param onToken the token to split on
       * @return the resultant array
       */
      private static String[] splitString( final String string, final String onToken )
      {
          final StringTokenizer tokenizer = new StringTokenizer( string, onToken );
          final String[] result = new String[ tokenizer.countTokens() ];
  
          for( int i = 0; i < result.length; i++ )
          {
              result[ i ] = tokenizer.nextToken();
          }
  
          return result;
      }
  
      private static void printCause( java.io.PrintStream out, Throwable e )
      {
          Throwable cause = getCause( e );
          out.println( "Cause: " + cause.toString() );
          if( getCause( cause ) != null )
          {
              printCause( out, cause );
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/util/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The <code>util</code> package contains a number of general component utilities.</p>
  </body>
  
  
  
  1.2       +10 -3     avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/TestCaseBase.java
  
  Index: TestCaseBase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/TestCaseBase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestCaseBase.java	24 Nov 2002 12:50:46 -0000	1.1
  +++ TestCaseBase.java	29 Nov 2002 13:04:56 -0000	1.2
  @@ -10,8 +10,12 @@
   
   import java.io.File;
   import junit.framework.TestCase;
  -import org.apache.avalon.assembly.logger.DefaultLoggerManager;
  +import org.apache.avalon.assembly.logging.LoggingManager;
  +import org.apache.avalon.assembly.logging.TargetDescriptor;
  +import org.apache.avalon.assembly.logging.LoggingDescriptor;
  +import org.apache.avalon.assembly.logging.DefaultLoggingManager;
   import org.apache.avalon.framework.logger.*;
  +import org.apache.avalon.meta.model.Category;
   
   /**
    * A testcase for the @link{TypeManager}.
  @@ -22,7 +26,7 @@
   {
   
       protected ClassLoader m_loader;
  -    protected DefaultLoggerManager m_logManager;
  +    protected LoggingManager m_logManager;
   
       public TestCaseBase( String name )
       {
  @@ -33,7 +37,10 @@
       {
           m_loader = Thread.currentThread().getContextClassLoader();
           final File base = new File( System.getProperty( "user.dir" ) );
  -        m_logManager = new DefaultLoggerManager( base );
  +        LoggingDescriptor logging = 
  +           new LoggingDescriptor( 
  +             "", "DEBUG", null, new TargetDescriptor[ 0 ], new Category( "logging" ) );
  +        m_logManager = new DefaultLoggingManager( logging, base );
       }
   
       protected Logger getLogger()
  
  
  
  1.2       +1 -1      avalon-sandbox/assembly/src/test/org/apache/avalon/playground/BasicComponent.xconfig
  
  Index: BasicComponent.xconfig
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/test/org/apache/avalon/playground/BasicComponent.xconfig,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BasicComponent.xconfig	24 Nov 2002 12:50:46 -0000	1.1
  +++ BasicComponent.xconfig	29 Nov 2002 13:04:56 -0000	1.2
  @@ -15,6 +15,6 @@
   -->
   
   <configuration>
  -   <message>Hello.</message>
  +   <message>Hello</message>
   </configuration>
   
  
  
  

--
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