mcconnell 2002/12/20 19:28:38 Modified: assembly/src/java/org/apache/avalon/assembly/appliance Appliance.java ApplianceContext.java DefaultAppliance.java DependencyGraph.java assembly/src/java/org/apache/avalon/assembly/engine EngineClassLoader.java assembly/src/java/org/apache/avalon/assembly/lifecycle ContextHandler.java DefaultAssemblyService.java assembly/src/java/org/apache/avalon/assembly/lifecycle/composition DefaultCompositionService.java assembly/src/java/org/apache/avalon/assembly/lifecycle/configuration DefaultConfigurationService.java assembly/src/java/org/apache/avalon/assembly/lifecycle/disposal ExtendedDisposalService.java assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization DefaultInitializationService.java ExtendedInitializationService.java assembly/src/java/org/apache/avalon/assembly/lifecycle/logging DefaultLoggingService.java assembly/src/java/org/apache/avalon/assembly/lifecycle/parameters DefaultParameterizationService.java assembly/src/java/org/apache/avalon/assembly/lifestyle AbstractLifestyleHandler.java SingletonLifestyleHandler.java ThreadLocalLifestyleHandler.java assembly/src/test/org/apache/avalon/assembly/engine EngineTestCase.java Added: assembly/src/java/org/apache/avalon/assembly/appliance DefaultApplianceContext.java Log: Updates to the applaince context including seperation of interface and implementation. Revision Changes Path 1.11 +53 -10 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.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- Appliance.java 20 Dec 2002 11:54:28 -0000 1.10 +++ Appliance.java 21 Dec 2002 03:28:37 -0000 1.11 @@ -54,10 +54,14 @@ import java.net.URL; import org.apache.avalon.framework.activity.Initializable; +import org.apache.avalon.framework.parameters.Parameters; +import org.apache.avalon.framework.configuration.Configuration; 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; +import org.apache.avalon.meta.model.LoggingDirective; +import org.apache.avalon.meta.model.ContextDirective; import org.apache.avalon.meta.info.Type; /** @@ -80,12 +84,6 @@ "urn:assembly:appliance.class"; /** - * Get the deployment context. - * @return the deployment context - */ - Map getDeploymentContext(); - - /** * Get the appliance name. */ String getName(); @@ -143,10 +141,49 @@ void setEnabled( boolean value ); /** - * Return the assigned service providers. - * @return the set of service provider appliances. + * Return the logging categories for the profile. + * + * @return the logger */ - Appliance[] getServiceProviders(); + LoggingDirective getLoggingDirective(); + + /** + * Return the Parameters to be applied to the appliance. + * + * @return the Parameters for appliance. + */ + Parameters getParameters(); + + /** + * Return the Configuration for the appliance. + * + * @return the Configuration for the appliance. + */ + Configuration getConfiguration(); + + /** + * Get the deployment context. The deployment context includes + * supplimentary context values provided by the client that can be + * used by the context management framework during the creation + * and population of the context supplied to the target component. + * + * @return the deployment context + * @see #getContextDirective() + */ + Map getDeploymentContext(); + + /** + * Return the context directive for the profile. A context directive + * is declared in a component profile and may contain information + * unabling the selection of a component implementation class and + * constructed context values. This information may be used by the + * the context management framework during creation and population + * of the of the context supplied to the target component. + * + * @return the ContextDirective for the profile. + * @see #getDeploymentContext() + */ + ContextDirective getContextDirective(); /** * Return the context provider. @@ -169,6 +206,12 @@ * @return the appliance mapped as a provider of the role */ Appliance getServiceProvider( final String role ); + + /** + * Return the assigned service providers. + * @return the set of service provider appliances. + */ + Appliance[] getServiceProviders(); /** * Add the appliance that will acts as provider for a named dependency. 1.6 +67 -151 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceContext.java Index: ApplianceContext.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceContext.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ApplianceContext.java 20 Dec 2002 16:54:07 -0000 1.5 +++ ApplianceContext.java 21 Dec 2002 03:28:37 -0000 1.6 @@ -52,8 +52,10 @@ import java.util.Map; import java.util.Hashtable; +import java.util.ArrayList; import org.apache.avalon.framework.activity.Initializable; +import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.configuration.Configuration; @@ -71,9 +73,16 @@ 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.Type; import org.apache.avalon.meta.info.DependencyDescriptor; import org.apache.avalon.meta.info.StageDescriptor; +import org.apache.avalon.meta.info.LoggerDescriptor; import org.apache.avalon.meta.model.Profile; +import org.apache.avalon.meta.model.LoggingDirective; +import org.apache.avalon.meta.model.Category; +import org.apache.avalon.meta.model.ContextDirective; + +import org.apache.excalibur.configuration.CascadingConfiguration; /** * An appliance context aggregates the set of arguments that are supplied to @@ -82,7 +91,7 @@ * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a> * @version $Revision$ $Date$ */ -public class ApplianceContext extends DefaultContext +public interface ApplianceContext extends Context { //===================================================================== // static @@ -94,7 +103,7 @@ * a policy of startup on startup of the enclosing container. A value of * FALSE defers activation until demand. The default value is FALSE. * - * @see #setActivationPolicy( boolean ) + * @see DefaultApplianceContext#setActivationPolicy( boolean ) * @see #getActivationPolicy() */ public static final String ACTIVATION_KEY = "urn:assembly:appliance.activation"; @@ -105,7 +114,7 @@ * will normally be supplied by a containerment system and typically refers to * the containment path. * - * @see #setPartitionName( String ) + * @see DefaultApplianceContext#setPartitionName( String ) * @see #getPartitionName() */ public static final String PARTITION_KEY = "urn:assembly:appliance.partition"; @@ -115,7 +124,7 @@ * context information that will be supplied to te context handling framework along * with the system context information. * - * @see #setDeploymentContext( Map ) + * @see DefaultApplianceContext#setDeploymentContext( Map ) * @see #getDeploymentContext() */ public static final String DEPLOYMENT_KEY = "urn:assembly:appliance.deployment"; @@ -126,151 +135,68 @@ * will be the type name. If the type and profile names are different, the default * name will be "<type-name>#<profile-name>. * - * @see #setName( String ) + * @see DefaultApplianceContext#setName( String ) * @see #getName() */ public static final String NAME_KEY = "urn:assembly:appliance.name"; - //===================================================================== - // state - //===================================================================== - - /** - * The map of values managed by the context. - */ - private Map m_map = new Hashtable(); - - /** - * The underlying profile that this appliance is managing. - */ - private Profile m_profile; - - /** - * The enabled status of the profile. Normally a profile is enabled however, a - * failure to assemble will result in the disabling of the profile. - */ - private boolean m_enabled = true; - - /** - * The activation policy - TRUE if activation on startup, FALSE to activate on request. - */ - private boolean m_activation = true; - - /** - * The base path for the appliance. - */ - private String m_partition; - /** - * The appliance domain. + * Logging directives to be assigned to the appliance. The default value + * corresponds to any logging directives declared under the appliance profile. + * + * @see DefaultApplianceContext#setLoggingDirective( LoggingDirective ) + * @see #getLoggingDirective() */ - private String m_domain; - - /** - * The deployment context. - */ - private Map m_context; - - /** - * The appliance name. - */ - private String m_name; - - //============================================================== - // constructor - //============================================================== + public static final String LOGGING_KEY = "urn:assembly:appliance.logging.directive"; /** - * Creation of a new appliance context. - * @param profile the profile + * The default partition delimiter. */ - public ApplianceContext( Profile profile ) - { - super(); - if( profile == null ) - { - throw new NullPointerException( "profile" ); - } - m_map = getContextData(); - m_profile = profile; - } + public static final String PARTITION_DELIMITER = "/"; //============================================================== - // parameters + // interface //============================================================== /** - * Set the appliance name. - * @param the name - */ - public void setName( String name ) - { - if( m_name != null ) - { - throw new IllegalStateException("name"); - } - m_name = name; - } - - /** * Get the appliance name. * @return the name */ - public String getName() - { - if( m_name == null ) - { - return getProfile().getName(); - } - else - { - return m_name; - } - } + String getName(); /** * Get the appliance profile. * @return the profile */ - public Profile getProfile() - { - return m_profile; - } - - /** - * Set the appliance partition name. - * @param name the partition name - * @exception IllegalStateException if the partition name is already set - */ - public void setPartitionName( final String name ) throws IllegalStateException - { - if( m_partition != null ) - { - throw new IllegalStateException("partition"); - } - m_partition = name; - } - - /** - * Get the partition name - * @return the name (possibly null) - */ - public String getPartitionName() - { - return m_partition; - } + Profile getProfile(); + + /** + * Get the appliance type. + * @return the type + */ + Type getType(); /** - * Set the activation policy for the component. If TRUE, activation - * will occur at startup. If false, activation will be deferred to - * the first lookup invocation if any (i.e. lazy activation). + * Return the logging directives for the appliance. * - * @param policy the activation policy + * @return the logging directive */ - public void setActivationPolicy( final boolean policy ) - { - m_activation = policy; - } + LoggingDirective getLoggingDirective(); + + /** + * Return the context directive from the profile. The context directive + * returned from this method is the context directive contained within the + * profile supplied to the appliance context constructor. + * + * @return the context directive + */ + ContextDirective getContextDirective(); + + /** + * Get the partition name. + * @return the partition name + */ + String getPartitionName(); /** * Return the activation policy for the component. If TRUE, activation @@ -279,36 +205,26 @@ * * @return the activation policy */ - public boolean getActivationPolicy() - { - return m_activation; - } - - /** - * Set the deployment context. - * @param map the deployment context - * @exception IllegalStateException if the deployment context is already set - * @see #getDeploymentContext() - */ - public void setDeploymentContext( final Map map ) throws IllegalStateException - { - if( m_context != null ) - { - throw new IllegalStateException("map"); - } - m_context = map; - } + boolean getActivationPolicy(); /** * Get the deployment context. * @return the deployment context */ - public Map getDeploymentContext() - { - if( m_context == null ) - { - return new Hashtable(); - } - return m_context; - } + Map getDeploymentContext(); + + /** + * Return the Parameters for the appliance. + * + * @return the Parameters for the appliance. + */ + Parameters getParameters(); + + /** + * Return the Configuration for the appliance. + * + * @return the appliance configuration. + */ + Configuration getConfiguration(); + } 1.15 +89 -49 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.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- DefaultAppliance.java 20 Dec 2002 16:54:07 -0000 1.14 +++ DefaultAppliance.java 21 Dec 2002 03:28:37 -0000 1.15 @@ -52,10 +52,12 @@ import java.io.File; import java.util.Map; +import java.util.ArrayList; import java.util.Hashtable; import java.net.URL; import org.apache.avalon.framework.activity.Initializable; +import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.configuration.Configuration; @@ -73,9 +75,12 @@ 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.Type; import org.apache.avalon.meta.info.StageDescriptor; +import org.apache.avalon.meta.info.LoggerDescriptor; import org.apache.avalon.meta.model.Profile; -import org.apache.avalon.meta.info.Type; +import org.apache.avalon.meta.model.LoggingDirective; +import org.apache.avalon.meta.model.ContextDirective; /** * Default implementation of an applaince. @@ -97,7 +102,7 @@ /** * The profile. */ - private Profile m_profile; + private ApplianceContext m_context; /** * The lifestyle service from which the appliance lifestyle handler is established. @@ -123,7 +128,7 @@ /** * The context provider. */ - private Appliance m_context; + private Appliance m_contextProvider; /** * The dependencies providers keyed by role name. @@ -141,11 +146,6 @@ private String m_path; /** - * The partition name. - */ - private String m_partition; - - /** * The logging channel. */ private Logger m_logger; @@ -200,12 +200,11 @@ throw new NullPointerException( "logger" ); } + m_context = context; m_logger = logger; m_engine = engine; m_system = system; m_activation = context.getActivationPolicy(); - m_partition = context.getPartitionName(); - m_profile = (Profile) context.getProfile(); try { @@ -216,26 +215,9 @@ m_domain = "localhost"; } - if( m_partition == null ) - { - m_partition = "/"; - } - - if( !m_partition.endsWith("/") ) - { - m_partition = m_partition + "/"; - } - - if( context.getName() == null ) - { - m_name = context.getProfile().getName(); - } - else - { - m_name = context.getName(); - } + m_name = context.getName(); - m_path = m_partition + m_name; + m_path = m_context.getPartitionName() + m_name; // // make sure that the deployment context is fully populated @@ -250,7 +232,7 @@ // map.put( "urn:avalon:name", m_name ); - map.put( "urn:avalon:partition.name", m_partition ); + map.put( "urn:avalon:partition.name", m_context.getPartitionName() ); // // setup the home and working directory for the component @@ -317,22 +299,21 @@ return m_name; } + /** + * Get the appliance context. + */ + public ApplianceContext getApplianceContext() + { + return m_context; + } + /** * Return the component type backing the appliance. * @return the type that this appliance is managing */ public Type getType() { - return m_profile.getType(); - } - - /** - * Return the loging channel for the appliance. - * @return the logging channel - */ - protected Logger getLogger() - { - return m_logger; + return m_context.getType(); } /** @@ -362,7 +343,7 @@ */ public String getPartitionName() { - return m_partition; + return m_context.getPartitionName(); } /** @@ -374,8 +355,13 @@ } /** - * Get the deployment context. + * Get the deployment context. The deployment context includes + * supplimentary context values provided by the client that can be + * used by the context management framework during the creation + * and population of the context supplied to the target component. + * * @return the deployment context + * @see #getContextDirective() */ public Map getDeploymentContext() { @@ -383,13 +369,49 @@ } /** + * Return the context directive for the profile. A context directive + * is declared in a component profile and may contain information + * unabling the selection of a component implementation class and + * constructed context values. This information may be used by the + * the context management framework during creation and population + * of the of the context supplied to the target component. + * + * @return the ContextDirective for the profile. + * @see #getDeploymentContext() + */ + public ContextDirective getContextDirective() + { + return m_context.getContextDirective(); + } + + /** + * Return the Parameters to be applied to the appliance. + * + * @return the Parameters for appliance. + */ + public Parameters getParameters() + { + return m_context.getParameters(); + } + + /** + * Return the Configuration for the appliance. + * + * @return the Configuration for the appliance. + */ + public Configuration getConfiguration() + { + return m_context.getConfiguration(); + } + + /** * Return the profile backing the appliance. * * @return the profile that this appliance is managing */ public Profile getProfile() { - return m_profile; + return m_context.getProfile(); } /** @@ -427,13 +449,23 @@ } /** + * Return the logging categories for the profile. + * + * @return the logger + */ + public LoggingDirective getLoggingDirective() + { + return m_context.getLoggingDirective(); + } + + /** * Return the context provider. * * @return the appliance mapped as provider of the context */ public Appliance getContextProvider() { - return m_context; + return m_contextProvider; } /** @@ -444,11 +476,11 @@ */ public void setContextProvider( Appliance appliance ) { - if( m_context != null ) + if( m_contextProvider != null ) { throw new IllegalStateException( "appliance" ); } - m_context = appliance; + m_contextProvider = appliance; } /** @@ -553,14 +585,14 @@ catch( Throwable e ) { final String error = - "Lifestyle handler raised a release error in appliance: " + getProfile().getName(); + "Lifestyle handler raised a release error in appliance: " + this; throw new ApplianceRuntimeException( error, e ); } } public String toString() { - return "[" + getProfile().getName() + "/" + System.identityHashCode( this ) + "]"; + return "[" + getName() + "/" + System.identityHashCode( this ) + "]"; } /** @@ -571,4 +603,12 @@ m_handler.terminate(); } + /** + * Return the loging channel for the appliance. + * @return the logging channel + */ + protected Logger getLogger() + { + return m_logger; + } } 1.4 +2 -2 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DependencyGraph.java Index: DependencyGraph.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DependencyGraph.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DependencyGraph.java 20 Dec 2002 11:54:28 -0000 1.3 +++ DependencyGraph.java 21 Dec 2002 03:28:37 -0000 1.4 @@ -371,7 +371,7 @@ final ArrayList order ) { - final String name = appliance.getProfile().getName(); + final String name = appliance.getName(); final int size = m_appliances.size(); for( int i = 0; i < size; i++ ) 1.1 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceContext.java Index: DefaultApplianceContext.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.avalon.assembly.appliance; import java.util.Map; import java.util.Hashtable; import java.util.ArrayList; import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.parameters.Parameters; 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.DefaultContext; 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.engine.EngineClassLoader; 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.Type; import org.apache.avalon.meta.info.DependencyDescriptor; import org.apache.avalon.meta.info.StageDescriptor; import org.apache.avalon.meta.info.LoggerDescriptor; import org.apache.avalon.meta.model.Profile; import org.apache.avalon.meta.model.LoggingDirective; import org.apache.avalon.meta.model.Category; import org.apache.avalon.meta.model.ContextDirective; import org.apache.excalibur.configuration.CascadingConfiguration; /** * An appliance context aggregates the set of arguments that are supplied to * and appliance instance. * * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a> * @version $Revision: 1.1 $ $Date: 2002/12/21 03:28:37 $ */ public class DefaultApplianceContext extends DefaultContext implements ApplianceContext { //===================================================================== // state //===================================================================== /** * The map of values managed by the context. */ private Map m_map = new Hashtable(); /** * The underlying profile that this appliance is managing. */ private Profile m_profile; /** * The enabled status of the profile. Normally a profile is enabled however, a * failure to assemble will result in the disabling of the profile. */ private boolean m_enabled = true; /** * The activation policy - TRUE if activation on startup, FALSE to activate on request. */ private boolean m_activation = true; /** * The base path for the appliance. */ private String m_partition; /** * The appliance domain. */ private String m_domain; /** * The deployment context. */ private Map m_context; /** * The appliance name. */ private String m_name; /** * The consolidated logging directives. */ private LoggingDirective m_logging; /** * The modified parameters. */ private Parameters m_parameters; /** * The extended configuration. */ private Configuration m_config; //============================================================== // constructor //============================================================== /** * Creation of a new appliance context. * @param profile the profile */ public DefaultApplianceContext( Profile profile ) { super(); if( profile == null ) { throw new NullPointerException( "profile" ); } m_map = getContextData(); m_profile = profile; } //============================================================== // parameters //============================================================== /** * Set the appliance name. * @param the name * @exception NullPointerException if the supplied name is null * @exception IllegalStateException if the context is write protected */ public void setName( String name ) throws NullPointerException, IllegalStateException { checkWritable(); if( name == null ) { throw new NullPointerException( "name" ); } m_name = name; } /** * Get the appliance name. * @return the name */ public String getName() { if( m_name == null ) { return getProfile().getName(); } else { return m_name; } } /** * Get the appliance profile. * @return the profile */ public Profile getProfile() { return m_profile; } /** * Get the appliance type. * @return the type */ public Type getType() { return m_profile.getType(); } /** * Set supplimentary logging directives for the profile. * * @param the supplimentary directives * @exception IllegalStateException if the logging categories have been set * @exception NullPointerException if the supplied directive is nulls */ public void setLoggingDirective( LoggingDirective directives ) throws IllegalStateException, NullPointerException { checkWritable(); if( directives == null ) { throw new NullPointerException( "logging" ); } m_logging = buildLoggingDirectives( directives ); } /** * Return the logging directives for the profile. * * @return the logger */ public LoggingDirective getLoggingDirective() { if( m_logging == null ) { LoggingDirective client = new LoggingDirective( m_profile.getType() ); m_logging = buildLoggingDirectives( client ); } return m_logging; } /** * Return the context directive from the profile. The context directive * returned from this method is the context directive contained within the * profile supplied to the appliance context constructor. * * @return the context directive */ public ContextDirective getContextDirective() { return m_profile.getContext(); } /** * Set the appliance partition name. * @param name the partition name * @exception IllegalStateException if the partition name is already set */ public void setPartitionName( final String name ) throws IllegalStateException { checkWritable(); if( name == null ) { m_partition = PARTITION_DELIMITER; } else { if( !name.endsWith( PARTITION_DELIMITER ) ) { m_partition = name + PARTITION_DELIMITER; } else { m_partition = name; } } } /** * Get the partition name * @return the name (possibly null) */ public String getPartitionName() { if( m_partition == null ) { return PARTITION_DELIMITER; } return m_partition; } /** * Set the activation policy for the component. If TRUE, activation * will occur at startup. If false, activation will be deferred to * the first lookup invocation if any (i.e. lazy activation). * * @param policy the activation policy * @exception IllegalStateException if the context is write protected */ public void setActivationPolicy( final boolean policy ) { checkWritable(); m_activation = policy; } /** * Return the activation policy for the component. If TRUE, activation * will occur at startup. If false, activation will be deferred to * the first lookup invocation if any (i.e. lazy activation). * * @return the activation policy */ public boolean getActivationPolicy() { return m_activation; } /** * Set the deployment context. * @param map the deployment context * @exception IllegalStateException if the appliance context is write protected * @exception NullPointerException if the supplied map is null * @see #getDeploymentContext() */ public void setDeploymentContext( final Map map ) throws IllegalStateException { checkWritable(); m_context = map; } /** * Get the deployment context. * @return the deployment context */ public Map getDeploymentContext() { if( m_context == null ) { return new Hashtable(); } return m_context; } /** * Creates a new parameters object based on the merge of the * profile parameters and supplied parameters. Profile parameters * remain unchanged. Supplied parameters take precedence over profile * parameters. * * @param parameters the parameters to merge with profile based parameters * @exception IllegalStateException if the context is write protected * @exception NullPointerException if the supplied parameters argument is null */ public void addParameters( Parameters parameters ) throws IllegalStateException, NullPointerException { checkWritable(); if( parameters == null ) { throw new NullPointerException("parameters"); } m_parameters = new Parameters(); m_parameters.merge( m_profile.getParameters() ); m_parameters.merge( parameters ); } /** * Return the Parameters for the appliance. If the parameters have not * been modfified, this operation returns the profile parameters. * * @return the Parameters for appliance. */ public Parameters getParameters() { if( m_parameters == null ) { return m_profile.getParameters(); } else { return m_parameters; } } /** * Creates a new cascading configuration backed by the profile configuration. * * @param config the configuration * @exception IllegalStateException if the context is write protected * @exception NullPointerException if the supplied configuration is null */ public void addConfiguration( Configuration config ) throws IllegalStateException, NullPointerException { checkWritable(); if( config == null ) { throw new NullPointerException("configuration"); } m_config = new CascadingConfiguration( config, m_profile.getConfiguration() ); } /** * Return the Configuration for the appliance. If a configuration have not * been set, this operation returns the profile configuration. * * @return the Configuration for the appliance. */ public Configuration getConfiguration() { if( m_config == null ) { return m_profile.getConfiguration(); } else { return m_config; } } /** * Create a consolidated logging descriptor that takes into account both type logging * category declarations and the profile level logging category directives * under a single <code>LoggingDirective</code> instance. * * @param directive the client supplied logging directives * @return the consolidated logging directives */ private LoggingDirective buildLoggingDirectives( LoggingDirective directive ) { LoggingDirective categories = m_profile.getCategories(); LoggerDescriptor[] loggers = m_profile.getType().getLoggers(); ArrayList list = new ArrayList(); for( int i = 0; i < loggers.length; i++ ) { String name = loggers[ i ].getName(); Category category = getCategory( name, directive, categories ); if( category != null ) { list.add( category ); } else { list.add( new Category( name ) ); } } return new LoggingDirective( categories.getName(), categories.getPriority(), categories.getTarget(), (Category[])list.toArray( new Category[ 0 ] ) ); } /** * Return a category based on preferential seletion for the primary * argument (client supplied), followed by the seocondary (the profile template) * or null if neither declare the category. * * @param name the category name to lookup * @primary the client supplied category defintion * @secondary the profile template defintion * @return the category or null if not defintions found */ private Category getCategory( String name, LoggingDirective primary, LoggingDirective secondary ) { Category category = primary.getCategory( name ); if( category == null ) { category = secondary.getCategory( name ); } return category; } } 1.14 +15 -5 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java Index: EngineClassLoader.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- EngineClassLoader.java 20 Dec 2002 11:54:28 -0000 1.13 +++ EngineClassLoader.java 21 Dec 2002 03:28:37 -0000 1.14 @@ -68,6 +68,7 @@ import org.apache.avalon.assembly.profile.ProfileManager; import org.apache.avalon.assembly.appliance.Appliance; import org.apache.avalon.assembly.appliance.ApplianceContext; +import org.apache.avalon.assembly.appliance.DefaultApplianceContext; import org.apache.avalon.assembly.appliance.ApplianceException; import org.apache.avalon.assembly.appliance.ApplianceManager; import org.apache.avalon.assembly.appliance.DefaultAppliance; @@ -880,8 +881,9 @@ } else { - ApplianceContext context = new ApplianceContext( profile ); + DefaultApplianceContext context = new DefaultApplianceContext( profile ); context.setPartitionName( partition ); + context.makeReadOnly(); appliance = createAppliance( context, true ); assemble( appliance ); } @@ -932,8 +934,9 @@ } else { - ApplianceContext context = new ApplianceContext( profile ); + DefaultApplianceContext context = new DefaultApplianceContext( profile ); context.setPartitionName( partition ); + context.makeReadOnly(); appliance = createAppliance( context, true ); assemble( appliance ); } @@ -972,7 +975,14 @@ if( getLogger().isDebugEnabled() ) { - getLogger().debug( "created " + appliance.getURL() ); + try + { + getLogger().debug( "created " + appliance.getURL() ); + } + catch( Throwable e ) + { + getLogger().debug( "created " + appliance ); + } } return appliance; @@ -981,7 +991,7 @@ private Appliance buildAppliance( ApplianceContext context, Context system, Logger logger ) throws ClassNotFoundException, ApplianceException { - InfoDescriptor info = context.getProfile().getType().getInfo(); + InfoDescriptor info = context.getType().getInfo(); String classname = info.getAttribute( Appliance.APPLIANCE_CLASS_ATTRIBUTE_NAME ); if( classname != null ) 1.10 +2 -2 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/ContextHandler.java Index: ContextHandler.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/ContextHandler.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ContextHandler.java 20 Dec 2002 11:54:28 -0000 1.9 +++ ContextHandler.java 21 Dec 2002 03:28:37 -0000 1.10 @@ -227,7 +227,7 @@ throws Exception { ContextDescriptor descriptor = appliance.getType().getContext(); - ContextDirective directive = appliance.getProfile().getContext(); + ContextDirective directive = appliance.getContextDirective(); return buildContext( appliance, descriptor, directive, context ); } 1.3 +5 -5 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/DefaultAssemblyService.java Index: DefaultAssemblyService.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/DefaultAssemblyService.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DefaultAssemblyService.java 20 Dec 2002 11:54:28 -0000 1.2 +++ DefaultAssemblyService.java 21 Dec 2002 03:28:37 -0000 1.3 @@ -270,7 +270,7 @@ throw new NullPointerException( "visited" ); } - String name = appliance.getProfile().getName(); + String name = appliance.getName(); getLogger().debug( pad + "assemble: " + name ); String pad2 = pad + " "; @@ -374,7 +374,7 @@ getLogger().debug( pad - + " associated supplier: " + supplier.getProfile().getName() + + " associated supplier: " + supplier.getName() + " with appliance: " + name + " under the role: " + role ); @@ -429,8 +429,8 @@ getLogger().debug( pad - + " associated extension provider: " + supplier.getProfile().getName() - + " with appliance: " + appliance.getProfile().getName() ); + + " associated extension provider: " + supplier + + " with appliance: " + appliance ); map.add( supplier ); } 1.5 +3 -5 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/DefaultCompositionService.java Index: DefaultCompositionService.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/DefaultCompositionService.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- DefaultCompositionService.java 17 Dec 2002 09:55:24 -0000 1.4 +++ DefaultCompositionService.java 21 Dec 2002 03:28:37 -0000 1.5 @@ -97,8 +97,7 @@ { if( getLogger().isDebugEnabled() ) { - final String message = - "[" + appliance.getProfile().getName() + "]"; + final String message = appliance.toString(); getLogger().debug( message ); } StandardServiceManager manager = new StandardServiceManager( appliance ); @@ -110,8 +109,7 @@ { if( getLogger().isDebugEnabled() ) { - final String message = - "[" + appliance.getProfile().getName() + "]"; + final String message = appliance.toString(); getLogger().debug( message ); } StandardServiceManager manager = new StandardServiceManager( appliance ); 1.3 +2 -3 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/configuration/DefaultConfigurationService.java Index: DefaultConfigurationService.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/configuration/DefaultConfigurationService.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DefaultConfigurationService.java 30 Nov 2002 18:12:06 -0000 1.2 +++ DefaultConfigurationService.java 21 Dec 2002 03:28:37 -0000 1.3 @@ -89,8 +89,7 @@ { if( getLogger().isDebugEnabled() ) { - final String message = - "[" + appliance.getProfile().getName() + "]"; + final String message = appliance.toString(); getLogger().debug( message ); } Configuration config = appliance.getProfile().getConfiguration(); 1.8 +4 -3 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/disposal/ExtendedDisposalService.java Index: ExtendedDisposalService.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/disposal/ExtendedDisposalService.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ExtendedDisposalService.java 20 Dec 2002 11:54:28 -0000 1.7 +++ ExtendedDisposalService.java 21 Dec 2002 03:28:37 -0000 1.8 @@ -125,8 +125,9 @@ { if( getLogger().isDebugEnabled() ) { - final String message = - "[" + appliance.getProfile().getName() + "] destroy stage extension handling" ; + final String message = + "destroy stage extension handling for appliance:" + + appliance; getLogger().debug( message ); } for( int i = 0; i < stages.length; i++ ) 1.3 +2 -2 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization/DefaultInitializationService.java Index: DefaultInitializationService.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization/DefaultInitializationService.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DefaultInitializationService.java 30 Nov 2002 18:12:06 -0000 1.2 +++ DefaultInitializationService.java 21 Dec 2002 03:28:37 -0000 1.3 @@ -78,7 +78,7 @@ if( getLogger().isDebugEnabled() ) { final String message = - "[" + appliance.getProfile().getName() + "]"; + appliance.toString(); getLogger().debug( message ); } ((Initializable)object).initialize(); 1.9 +4 -6 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization/ExtendedInitializationService.java Index: ExtendedInitializationService.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization/ExtendedInitializationService.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ExtendedInitializationService.java 20 Dec 2002 11:54:29 -0000 1.8 +++ ExtendedInitializationService.java 21 Dec 2002 03:28:37 -0000 1.9 @@ -131,9 +131,8 @@ if( getLogger().isDebugEnabled() ) { - final String message = - "[" + appliance.getProfile().getName() - + "] extension:" + stage; + final String message = + appliance + " stage: " + stage; getLogger().debug( message ); } @@ -217,8 +216,7 @@ { if( getLogger().isDebugEnabled() ) { - final String message = - "[" + appliance.getProfile().getName() + "] initialization"; + final String message = "initialization " + appliance; getLogger().debug( message ); } ((Initializable)object).initialize(); 1.5 +15 -42 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/logging/DefaultLoggingService.java Index: DefaultLoggingService.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/logging/DefaultLoggingService.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- DefaultLoggingService.java 3 Dec 2002 06:57:26 -0000 1.4 +++ DefaultLoggingService.java 21 Dec 2002 03:28:38 -0000 1.5 @@ -87,6 +87,8 @@ /** * <p>Application of a logging manager to this service.</p> * @param manager the service manager + * @exception ServiceException if the logging manager is included + * with the supplied manager */ public void service( ServiceManager manager ) throws ServiceException { @@ -99,7 +101,8 @@ /** * Initialization of the logging service. - * @exception Exception if an initialization error occurs + * @exception IllegalStateException if the logging service + * has not been serviced. */ public void initialize() throws Exception { @@ -115,9 +118,16 @@ /** * Applies primary and subsidiary logging channels to the component. + * Assignment of logging channels is based on the appliance partition + * and name. Logging category target and priority are derived from + * meta data associated with the appliance and applied against logging + * channel names declared on the appliance type. + * * @param appliance the appliace * @param object the object to which logging channels will be assigned - * @param path the absolute logging category path + * @see Appliance#getPath() + * @see LoggerDescriptor + * @see LoggingDirective */ public void enableLogging( Appliance appliance, Object object ) throws Exception @@ -133,56 +143,19 @@ if( object instanceof LogEnabled ) { - String name = appliance.getProfile().getName(); if( getLogger().isDebugEnabled() ) { - final String message = "[" + name + "]"; + final String message = appliance.toString(); getLogger().debug( message ); } String path = appliance.getPath(); - LoggingDirective logging = buildLoggingCategories( appliance.getProfile() ); + LoggingDirective logging = appliance.getLoggingDirective(); m_manager.addCategories( path, logging ); Logger logger = m_manager.getLoggerForCategory( path ); ((LogEnabled)object).enableLogging( logger ); } } - - /** - * Create a categories descriptor that takes into account both type logging - * category declarations and the profile level logging category definitions - * under a single <code>LoggingDirective</code> instance. - * - * @param profile the profile defining the type and profile level category - * information - * @return a new fully populated <code>LoggingDirective</code> - */ - private LoggingDirective buildLoggingCategories( Profile profile ) - { - LoggingDirective categories = profile.getCategories(); - LoggerDescriptor[] loggers = profile.getType().getLoggers(); - ArrayList list = new ArrayList(); - for( int i = 0; i < loggers.length; i++ ) - { - String name = loggers[ i ].getName(); - Category category = categories.getCategory( name ); - if( category != null ) - { - list.add( category ); - } - else - { - list.add( new Category( name ) ); - } - } - - return new LoggingDirective( - categories.getName(), - categories.getPriority(), - categories.getTarget(), - (Category[])list.toArray( new Category[ 0 ] )); - } - } 1.3 +2 -3 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/parameters/DefaultParameterizationService.java Index: DefaultParameterizationService.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/parameters/DefaultParameterizationService.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DefaultParameterizationService.java 30 Nov 2002 18:12:06 -0000 1.2 +++ DefaultParameterizationService.java 21 Dec 2002 03:28:38 -0000 1.3 @@ -89,8 +89,7 @@ { if( getLogger().isDebugEnabled() ) { - final String message = - "[" + appliance.getProfile().getName() + "]"; + final String message = appliance.toString(); getLogger().debug( message ); } Parameters params = appliance.getProfile().getParameters(); 1.13 +3 -3 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/AbstractLifestyleHandler.java Index: AbstractLifestyleHandler.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/AbstractLifestyleHandler.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- AbstractLifestyleHandler.java 20 Dec 2002 11:54:29 -0000 1.12 +++ AbstractLifestyleHandler.java 21 Dec 2002 03:28:38 -0000 1.13 @@ -471,8 +471,8 @@ { final String error = "Unexpected error while creating context for extension: " - + provider.getProfile().getName() - + " in appliance " + provider.getProfile().getName() + + provider + + " in appliance " + appliance + " for stage: " + stage; throw new LifestyleException( error, e ); } 1.8 +3 -5 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/SingletonLifestyleHandler.java Index: SingletonLifestyleHandler.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/SingletonLifestyleHandler.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- SingletonLifestyleHandler.java 17 Dec 2002 04:57:20 -0000 1.7 +++ SingletonLifestyleHandler.java 21 Dec 2002 03:28:38 -0000 1.8 @@ -109,8 +109,7 @@ if( getLogger().isDebugEnabled() ) { final String debug = - "access in appliance: " - + getAppliance().getProfile().getName(); + "access in appliance: " + getAppliance(); getLogger().debug( debug ); } Object object = newInstance(); @@ -159,8 +158,7 @@ if( getLogger().isDebugEnabled() ) { final String debug = - "new instance in appliance: " - + getAppliance().getProfile().getName(); + "new instance in appliance: " + getAppliance(); getLogger().debug( debug ); } 1.6 +1 -2 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/ThreadLocalLifestyleHandler.java Index: ThreadLocalLifestyleHandler.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/ThreadLocalLifestyleHandler.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ThreadLocalLifestyleHandler.java 17 Dec 2002 04:57:20 -0000 1.5 +++ ThreadLocalLifestyleHandler.java 21 Dec 2002 03:28:38 -0000 1.6 @@ -100,8 +100,7 @@ if( getLogger().isDebugEnabled() ) { final String message = - "access using thread local policy on appliance: " - + getAppliance().getProfile().getName(); + "access using thread local policy on appliance: " + getAppliance(); getLogger().debug( message ); } 1.9 +3 -1 avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/engine/EngineTestCase.java Index: EngineTestCase.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/engine/EngineTestCase.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- EngineTestCase.java 19 Dec 2002 10:46:16 -0000 1.8 +++ EngineTestCase.java 21 Dec 2002 03:28:38 -0000 1.9 @@ -21,6 +21,7 @@ import org.apache.avalon.assembly.engine.Engine; import org.apache.avalon.assembly.appliance.Appliance; import org.apache.avalon.assembly.appliance.ApplianceContext; +import org.apache.avalon.assembly.appliance.DefaultApplianceContext; import org.apache.avalon.assembly.util.ExceptionHelper; /** @@ -211,7 +212,8 @@ { Type type = m_engine.getRepository().getTypeManager().getType( classname ); Profile profile = m_engine.getRepository().getProfileManager().getProfile( type ); - ApplianceContext context = new ApplianceContext( profile ); + DefaultApplianceContext context = new DefaultApplianceContext( profile ); + context.makeReadOnly(); Appliance appliance = m_engine.createAppliance( context, false ); m_engine.assemble( appliance ); assertTrue( appliance.access() != null );
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>