mcconnell 2002/12/14 13:04:41 Modified: assembly/src/java/org/apache/avalon/assembly/appliance ApplianceManager.java DefaultAppliance.java DefaultApplianceFactory.java DefaultApplianceManager.java DefaultApplianceSelector.java package.html assembly/src/java/org/apache/avalon/assembly/engine Engine.java EngineClassLoader.java assembly/src/java/org/apache/avalon/assembly/lifecycle ContextHandler.java DefaultDeploymentService.java assembly/src/java/org/apache/avalon/assembly/lifestyle AbstractLifestyleHandler.java LifestyleHandler.java SingletonLifestyleHandler.java TransientLifestyleHandler.java assembly/src/java/org/apache/avalon/assembly/logging package.html assembly/src/java/org/apache/avalon/assembly/service package.html Added: assembly/src/java/org/apache/avalon/assembly/engine AssemblyException.java AssemblyService.java DefaultAssemblyService.java UnresolvedManagerException.java UnresolvedProviderException.java Removed: assembly/src/java/org/apache/avalon/assembly/appliance AssemblyException.java AssemblyService.java DefaultAssemblyService.java UnresolvedManagerException.java UnresolvedProviderException.java Log: Moved some sources from appliance to engine. Revision Changes Path 1.6 +2 -2 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.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ApplianceManager.java 7 Dec 2002 09:34:27 -0000 1.5 +++ ApplianceManager.java 14 Dec 2002 21:04:40 -0000 1.6 @@ -75,7 +75,7 @@ * @exception DuplicateApplianceException if an appliance has already been registered * for the underlying profile */ - void addAppliance( Appliance appliance ) throws DuplicateApplianceException, AssemblyException; + void addAppliance( Appliance appliance ) throws DuplicateApplianceException, NullPointerException; /** * Return the set of appliance istances capable of supporting the supplied dependency. 1.8 +3 -1 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- DefaultAppliance.java 12 Dec 2002 00:32:32 -0000 1.7 +++ DefaultAppliance.java 14 Dec 2002 21:04:40 -0000 1.8 @@ -50,6 +50,7 @@ package org.apache.avalon.assembly.appliance; +import java.util.Map; import java.util.Hashtable; import org.apache.avalon.framework.activity.Initializable; @@ -74,6 +75,7 @@ import org.apache.avalon.meta.model.Profile; /** + * Default implementation of an applaince. * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a> * @version $Revision$ $Date$ */ 1.2 +2 -2 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceFactory.java Index: DefaultApplianceFactory.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DefaultApplianceFactory.java 7 Dec 2002 09:34:27 -0000 1.1 +++ DefaultApplianceFactory.java 14 Dec 2002 21:04:40 -0000 1.2 @@ -86,7 +86,7 @@ * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a> * @version $Revision$ $Date$ */ -public class DefaultApplianceFactory extends AbstractLogEnabled +class DefaultApplianceFactory extends AbstractLogEnabled implements ApplianceFactory, Initializable { 1.6 +3 -2 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.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- DefaultApplianceManager.java 7 Dec 2002 09:34:27 -0000 1.5 +++ DefaultApplianceManager.java 14 Dec 2002 21:04:40 -0000 1.6 @@ -407,8 +407,9 @@ * @param appliance the appliance to add to the manager * @exception DuplicateApplianceException if an appliance has already been registered * for the undrlying profile + * @exception NullPointerException if the supplied appliance is null. */ - public void addAppliance( Appliance appliance ) throws DuplicateApplianceException, AssemblyException + public void addAppliance( Appliance appliance ) throws DuplicateApplianceException, NullPointerException { if( appliance == null ) { 1.3 +2 -2 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceSelector.java Index: DefaultApplianceSelector.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceSelector.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DefaultApplianceSelector.java 3 Dec 2002 06:57:25 -0000 1.2 +++ DefaultApplianceSelector.java 14 Dec 2002 21:04:40 -0000 1.3 @@ -64,7 +64,7 @@ * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a> * @version $Revision$ $Date$ */ -public class DefaultApplianceSelector implements ApplianceSelector +class DefaultApplianceSelector implements ApplianceSelector { /** * Returns the preferred appliance form an available selection of 1.2 +2 -1 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/package.html Index: package.html =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/package.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- package.html 24 Nov 2002 12:50:44 -0000 1.1 +++ package.html 14 Dec 2002 21:04:40 -0000 1.2 @@ -1,6 +1,7 @@ <body> <p> -The <code>appliace</code> package contains classes and interfaces for the [EMAIL PROTECTED] org.apache.avalon.assembly.appliance.Appliance} and related default implementations supporting the management of the lifecycle and lifestyle of a profiled service provider. +The <code>appliance</code> package contains classes and interfaces for the [EMAIL PROTECTED] org.apache.avalon.assembly.appliance.Appliance} and related default implementations supporting the management of the lifecycle and lifestyle of a profiled component type. </p> + </body> 1.6 +1 -2 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/Engine.java Index: Engine.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/Engine.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Engine.java 12 Dec 2002 00:32:32 -0000 1.5 +++ Engine.java 14 Dec 2002 21:04:40 -0000 1.6 @@ -58,7 +58,6 @@ import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.meta.model.Profile; import org.apache.avalon.assembly.appliance.Appliance; -import org.apache.avalon.assembly.appliance.AssemblyService; import org.apache.avalon.assembly.engine.model.ClasspathDescriptor; import org.apache.avalon.assembly.lifestyle.LifestyleService; import org.apache.avalon.assembly.lifestyle.LifestyleHandler; 1.7 +3 -6 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.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- EngineClassLoader.java 12 Dec 2002 00:32:32 -0000 1.6 +++ EngineClassLoader.java 14 Dec 2002 21:04:40 -0000 1.7 @@ -99,9 +99,6 @@ import org.apache.avalon.assembly.appliance.Appliance; import org.apache.avalon.assembly.appliance.ApplianceManager; import org.apache.avalon.assembly.appliance.ApplianceFactory; -import org.apache.avalon.assembly.appliance.AssemblyService; -import org.apache.avalon.assembly.appliance.AssemblyException; -import org.apache.avalon.assembly.appliance.DefaultAssemblyService; import org.apache.avalon.assembly.appliance.DefaultApplianceManager; import org.apache.avalon.assembly.appliance.DependencyGraph; import org.apache.avalon.assembly.appliance.MappedServiceManager; @@ -126,7 +123,7 @@ import org.apache.excalibur.event.command.TPCThreadManager; /** - * + * Default implementation of the service management engine. * * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a> * @version $Revision$ $Date$ @@ -373,7 +370,7 @@ * </tr> * <tr> * <td>urn:assembly:logging.manager</td> - * <td>[EMAIL PROTECTED] org.apache.assembly.logging.LoggingManager}</td> + * <td>[EMAIL PROTECTED] org.apache.avalon.assembly.logging.LoggingManager}</td> * <td>A logging manager.</td> * </tr> * </table> 1.1 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/AssemblyException.java Index: AssemblyException.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.engine; import org.apache.avalon.framework.CascadingException; /** * Exception to indicate that there was a assembly related error. * * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a> * @version $Revision: 1.1 $ $Date: 2002/12/14 21:04:40 $ */ public class AssemblyException extends CascadingException { /** * Construct a new <code>AssemblyException</code> instance. * * @param message The detail message for this exception. */ public AssemblyException( final String message ) { this( message, null ); } /** * Construct a new <code>AssemblyException</code> instance. * * @param message The detail message for this exception. * @param throwable the root cause of the exception */ public AssemblyException( final String message, final Throwable throwable ) { super( message, throwable ); } } 1.1 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/AssemblyService.java Index: AssemblyService.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.engine; 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/12/14 21:04:40 $ */ public interface AssemblyService { /** * Assemble the supplied appliance. * @param appliance the object to assembly */ void assemble( Appliance appliance ) throws AssemblyException; } 1.1 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/DefaultAssemblyService.java Index: DefaultAssemblyService.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.engine; import java.util.List; import java.util.ArrayList; import java.util.Map; import org.apache.avalon.framework.activity.Initializable; 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.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.appliance.DependencyGraph; import org.apache.avalon.meta.info.DependencyDescriptor; import org.apache.avalon.meta.info.StageDescriptor; /** * 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/12/14 21:04:40 $ */ class DefaultAssemblyService extends AbstractLogEnabled implements AssemblyService, Contextualizable, Serviceable, Initializable { //============================================================== // static //============================================================== private static final String ENGINE_KEY = "urn:assembly:engine.classloader"; //============================================================== // state //============================================================== private ServiceManager m_manager; private boolean m_initialized = false; private DependencyGraph m_map; private Engine m_engine; private ArrayList m_visited = new ArrayList(); //============================================================== // Contextualizable //============================================================== /** * <p>Application of a runtime context to this component. * 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>urn:assembly:dependency-map</td> * <td>org.apache.avalon.assembly.appliance.DepedendencyGraph</td> * <td>The depedency graph.</td> * </tr> * </table> * @param context the runtime context */ public void contextualize( Context context ) throws ContextException { m_map = (DependencyGraph) context.get( "urn:assembly:dependency-map" ); } //============================================================== // Serviceable //============================================================== /** * <p>Supply of container based services that may be used by the * assembly service as supplimentary resources.</p> * @param manager the service manager */ public void service( ServiceManager manager ) throws ServiceException { if( manager.hasService( ENGINE_KEY ) ) { m_manager = manager; } else { throw new ServiceException( ENGINE_KEY ); } } //============================================================== // Initializable //============================================================== /** * Initialization fo the component by the container. The implementation * validates a logger has been assigned and that the context phase has * been executed, following which it flags initialization as complete and * marks the component as ready to serve requests. * * @exception Exception if the manager has not been suppied with a context */ public void initialize() throws Exception { if( getLogger() == null ) { throw new IllegalStateException("logger"); } if( m_map == null ) { throw new IllegalStateException("contextaulize"); } if( m_manager == null ) { throw new IllegalStateException("service"); } m_initialized = true; } //============================================================== // AssemblyService //============================================================== /** * Assemble the supplied appliance. * @param appliance the object to assembly */ public void assemble( Appliance appliance ) throws AssemblyException { if( appliance == null ) { throw new NullPointerException( "appliance" ); } assembleAppliance( m_map, appliance, m_visited, "" ); } /** * Utility to get the engine from the service manager. This operation * should not be invoked before completion of initialization. * @return the engine * @exception IllegalStateException if invoked during or prior to * component initialization */ protected Engine getEngine() throws IllegalStateException { if( m_engine == null ) { if( !m_initialized ) { throw new IllegalStateException("initialization"); } try { m_engine = (Engine) m_manager.lookup( ENGINE_KEY ); } catch( ServiceException e ) { throw new IllegalStateException("engine"); } } return m_engine; } /** * Assemble a single appliance. * @param map the current depedency map to populate * @param profile the profile to assemble * @param context the assembly context * @param visited the set of profiles already assessed * @param pad used in formatting log messages * @exception AssemblyException if an assembly related error occurs */ private void assembleAppliance( DependencyGraph map, Appliance appliance, List visited, String pad ) throws AssemblyException { if( map == null ) { throw new NullPointerException( "map" ); } if( appliance == null ) { throw new NullPointerException( "appliance" ); } if( visited == null ) { throw new NullPointerException( "visited" ); } String name = appliance.getProfile().getName(); getLogger().debug( pad + "assemble: " + name ); String pad2 = pad + " "; // // for all of the declared dependencies - make sure the // dependency is satisfied // visited.add( appliance ); DependencyDescriptor[] dependencies = appliance.getProfile().getType().getDependencies(); for( int i = 0; i < dependencies.length; i++ ) { DependencyDescriptor dependency = dependencies[ i ]; String role = dependency.getRole(); if( appliance.getServiceProvider( role ) == null ) { getLogger().debug( "resolving role: " + role + " on " + name ); // // select the preferred provider for the dependency - the dependency // argument contains the selection policy to apply // Appliance supplier = null; try { supplier = getEngine().resolve( dependency ); } catch( Throwable e ) { final String error = "Unable to deploy a supplier for a service dependency: '" + supplier + "' within the appliance '" + appliance + "'."; throw new AssemblyException( error, e ); } if( supplier == null ) { final String message = "Unresolved supplied for the dependency: " + dependency.getReference() + " in appliance: " + appliance + ", for the role: " + dependency.getRole(); appliance.setEnabled( false ); final Exception problem = new Exception( message ); throw new UnresolvedProviderException( dependency, problem ); } // // associate the supplier to the appliance // appliance.addServiceProvider( role, supplier ); getLogger().debug( pad + " associated supplier: " + supplier.getProfile().getName() + " with appliance: " + name + " under the role: " + role ); map.add( supplier ); } } // // for all of the lifecycle phases - make sure we assign an extension // manager // StageDescriptor[] stages = appliance.getProfile().getType().getStages(); for( int i = 0; i < stages.length; i++ ) { StageDescriptor stage = stages[ i ]; if( appliance.getExtensionProvider( stage ) == null ) { Appliance supplier = null; try { supplier = getEngine().resolve( stage ); } catch( Throwable e ) { final String error = "Unable to resolve a supplier for a stage: '" + stage + "' within the appliance '" + appliance + "'."; throw new AssemblyException( error, e ); } if( supplier == null ) { final String message = "Unresolved supplied for the stage: " + stage + " in appliance: " + appliance; appliance.setEnabled( false ); final Exception problem = new Exception( message ); throw new UnresolvedManagerException( stage, problem ); } // // associate the supplier to the appliance // appliance.addExtensionProvider( stage, supplier ); getLogger().debug( pad + " associated extension provider: " + supplier.getProfile().getName() + " with appliance: " + appliance.getProfile().getName() ); map.add( supplier ); } } } private boolean assembleManagers( DependencyGraph map, Appliance appliance, StageDescriptor stage, List visited, String pad ) throws AssemblyException { boolean ok = false; Appliance provider; try { provider = getEngine().resolve( stage ); } catch( Throwable e ) { final String error = "Assembly error while resolving stage: " + stage + " for the appliance: " + appliance; throw new AssemblyException( error, e ); } if( provider != null ) { assembleAppliance( map, appliance, visited, pad + " " ); ok = true; } return ok; } private boolean assembleProviders( DependencyGraph map, Appliance appliance, DependencyDescriptor dependency, List visited, String pad ) throws AssemblyException { boolean ok = false; Appliance provider; try { provider = getEngine().resolve( dependency ); } catch( Throwable e ) { final String error = "Assembly error while resolving dependency: " + dependency + " for the appliance: " + appliance; throw new AssemblyException( error, e ); } if( provider != null ) { assembleAppliance( map, appliance, visited, pad + " " ); ok = true; } return ok; } } 1.1 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/UnresolvedManagerException.java Index: UnresolvedManagerException.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software * itself, if and wherever such third-party acknowledgments * normally appear. * * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.avalon.assembly.engine; import org.apache.avalon.meta.info.StageDescriptor; /** * Exception to indicate that a service provider could not be found. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a> * @version $Revision: 1.1 $ $Date: 2002/12/14 21:04:40 $ */ public final class UnresolvedManagerException extends AssemblyException { private StageDescriptor m_phase; /** * Construct a new <code>UnresolvedManagerException</code> instance. * * @param phase the unresolved phase */ public UnresolvedManagerException( StageDescriptor phase ) { this( phase, null ); } /** * Construct a new <code>UnresolvedManagerException</code> instance. * * @param phase the unresolved phase * @param cause the causal exception */ public UnresolvedManagerException( StageDescriptor phase, Throwable cause ) { super( getStandardMessage( phase ), cause ); m_phase = phase; } /** * Return the dependency description. * @return the unresolved dependency. */ public StageDescriptor getPhase() { return m_phase; } private static String getStandardMessage( StageDescriptor phase ) { return "Unable to resolve an extensions for the phase '" + phase.getReference(); } } 1.1 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/UnresolvedProviderException.java Index: UnresolvedProviderException.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software * itself, if and wherever such third-party acknowledgments * normally appear. * * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.avalon.assembly.engine; import org.apache.avalon.meta.info.DependencyDescriptor; /** * Exception to indicate that a service provider could not be found. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a> * @version $Revision: 1.1 $ $Date: 2002/12/14 21:04:40 $ */ public final class UnresolvedProviderException extends AssemblyException { private DependencyDescriptor m_dependency; /** * Construct a new <code>UnresolvedProviderException</code> instance. * * @param dependency the unresolved dependency */ public UnresolvedProviderException( DependencyDescriptor dependency ) { this( dependency, null ); } /** * Construct a new <code>UnresolvedProviderException</code> instance. * * @param dependency the unresolved dependency * @param cause the causal exception */ public UnresolvedProviderException( DependencyDescriptor dependency, Throwable cause ) { super( getStandardMessage( dependency ), cause ); m_dependency = dependency; } /** * Return the dependency description. * @return the unresolved dependency. */ public DependencyDescriptor getDependency() { return m_dependency; } private static String getStandardMessage( DependencyDescriptor dependency ) { return "Unable to resolve a provider for the dependency '" + dependency.getReference() + "' for the role: " + dependency.getRole(); } } 1.4 +4 -4 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.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ContextHandler.java 7 Dec 2002 09:34:28 -0000 1.3 +++ ContextHandler.java 14 Dec 2002 21:04:41 -0000 1.4 @@ -124,9 +124,9 @@ * <td>key</td><td>type</td><td>description</td> * </tr> * <tr> - * <td>urn:assembly:lifecycle.logging</td> - * <td>[EMAIL PROTECTED] org.apache.avalon.assembly.logging.LoggingService}</td> - * <td>The logging service to use for the creation of auxiliary logging channels.</td> + * <td>urn:assembly:engine.classloader</td> + * <td>[EMAIL PROTECTED] org.apache.avalon.assembly.engine.EngineClassLoader}</td> + * <td>The service management engine.</td> * </tr> * </table> * @param context the runtime context 1.5 +2 -2 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/DefaultDeploymentService.java Index: DefaultDeploymentService.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/DefaultDeploymentService.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- DefaultDeploymentService.java 7 Dec 2002 09:34:28 -0000 1.4 +++ DefaultDeploymentService.java 14 Dec 2002 21:04:41 -0000 1.5 @@ -163,7 +163,7 @@ * </tr> * <tr> * <td>urn:assembly:lifecycle.logging</td> - * <td>[EMAIL PROTECTED] org.apache.avalon.assembly.logging.LoggingService}</td> + * <td>[EMAIL PROTECTED] org.apache.avalon.assembly.lifecycle.logging.LoggingService}</td> * <td>The logging service to use for the creation of auxiliary logging channels.</td> * </tr> * </table> 1.8 +3 -2 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/AbstractLifestyleHandler.java Index: AbstractLifestyleHandler.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/AbstractLifestyleHandler.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- AbstractLifestyleHandler.java 7 Dec 2002 09:34:28 -0000 1.7 +++ AbstractLifestyleHandler.java 14 Dec 2002 21:04:41 -0000 1.8 @@ -129,7 +129,7 @@ * </tr> * <tr> * <td>urn:assembly:appliance.target</td> - * <td>[EMAIL PROTECTED] org.apache.avalon.appliance.Appliance}</td> + * <td>[EMAIL PROTECTED] org.apache.avalon.assembly.appliance.Appliance}</td> * <td>The appliance that this manager is managing.</td> * </tr> * </table> @@ -224,6 +224,7 @@ * @param object the service to be released */ public abstract void release( Object object ); + //============================================================== // Disposable 1.3 +2 -1 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleHandler.java Index: LifestyleHandler.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleHandler.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- LifestyleHandler.java 12 Dec 2002 00:32:32 -0000 1.2 +++ LifestyleHandler.java 14 Dec 2002 21:04:41 -0000 1.3 @@ -84,4 +84,5 @@ * @param object the service to be released */ void release( Object object ); + } 1.6 +14 -28 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.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- SingletonLifestyleHandler.java 12 Dec 2002 00:32:32 -0000 1.5 +++ SingletonLifestyleHandler.java 14 Dec 2002 21:04:41 -0000 1.6 @@ -124,34 +124,9 @@ */ public void release( Object object ) { - if( m_instance == null ) - { - final String error = - "Singleton instance has not been established for appliance: " - + getAppliance().getProfile().getName(); - throw new IllegalStateException( error ); - } - if( object == null ) - { - return; - } - if( object.equals( m_instance ) ) - { - super.processReleaseStage( m_instance ); - } - else - { - final String warning = - "Illegal attempt to release an object [" - + object.getClass() - + "] that does not correspond to the singleton: ]" - + m_instance.getClass() - + "] in appliance: " - + getAppliance(); - getLogger().warn( warning ); - } } + //============================================================== // Disposable //============================================================== @@ -161,7 +136,18 @@ */ public void dispose() { - m_instance = null; + if( m_instance != null ) + { + if( getLogger().isDebugEnabled() ) + { + final String debug = + "release in appliance: " + + getAppliance().getProfile().getName(); + getLogger().debug( debug ); + } + super.processReleaseStage( m_instance ); + m_instance = null; + } super.dispose(); } 1.4 +23 -4 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/TransientLifestyleHandler.java Index: TransientLifestyleHandler.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/TransientLifestyleHandler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TransientLifestyleHandler.java 12 Dec 2002 00:32:32 -0000 1.3 +++ TransientLifestyleHandler.java 14 Dec 2002 21:04:41 -0000 1.4 @@ -50,6 +50,10 @@ package org.apache.avalon.assembly.lifestyle; +import java.util.List; +import java.util.ArrayList; +import java.util.Iterator; + import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.context.ContextException; @@ -74,9 +78,9 @@ //============================================================== /** - * The singleton instance. + * The set of transient objects created by the handler. */ - private Object m_instance; + private List m_instances = new ArrayList(); //============================================================== // LifestyleHandler @@ -107,6 +111,10 @@ public Object access() throws LifestyleException { Object object = newInstance(); + synchronized( m_instances ) + { + m_instances.add( object ); + } super.processAccessStage( object ); return object; } @@ -118,6 +126,10 @@ public void release( Object object ) { super.processReleaseStage( object ); + synchronized( m_instances ) + { + m_instances.remove( object ); + } } //============================================================== @@ -129,7 +141,14 @@ */ public void dispose() { - m_instance = null; + synchronized( m_instances ) + { + Iterator iterator = m_instances.iterator(); + while( iterator.hasNext() ) + { + release( iterator.next() ); + } + } super.dispose(); } 1.2 +1 -1 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/logging/package.html Index: package.html =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/logging/package.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- package.html 29 Nov 2002 13:22:20 -0000 1.1 +++ package.html 14 Dec 2002 21:04:41 -0000 1.2 @@ -1,6 +1,6 @@ <body> <p> -The <code>logging</code> package contains the [EMAIL PROTECTED] org.apache.avalon.assembly.logging.DefaultLoggerManager} which is an initial bootstrap logging mananager that uses mata inforatrion about logging targets and catagories. Rhis class is subject to refactoring to bring in into a component model to enable easy specialization and/or replacement. +The <code>logging</code> package contains the [EMAIL PROTECTED] org.apache.avalon.assembly.logging.DefaultLoggingManager} which is an initial bootstrap logging mananager that uses mata information about logging targets and catagories. This class is subject to refactoring to bring in into a component model to enable easy specialization and/or replacement. </p> </body> 1.2 +1 -1 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/service/package.html Index: package.html =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/service/package.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- package.html 24 Nov 2002 12:50:45 -0000 1.1 +++ package.html 14 Dec 2002 21:04:41 -0000 1.2 @@ -1,6 +1,6 @@ <body> <p> -The <code>type</code> package contains classes and interfaces for the [EMAIL PROTECTED] org.apache.avalon.assembly.type.TypeManager} and related default implementations supporting the management of a repository of component types. +The <code>service</code> package contains classes and interfaces for the [EMAIL PROTECTED] org.apache.avalon.assembly.service.ServiceManager} and related default implementations supporting the management of a repository of service defintions. </p> </body>
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>