CVS: jcontainer/loom/engine/src/java/org/jcontainer/loom/components/util/metadata ComponentTemplate.java,NONE,1.1 DependencyDirective.java,NONE,1.1 PartitionTemplate.java,NONE,1.1 MetaDataBuilder.java,1.1,1.2 ComponentMetaData.java,1.1,NONE DependencyMetaData.java,1.1,NONE PartitionMetaData.java,1.1,NONE

Peter Donald <pdonald-yCVjj/[email protected]> Mon, 3 Nov 2003 00:43:19 -0600
Newsgroups gmane.comp.java.jcontainer.cvs
Message-ID <[email protected]>
Update of /cvsroot/jcontainer/jcontainer/loom/engine/src/java/org/jcontainer/loom/components/util/metadata
In directory hogshead.codehaus.org:/tmp/cvs-serv22178/engine/src/java/org/jcontainer/loom/components/util/metadata

Modified Files:
	MetaDataBuilder.java 
Added Files:
	ComponentTemplate.java DependencyDirective.java 
	PartitionTemplate.java 
Removed Files:
	ComponentMetaData.java DependencyMetaData.java 
	PartitionMetaData.java 
Log Message:
Rename the MetaData away from standard MetaData postfix to use more readily accesisble names


--- NEW FILE: ComponentTemplate.java ---
/*
 * Copyright (C) The JContainer Group. All rights reserved.
 *
 * This software is published under the terms of the JContainer
 * Software License version 1.1, a copy of which has been included
 * with this distribution in the LICENSE.txt file.
 */
package org.jcontainer.loom.components.util.metadata;

import java.util.ArrayList;
import java.util.List;
import org.apache.avalon.framework.parameters.Parameters;
import org.jcontainer.dna.Configuration;

/**
 * Each component declared in the application is represented by
 * a ComponentTemplate. Note that this does not necessarily imply
 * that there is only one instance of actual component. The
 * ComponentTemplate could represent a pool of components, a single
 * component or a component prototype that is reused to create
 * new components as needed.
 *
 * @author <a href="mailto:peter at realityforge.org">Peter Donald</a>
 * @version $Revision: 1.1 $ $Date: 2003/11/03 06:43:15 $
 */
public class ComponentTemplate
{
    /**
     * Empty set of component metadata.
     */
    public static final ComponentTemplate[] EMPTY_SET = new ComponentTemplate[ 0 ];

    /**
     * The name of the component. This is an
     * abstract name used during assembly.
     */
    private final String m_name;

    /**
     * The implementationKey for this component.
     * Usually this represents a classname but
     * alternative mechanisms could be used (ie URL
     * of webservice).
     */
    private final String m_implementationKey;

    /**
     * The resolution of any dependencies required by
     * the component type.
     */
    private final DependencyDirective[] m_dependencies;

    /**
     * The parameters for component (if any).
     */
    private final Parameters m_parameters;

    /**
     * The configuration for component (if any).
     */
    private final Configuration m_configuration;

    /**
     * True if proxy should be disabled.
     */
    private final boolean m_disableProxy;

    /**
     * Create a ComponentTemplate.
     *
     * @param name the abstract name of component meta data instance
     * @param implementationKey the key used to create component (usually a classname)
     * @param dependencies the meta data for any dependencies
     * @param parameters the parameters that the component will be provided (may be null)
     * @param configuration the configuration that the component will be provided (may be null)
     * @param disableProxy true if proxy should be disabled
     */
    public ComponentTemplate( final String name,
                              final String implementationKey,
                              final DependencyDirective[] dependencies,
                              final Parameters parameters,
                              final Configuration configuration,
                              final boolean disableProxy )
    {
        if( null == name )
        {
            throw new NullPointerException( "name" );
        }
        if( null == dependencies )
        {
            throw new NullPointerException( "dependencies" );
        }
        if( null == implementationKey )
        {
            throw new NullPointerException( "implementationKey" );
        }

        m_name = name;
        m_dependencies = dependencies;
        m_parameters = parameters;
        m_configuration = configuration;
        m_implementationKey = implementationKey;
        m_disableProxy = disableProxy;
    }

    /**
     * Return true if proxy should not be created for object.
     *
     * @return true if proxy should not be created for object.
     */
    public boolean isDisableProxy()
    {
        return m_disableProxy;
    }

    /**
     * Return the name of component metadata.
     *
     * @return the name of the component metadata.
     */
    public String getName()
    {
        return m_name;
    }

    /**
     * Return the implementationKey for component.
     *
     * @return the implementationKey for component.
     */
    public String getImplementationKey()
    {
        return m_implementationKey;
    }

