Return-Path: Delivered-To: apmail-avalon-cvs-archive@avalon.apache.org Received: (qmail 88194 invoked by uid 500); 20 Apr 2003 12:19:53 -0000 Mailing-List: contact cvs-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list cvs@avalon.apache.org Received: (qmail 88183 invoked by uid 500); 20 Apr 2003 12:19:53 -0000 Received: (qmail 88180 invoked from network); 20 Apr 2003 12:19:53 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 20 Apr 2003 12:19:53 -0000 Received: (qmail 2732 invoked by uid 1438); 20 Apr 2003 12:19:52 -0000 Date: 20 Apr 2003 12:19:52 -0000 Message-ID: <20030420121952.2731.qmail@icarus.apache.org> From: mcconnell@apache.org To: avalon-sandbox-cvs@apache.org Subject: cvs commit: avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/container Targets.java Target.java ContainmentProfile.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N mcconnell 2003/04/20 05:19:52 Added: merlin/merlin-core/src/java/org/apache/avalon/merlin/container Targets.java Target.java ContainmentProfile.java Log: Seperated out functionality dealing with configuration fragments. Revision Changes Path 1.1 avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/container/Targets.java Index: Targets.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software * itself, if and wherever such third-party acknowledgments * normally appear. * * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.apache.avalon.merlin.container; import java.util.ArrayList; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.meta.info.Type; import org.apache.avalon.meta.info.DependencyDescriptor; import org.apache.avalon.meta.info.ServiceDescriptor; import org.apache.avalon.meta.model.ContextDirective; import org.apache.avalon.meta.model.LoggingDirective; import org.apache.avalon.meta.model.Mode; import org.apache.avalon.meta.model.Profile; /** *

A target is a tagged configuration fragment. The tag is a path * seperated by "/" charaters qualifying the component that the target * configuration is to be applied to.

* * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2003/04/20 12:19:52 $ */ public class Targets { //======================================================================== // state //======================================================================== /** * The parent. */ private final Targets m_parent; /** * The set of targets. */ private final Target[] m_targets; //======================================================================== // constructors //======================================================================== /** * Create a new Targets instance. * * @param targets the set of targets */ public Targets( final Target[] targets ) { this( null, targets ); } /** * Create a new Targets instance. * * @param targets the set of targets */ public Targets( final Targets parent, final Target[] targets ) { m_targets = targets; m_parent = parent; } //======================================================================== // implementation //======================================================================== /** * Return all targets. * * @return all the targets in this targets instance. */ protected Target[] getTargets() { return m_targets; } /** * Return a matching target. * * @return the target or null if no matching target */ public Target getTarget( String path ) { final String key = getKey( path ); if( m_parent != null ) { Target t = m_parent.getTarget( key ); if( t.getConfiguration() != null ) { return t; } } for( int i=0; i 0 ) { if( target.getConfiguration() != null ) { Target t = new Target( getKey( name ), target.getConfiguration() ); list.add( t ); } } } } Target[] result = (Target[]) list.toArray( new Target[0] ); if( m_parent != null ) { return new Targets( m_parent.getTargets( key ), result ); } return new Targets( result ); } /** * Convert the supplied path to a valid path. * @param path the path to convert * @return a good path value */ private String getKey( final String path ) throws IllegalArgumentException { if( !path.startsWith("/") ) { return "/" + path; } return path; } /** * Return a string representation of the target. * @return a string representing the target instance */ public String toString() { StringBuffer buffer = new StringBuffer( "[targets: " ); if( m_parent != null ) { buffer.append( m_parent.toString() ); } for( int i=0; i. */ package org.apache.avalon.merlin.container; import java.util.ArrayList; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.meta.info.Type; import org.apache.avalon.meta.info.DependencyDescriptor; import org.apache.avalon.meta.info.ServiceDescriptor; import org.apache.avalon.meta.model.ContextDirective; import org.apache.avalon.meta.model.LoggingDirective; import org.apache.avalon.meta.model.Mode; import org.apache.avalon.meta.model.Profile; import org.apache.excalibur.configuration.ConfigurationUtil; /** *

A target is a tagged configuration fragment. The tag is a path * seperated by "/" charaters qualifying the component that the target * configuration is to be applied to.

* * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2003/04/20 12:19:52 $ */ public class Target { //======================================================================== // state //======================================================================== /** * The path. */ private final String m_path; /** * The configuration. */ private final Configuration m_config; //======================================================================== // constructors //======================================================================== /** * Create a new Target instance. * * @param path target path * @param configuration the configuration */ public Target( final String path, final Configuration configuration ) { if( !path.startsWith("/") ) { final String error = "Supplied target path '" + path + "' does not commence with the path delimiter '/'."; throw new IllegalArgumentException( error ); } m_path = path; m_config = configuration; } //======================================================================== // implementation //======================================================================== /** * Return the target path. * * @return the target path */ public String getPath() { return m_path; } /** * Return the target configuration. * * @return the target path */ public Configuration getConfiguration() { return m_config; } /** * Return a string representation of the target. * @return a string representing the target instance */ public String toString() { return "[target: " + getPath() + ", " + (getConfiguration() != null ) + " ]"; } } 1.1 avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/container/ContainmentProfile.java Index: ContainmentProfile.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software * itself, if and wherever such third-party acknowledgments * normally appear. * * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.apache.avalon.merlin.container; import java.util.ArrayList; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.meta.info.Type; import org.apache.avalon.meta.info.DependencyDescriptor; import org.apache.avalon.meta.info.ServiceDescriptor; import org.apache.avalon.meta.model.ContextDirective; import org.apache.avalon.meta.model.LoggingDirective; import org.apache.avalon.meta.model.Mode; import org.apache.avalon.meta.model.Profile; import org.apache.avalon.assembly.engine.EngineClassLoader; /** *

A container descriptor is a description of the crieria supporting the * construction of a container. It may may include multiple * component profile declarations, and multiple nested container declarations.

* *

XML

* A single container element is required within a kernel defintion. Multiple * container declarations may appear within an enclosing container. *

   *    <!--
   *    Definition of a container.  The name attribute declares bother the container
   *    name and the base logging category that will be supplied to the container
   *    by its parent.  Logging category defintions declared within the container
   *    declaration are relative to the container name.
   *    -->
   *
   *    <container name="root">
   *
   *      <engine>
   *
   *        <!--
   *        Classpath declaration.  Classes accessible to a component are constrained
   *        to the classes available in the jar files declared within the immediate
   *        classpath, together with and resources declared in any parent container.
   *        -->
   *
   *        <classpath>
   *          <fileset dir="dist">
   *            <include name="demo.jar"/>
   *            <include name="new-application-1.0.jar"/>
   *          </fileset>
   *        </classpath>
   *
   *      </engine>
   *
   *      <!--
   *      Logging categories declaration.  Logging categories are relative to the name of the
   *      enaclosing container. Logging priorities and targets will default to the parent
   *      containtains values if undefined.
   *      -->
   *
   *      <categories priority="INFO">
   *        <category name="profiles" />
   *        <category name="lifecycle" />
   *        <category name="verifier" />
   *      </categories>
   *
   *      <!--
   *      Multiple component profile declarations.  If a component declares dependecies,
   *      the container will attempt to resolve the dependency locally relative to any
   *      other declared components, otherwise, the container will attempt to resolve
   *      the dependecy using services established (explicitly or implicitly) in the
   *      parent containers before attempting a local implicit solution.
   *      -->
   *
   *      <component name="my-component"
   *         class="org.apache.excalibur.playground.SimpleComponent" />
   *
   *      <!--
   *      Multiple subsidiary container declarations.
   *      -->
   *
   *      <container name="child">
   *        <component name="demo-component" class="org.apache.excalibur.playground.BasicComponent" />
   *      <container>
   *
   *    </container>
   * 
* * @see org.apache.avalon.meta.model.Profile * * @author Avalon Development Team * @version $Revision: 1.1 $ $Date: 2003/04/20 12:19:52 $ */ public class ContainmentProfile extends Profile { //======================================================================== // static //======================================================================== /** * Container path delimiter. */ public static final String DELIMITER = "/"; //======================================================================== // state //======================================================================== /** * The component described within the scope of the container. */ private final ArrayList m_components = new ArrayList(); /** * The containers described within the scope of the container. */ private final ArrayList m_containers = new ArrayList(); /** * Virtual services. */ private ServiceDescriptor[] m_services; /** * Virtual dependencies. */ private DependencyDescriptor[] m_dependencies; /** * Assigned classloader. */ private EngineClassLoader m_engine; //======================================================================== // constructors //======================================================================== /** * Create a ContainmentProfile instance. * * @param name the abstract name of profile * @param parameters the parameters instance to use during type instantiation * @param configuration the configuration instance to use during type instantiation * @param context the context instance to use during type instantiation * @param categories the logging categories descriptor * @param type the type of component that this profile qualifies * @param mode the creation mode (either IMPLICIT, PACKAGED, or EXPLICIT) * @param services virtual services exposed by the container * @param dependencies virtual dependencies * @param engine assigned classloader * @param components embedded component profiles * @param containers embedded containers profiles */ public ContainmentProfile( final String name, final Parameters parameters, final Configuration configuration, final ContextDirective context, final LoggingDirective categories, final Type type, final Mode mode ) { super( name, parameters, configuration, context, categories, type, mode ); /* m_services = services; m_dependencies = dependencies; m_engine = engine; for( int i=0; i