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/store ComponentStore.java
Date Mon, 19 Aug 2002 12:12:35 GMT
donaldp     2002/08/19 05:12:35

  Modified:    containerkit/src/java/org/apache/excalibur/containerkit/kernel
                        AbstractServiceKernel.java
  Added:       containerkit/src/java/org/apache/excalibur/containerkit/store
                        ComponentStore.java
  Log:
  Start separating out storage and processing of component.
  
  Revision  Changes    Path
  1.21      +7 -7      jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/kernel/AbstractServiceKernel.java
  
  Index: AbstractServiceKernel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/kernel/AbstractServiceKernel.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- AbstractServiceKernel.java	18 Aug 2002 03:46:08 -0000	1.20
  +++ AbstractServiceKernel.java	19 Aug 2002 12:12:35 -0000	1.21
  @@ -8,7 +8,6 @@
   package org.apache.excalibur.containerkit.kernel;
   
   import java.util.ArrayList;
  -import java.util.HashMap;
   import java.util.List;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  @@ -21,6 +20,7 @@
   import org.apache.excalibur.containerkit.lifecycle.LifecycleHelper;
   import org.apache.excalibur.containerkit.lifecycle.ResourceProvider;
   import org.apache.excalibur.containerkit.metadata.ComponentMetaData;
  +import org.apache.excalibur.containerkit.store.ComponentStore;
   import org.apache.avalon.framework.info.ComponentInfo;
   
   /**
  @@ -55,7 +55,7 @@
       /**
        * The map of all entrys present in application.
        */
  -    private final HashMap m_entrys = new HashMap();
  +    private final ComponentStore m_store = new ComponentStore();
       /**
        * The {@link DependencyMap} via which dependency graph is
        * produced.
  @@ -148,7 +148,7 @@
       protected final void startupComponent( final String name )
           throws Exception
       {
  -        final ComponentEntry entry = (ComponentEntry)m_entrys.get( name );
  +        final ComponentEntry entry = m_store.getComponent( name );
           final ComponentEntry[] components =
               m_dependencyMap.getProviderGraph( entry );
           processComponents( true, components );
  @@ -162,7 +162,7 @@
       protected final void shutdownComponent( final String name )
           throws Exception
       {
  -        final ComponentEntry entry = (ComponentEntry)m_entrys.get( name );
  +        final ComponentEntry entry = m_store.getComponent( name );
           final ComponentEntry[] components =
               m_dependencyMap.getConsumerGraph( entry );
           processComponents( false, components );
  @@ -190,13 +190,13 @@
       {
           final ComponentInfo info = m_factory.createInfo( component.getImplementationKey()
);
           final ComponentEntry entry = new ComponentEntry( info, component );
  -        m_entrys.put( component.getName(), entry );
  +        m_store.addComponent( entry );
           m_dependencyMap.add( entry );
       }
   
       protected final Object getComponent( final String name )
       {
  -        final ComponentEntry entry = (ComponentEntry)m_entrys.get( name );
  +        final ComponentEntry entry = m_store.getComponent( name );
           if( null != entry )
           {
               return entry.getObject();
  
  
  
  1.1                  jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/store/ComponentStore.java
  
  Index: ComponentStore.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.excalibur.containerkit.store;
  
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Collection;
  import java.util.ArrayList;
  import org.apache.excalibur.containerkit.kernel.ComponentEntry;
  
  /**
   *
   *
   * @author <a href="mailto:peter at apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/08/19 12:12:35 $
   */
  public class ComponentStore
  {
      /**
       * The set of components in assembly.
       * Used when searching for providers/consumers.
       */
      private final Map m_components = new HashMap();
  
      /**
       * Add a component to store.
       *
       * @param component the component
       */
      public void addComponent( final ComponentEntry component )
      {
          final String name =
              component.getMetaData().getName();
          m_components.put( name, component );
      }
  
      /**
       * Remove a component from the store.
       *
       * @param component the component
       */
      public void removeComponent( final ComponentEntry component )
      {
          final String name =
              component.getMetaData().getName();
          m_components.remove( name );
      }
  
      /**
       * Return a component with specified name.
       *
       * @return a component with specified name
       */
      public ComponentEntry getComponent( final String name )
      {
          return (ComponentEntry)m_components.get( name );
      }
  
      /**
       * Return a collection containing all the
       * names of components in store. No ordering of
       * components is guarenteed or mandated.
       *
       * @return the collection containing all component names
       */
      public Collection getComponentNames()
      {
          final Collection collection = m_components.keySet();
          final ArrayList components = new ArrayList();
          components.addAll( collection );
          return components;
      }
  
      /**
       * Return a collection containing all the
       * components in store. Noordering of
       * components is guarenteed or mandated.
       *
       * @return the collection containing all components
       */
      public Collection getComponents()
      {
          final Collection collection = m_components.values();
          final ArrayList components = new ArrayList();
          components.addAll( collection );
          return components;
      }
  }
  
  
  

--
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