    /**
     * Return the dependency for component.
     *
     * @return the dependency for component.
     */
    public DependencyDirective[] getDependencies()
    {
        return m_dependencies;
    }

    /**
     * Return the Parameters for Component (if any).
     *
     * @return the Parameters for Component (if any).
     */
    public Parameters getParameters()
    {
        return m_parameters;
    }

    /**
     * Return the Configuration for Component (if any).
     *
     * @return the Configuration for Component (if any).
     */
    public Configuration getConfiguration()
    {
        return m_configuration;
    }

    /**
     * Return the dependency for component with specified key.
     *
     * @return the dependency for component with specified key.
     */
    public DependencyDirective getDependency( final String key )
    {
        for( int i = 0; i < m_dependencies.length; i++ )
        {
            if( m_dependencies[ i ].getKey().equals( key ) )
            {
                return m_dependencies[ i ];
            }
        }

        return null;
    }

    /**
     * Return all the dependencies for key. Used for Map and array dependencies.
     *
     * @return all the dependencies for key
     */
    public DependencyDirective[] getDependencies( final String key )
    {
        final List result = new ArrayList();

        for( int i = 0; i < m_dependencies.length; i++ )
        {
            final DependencyDirective dependency = m_dependencies[ i ];
            if( dependency.getKey().equals( key ) )
            {
                result.add( dependency );
            }
        }

        return (DependencyDirective[])result.
            toArray( new DependencyDirective[ result.size() ] );
    }
}

--- NEW FILE: DependencyDirective.java ---
/* ====================================================================
 * JContainer Software License, version 1.1
 *
 * Copyright (c) 2003, JContainer Group. 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. Neither the name of the JContainer Group nor the name "Loom" nor
 *    the names of its contributors may be used to endorse or promote
 *    products derived from this software without specific prior
 *    written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS 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
 * COPYRIGHT OWNER OR 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.
 *
 * ====================================================================
 *
 * JContainer Loom includes code from the Apache Software Foundation
 *
 * ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1997-2003 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.
 */
package org.jcontainer.loom.components.util.metadata;

/**
 * The DependencyDirective is the mapping of a component as a dependency
 * of another component. Each component declares dependencies (via
 * ComponentInfo) and for each dependency there must be a coressponding
 * DependencyDirective which has a matching key. The name value in
 * DependencyDirective object must refer to another Component that implements
 * a service as specified in DependencyInfo.
 *
 * <p>Note that it is invalid to have circular dependencies.</p>
 *
 * @author <a href="mailto:peter at realityforge.org">Peter Donald</a>
 * @version $Revision: 1.1 $ $Date: 2003/11/03 06:43:15 $
 */
public final class DependencyDirective
{
    /**
     * Empty set of dependencys.
     */
    public static final DependencyDirective[] EMPTY_SET = new DependencyDirective[ 0 ];

    /**
     * The key that the client component will use to access a dependency.
     */
    private final String m_key;

    /**
     * the name of the component profile that represents a component
     * type that is capable of fullfilling the dependency.
     */
    private final String m_providerName;

    /**
     * The key that is used when the dependency is a map dependency.
     * Usually this defaults to the same value as the key.
     */
    private final String m_alias;

    /**
     * Create Association between key and provider.
     *
     * @param key the key the client uses to access component
     * @param providerName the name of ComponentTemplate
     *   that is associated as a service provider
     */
    public DependencyDirective( final String key,
                               final String providerName,
                               final String alias )
    {
        if( null == key )
        {
            throw new NullPointerException( "key" );
        }
        if( null == providerName )
        {
            throw new NullPointerException( "providerName" );
        }
        if( null == alias )
        {
            throw new NullPointerException( "alias" );
        }
        m_key = key;
        m_providerName = providerName;
        m_alias = alias;
    }

    /**
     * Return the key that will be used by a component instance to access a
     * dependent service.
     *
     * @return the name that the client component will use to access dependency.
     * @see org.apache.avalon.framework.service.ServiceManager#lookup( java.lang.String )
     */
    public String getKey()
    {
        return m_key;
    }

    /**
     * Return the name of a ComponentTemplate instance that will used to
     * fulfill the dependency.
     *
     * @return the name of the Component that will provide the dependency.
     */
    public String getProviderName()
    {
        return m_providerName;
    }

    /**
     * The key under which the dependency is placed in map if dependency is
     * a Map dependency.
     *
     * @return the key under which the dependency is placed in map if dependency is
     *         a Map dependency.
     */
    public String getAlias()
    {
        return m_alias;
    }
}

