avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/dependency DependencyMap.java
Date Sun, 23 Jun 2002 06:57:19 GMT
donaldp     2002/06/22 23:57:19

  Modified:    containerkit/src/java/org/apache/excalibur/containerkit/dependency
                        DependencyMap.java
  Log:
  If looking for consumers of service then walk child dependencyMaps aswell.
  
  Revision  Changes    Path
  1.3       +39 -30    jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/dependency/DependencyMap.java
  
  Index: DependencyMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/dependency/DependencyMap.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DependencyMap.java	23 Jun 2002 06:49:15 -0000	1.2
  +++ DependencyMap.java	23 Jun 2002 06:57:19 -0000	1.3
  @@ -29,6 +29,12 @@
       private final DependencyMap m_parent;
   
       /**
  +     * The child {@link DependencyMap} objects.
  +     * Possible consumers of services in this assembly.
  +     */
  +    private final ArrayList m_children = new ArrayList();
  +
  +    /**
        * The set of components in assembly.
        * Used when searching for providers/consumers.
        */
  @@ -44,19 +50,16 @@
           m_parent = parent;
       }
   
  +    /**
  +     * Add a component to current dependency graph.
  +     *
  +     * @param component the component
  +     */
       public void add( final ComponentMetaData component )
       {
           m_components.add( component );
       }
   
  -    public void addAll( final ComponentMetaData[] components )
  -    {
  -        for( int i = 0; i < components.length; i++ )
  -        {
  -            m_components.add( components[ i ] );
  -        }
  -    }
  -
       /**
        * Get the serilized graph of {@link ComponentMetaData} objects
        * required when starting up all the components. This makes sure
  @@ -111,14 +114,14 @@
        * Get the graph of a single component.
        *
        * @param component the component
  -     * @param provider true if traversing providers, false if consumers
  +     * @param providers true if traversing providers, false if consumers
        * @return the list of components in graph
        */
  -    private ComponentMetaData[] getComponentGraph( final ComponentMetaData component, final
boolean provider )
  +    private ComponentMetaData[] getComponentGraph( final ComponentMetaData component, final
boolean providers )
       {
           final ArrayList result = new ArrayList();
           visitcomponent( component,
  -                        provider,
  +                        providers,
                           new ArrayList(),
                           result );
   
  @@ -131,10 +134,10 @@
        * It is expected that the specified components have passed
        * verification tests and are well formed.
        *
  -     * @param forward true if forward dependencys traced, false if dependencies reversed
  +     * @param providers true if forward dependencys traced, false if dependencies reversed
        * @return the ordered node names
        */
  -    private ComponentMetaData[] walkGraph( final boolean forward )
  +    private ComponentMetaData[] walkGraph( final boolean providers )
       {
           final ArrayList result = new ArrayList();
   
  @@ -144,7 +147,7 @@
               final ComponentMetaData component =
                   (ComponentMetaData)m_components.get( i );
               visitcomponent( component,
  -                            forward,
  +                            providers,
                               new ArrayList(),
                               result );
           }
  @@ -157,13 +160,13 @@
        * Visit a component when traversing dependencies.
        *
        * @param component the component
  -     * @param forward true if walking down tree, else false
  +     * @param providers true if walking tree looking for providers, else false
        * @param done those nodes already traversed
        * @param order the order in which nodes have already been
        *             traversed
        */
       private void visitcomponent( final ComponentMetaData component,
  -                                 final boolean forward,
  +                                 final boolean providers,
                                    final ArrayList done,
                                    final ArrayList order )
       {
  @@ -174,26 +177,27 @@
           }
           done.add( component );
   
  -        if( forward )
  +        if( providers )
           {
  -            visitDependencies( component, done, order );
  +            visitProviders( component, done, order );
           }
           else
           {
  -            visitReverseDependencies( component, done, order );
  +            visitConsumers( component, done, order );
           }
   
           order.add( component );
       }
   
       /**
  -     * Traverse dependencies of specified component.
  +     * Traverse graph of components that provide services to
  +     * the specified component.
        *
        * @param component the ComponentMetaData
        */
  -    private void visitDependencies( final ComponentMetaData component,
  -                                    final ArrayList done,
  -                                    final ArrayList order )
  +    private void visitProviders( final ComponentMetaData component,
  +                                 final ArrayList done,
  +                                 final ArrayList order )
       {
           final DependencyDescriptor[] descriptors =
               component.getComponentInfo().getDependencies();
  @@ -209,14 +213,14 @@
       }
   
       /**
  -     * Traverse all reverse dependencies of specified component.
  -     * A reverse dependency are those that dependend on component.
  +     * Traverse all Consumers of component. ie Anyone that uses
  +     * service provided by component.
        *
        * @param component the ComponentMetaData
        */
  -    private void visitReverseDependencies( final ComponentMetaData component,
  -                                           final ArrayList done,
  -                                           final ArrayList order )
  +    private void visitConsumers( final ComponentMetaData component,
  +                                 final ArrayList done,
  +                                 final ArrayList order )
       {
           final String name = component.getName();
   
  @@ -237,7 +241,12 @@
               }
           }
   
  -        //TODO: Search children consumers here
  +        final int childCount = m_children.size();
  +        for( int i = 0; i < childCount; i++ )
  +        {
  +            final DependencyMap map = (DependencyMap)m_children.get( i );
  +            map.visitConsumers( component, done, order );
  +        }
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message