You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2003/04/13 04:40:03 UTC
cvs commit: avalon-sandbox/merlin/merlin-spi/src/java/org/apache/avalon/merlin/container ContainmentProfile.java ContainerDescriptor.java
mcconnell 2003/04/12 19:40:03
Added: merlin/merlin-spi/src/java/org/apache/avalon/merlin/container
ContainmentProfile.java
Removed: merlin/merlin-spi/src/java/org/apache/avalon/merlin/container
ContainerDescriptor.java
Log:
Renamed ContainerDescriptor to ContainmentProfile to be consitent with teminology and properly reflect the fact this is a profile.
Revision Changes Path
1.1 avalon-sandbox/merlin/merlin-spi/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
* <http://www.apache.org/>.
*/
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.model.LoggingDirective;
import org.apache.avalon.meta.model.ContextDirective;
import org.apache.avalon.meta.model.Mode;
import org.apache.avalon.meta.model.Profile;
/**
* <p>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.</p>
*
* <p><b>XML</b><p>
* A single container element is required within a kernel defintion. Multiple
* container declarations may appear within an enclosing container.
* <pre>
* <font color="gray"><i><!--
* 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.
* --></i></font>
*
* <container name="<font color="darkred">root</font>">
*
* <font color="gray"><i><!--
* 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.
* --></i></font>
*
* <classpath>
* <fileset dir="<font color="darkred">dist</font>">
* <include name="<font color="darkred">demo.jar</font>"/>
* <include name="<font color="darkred">new-application-1.0.jar</font>"/>
* </fileset>
* </classpath>
*
* <font color="gray"><i><!--
* 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.
* --></i></font>
*
* <categories priority="<font color="darkred">INFO</font>">
* <category name="<font color="darkred">profiles</font>" />
* <category name="<font color="darkred">lifecycle</font>" />
* <category name="<font color="darkred">verifier</font>" />
* </categories>
*
* <font color="gray"><i><!--
* 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.
* --></i></font>
*
* <component name="<font color="darkred">my-component</font>"
* class="<font color="darkred">org.apache.excalibur.playground.SimpleComponent</font>" />
*
* <font color="gray"><i><!--
* Multiple subsidiary container declarations.
* --></i></font>
*
* <container name="<font color="darkred">child</font>">
* <component name="<font color="darkred">demo-component</font>" class="<font color="darkred">org.apache.excalibur.playground.BasicComponent</font>" />
* <container>
*
* </container>
* </pre>
*
* @see org.apache.avalon.meta.model.Profile
*
* @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
* @version $Revision: 1.1 $ $Date: 2003/04/13 02:40:03 $
*/
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();
//========================================================================
// constructors
//========================================================================
/**
* Create a ContainmentProfile instance.
*
* @param name the abstract name of component meta data instance
* @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)
*/
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
);
}
//========================================================================
// implementation
//========================================================================
/**
* Add a component profile to this container.
*
* @param component the component profile to add to the container
*/
public void addComponent( Profile component )
{
if( !m_components.contains( component ) )
{
m_components.add( component );
}
}
/**
* Return the set of component descriptors contained within this container.
*
* @return the target descriptors
*/
public Profile[] getComponents()
{
return (Profile[])m_components.toArray( new Profile[ 0 ] );
}
/**
* Return the set of component descriptors contained within this container matching
* the supplied mode.
*
* @param mode one of enumerated value {@link Mode#IMPLICIT}, {@link Mode#PACKAGED},
* or {@link Mode#EXPLICIT}
* @param enabled TRUE to select enabled components, FALSE returns disabled components
* @return the profiles matching the supplied creation mode
*/
public Profile[] getComponents( Mode mode )
{
ArrayList list = new ArrayList();
Profile[] components = getComponents( );
return selectComponentsByMode( components, mode );
}
/**
* Returns a sub-set of the supplied containers matching the supplied creation mode.
* @param components the compoennts to select from
* @param mode the creation mode to retrict the returned selection to
* @param the subset of the supplied components with a creation mode matching
* the supplied mode value
*/
private Profile[] selectComponentsByMode( Profile[] components, Mode mode )
{
ArrayList list = new ArrayList();
for( int i = 0; i < components.length; i++ )
{
Profile component = components[ i ];
if( component.getMode().equals( mode ) )
{
list.add( component );
}
}
return (Profile[])list.toArray( new Profile[ 0 ] );
}
/**
* Add a container profile to this container.
*
* @param container the container profile to add to the container
*/
public void addContainer( ContainmentProfile container )
{
if( !m_containers.contains( container ) )
{
m_containers.add( container );
}
}
/**
* Return the set of container descriptors contained within this container.
*
* @return the container descriptors
*/
public ContainmentProfile[] getContainers()
{
return (ContainmentProfile[])m_containers.toArray( new ContainmentProfile[ 0 ] );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org