--- NEW FILE: PartitionTemplate.java ---
/*
 * Copyright (C) The JContainer Group. All rights reserved.
 *
 * This software is published under the terms of the JContainer
 * Software License version 1.1, a copy of which has been included
 * with this distribution in the LICENSE.txt file.
 */
package org.jcontainer.loom.components.util.metadata;



/**
 * In each Assembly there may be groups of components that
 * are activated together and treated as a group. These
 * components are all "visible" to each other as peers.
 * The group will have a name and may use resources from
 * other partitions. Partitions can also be nested one inside
 * each other.
 *
 * @author <a href="mailto:peter at realityforge.org">Peter Donald</a>
 * @version $Revision: 1.1 $ $Date: 2003/11/03 06:43:15 $
 */
public class PartitionTemplate
{
    /**
     * Constant for an empty set of partitions.
     */
    public static final PartitionTemplate[] EMPTY_SET = new PartitionTemplate[ 0 ];

    /**
     * The name of the partition. This is an
     * abstract name used during assembly.
     */
    private final String m_name;

    /**
     * An array listing the set of other partitions required by
     * this partition. The required partitions must be initialized
     * and in ready state prior to this partition starting and this
     * partition must be shutdown prior
     */
    private final String[] m_depends;

    /**
     * AN array of partitions that are contained by this
     * object.
     */
    private final PartitionTemplate[] m_partitions;

    /**
     * AN array of components that are contained by this
     * object.
     */
    private final ComponentTemplate[] m_components;

    /**
     * Create a PartitionTemplate.
     *
     * @param name the abstract name of component meta data instance
     * @param depends the partitions depended upon by this parition
     * @param partitions the partitions contained by this partition
     * @param components the components contained by this partition
     */
    public PartitionTemplate( final String name,
                              final String[] depends,
                              final PartitionTemplate[] partitions,
                              final ComponentTemplate[] components )
    {
        if( null == name )
        {
            throw new NullPointerException( "name" );
        }
        if( null == depends )
        {
            throw new NullPointerException( "depends" );
        }
        if( null == partitions )
        {
            throw new NullPointerException( "partitions" );
        }
        if( null == components )
        {
            throw new NullPointerException( "components" );
        }

        m_name = name;
        m_depends = depends;
        m_partitions = partitions;
        m_components = components;
    }

    /**
     * Return the name of component profile.
     *
     * @return the name of the component profile.
     */
    public String getName()
    {
        return m_name;
    }

    /**
     * Return the set of prereqs for this partition.
     *
     * @return the set of prereqs for this partition.
     */
    public String[] getDepends()
    {
        return m_depends;
    }

    /**
     * Return the set of partitions contained in this partition.
     *
     * @return the set of partitions contained in this partition.
     */
    public PartitionTemplate[] getPartitions()
    {
        return m_partitions;
    }

    /**
     * Return the set of components contained in this partition.
     *
     * @return the set of components contained in this partition.
     */
    public ComponentTemplate[] getComponents()
    {
        return m_components;
    }

    /**
     * Return the partition with specified name.
     *
     * @return the partition with specified name.
     */
    public PartitionTemplate getPartition( final String name )
    {
        for( int i = 0; i < m_partitions.length; i++ )
        {
            final PartitionTemplate partition = m_partitions[ i ];
            if( partition.getName().equals( name ) )
            {
                return partition;
            }
        }

        throw new IllegalArgumentException( "Missing partition named " + name );
    }

    /**
     * Return the component with specified name.
     *
     * @return the component with specified name.
     */
    public ComponentTemplate getComponent( final String name )
    {
        for( int i = 0; i < m_components.length; i++ )
        {
            final ComponentTemplate component = m_components[ i ];
            if( component.getName().equals( name ) )
            {
                return component;
            }
        }
        return null;
    }
}

Index: MetaDataBuilder.java
===================================================================
RCS file: /cvsroot/jcontainer/jcontainer/loom/engine/src/java/org/jcontainer/loom/components/util/metadata/MetaDataBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- MetaDataBuilder.java	16 Oct 2003 14:45:46 -0000	1.1
+++ MetaDataBuilder.java	3 Nov 2003 06:43:15 -0000	1.2
@@ -28,6 +28,6 @@
      * @throws java.lang.Exception if unable to load or resolve
      *         meta data for any reason
      */
-    PartitionMetaData buildAssembly( Map parameters )
+    PartitionTemplate buildAssembly( Map parameters )
         throws Exception;
 }

--- ComponentMetaData.java DELETED ---

--- DependencyMetaData.java DELETED ---

--- PartitionMetaData.java DELETED ---