You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by bl...@apache.org on 2001/04/11 18:39:16 UTC

cvs commit: jakarta-avalon/src/java/org/apache/avalon/component DefaultComponentManager.java

bloritsch    01/04/11 09:39:15

  Modified:    src/java/org/apache/avalon/component
                        DefaultComponentManager.java
  Log:
  Added fix from Dims (Davinum Srivinas)
  
  Revision  Changes    Path
  1.6       +33 -33    jakarta-avalon/src/java/org/apache/avalon/component/DefaultComponentManager.java
  
  Index: DefaultComponentManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/component/DefaultComponentManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultComponentManager.java	2001/04/11 04:18:10	1.5
  +++ DefaultComponentManager.java	2001/04/11 16:39:13	1.6
  @@ -32,9 +32,9 @@
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
  - * @version CVS $Revision: 1.5 $ $Date: 2001/04/11 04:18:10 $
  + * @version CVS $Revision: 1.6 $ $Date: 2001/04/11 16:39:13 $
    */
  -public class DefaultComponentManager 
  +public class DefaultComponentManager
       extends AbstractLoggable
       implements ComponentManager, Configurable, Contextualizable, Disposable
   {
  @@ -57,7 +57,7 @@
       /** Is the Manager disposed or not? */
       private boolean      m_disposed;
   
  -    public DefaultComponentManager() 
  +    public DefaultComponentManager()
       {
           // Setup the maps.
           m_componentHandlers = Collections.synchronizedMap( new HashMap() );
  @@ -66,7 +66,7 @@
   
       /** Set up the Component's Context.
        */
  -    public void contextualize( final Context context ) 
  +    public void contextualize( final Context context )
       {
           //HACK: Is this really needed ??? (Isn't a symtom of fault elsewhere in system)
           if( null == m_context )
  @@ -84,10 +84,10 @@
           Iterator keys = m_componentHandlers.keySet().iterator();
           final List keyList = new ArrayList();
   
  -        while( keys.hasNext() ) 
  +        while( keys.hasNext() )
           {
               final Object key = keys.next();
  -            final DefaultComponentHandler handler = 
  +            final DefaultComponentHandler handler =
                   (DefaultComponentHandler)m_componentHandlers.get( key );
   
               handler.dispose();
  @@ -115,13 +115,13 @@
   
           if( m_disposed )
           {
  -            throw new IllegalStateException( "You cannot lookup components " + 
  +            throw new IllegalStateException( "You cannot lookup components " +
                                                "on a disposed ComponentManager" );
           }
   
           if( null == role )
           {
  -            final String message = 
  +            final String message =
                   "ComponentManager Attempted to retrieve component with null role.";
               getLogger().error( message );
               throw new ComponentException( message );
  @@ -132,27 +132,27 @@
           // Retrieve the instance of the requested component
           if( null == handler )
           {
  -            getLogger().debug( "Could not find ComponentHandler, " + 
  +            getLogger().debug( "Could not find ComponentHandler, " +
                                  "attempting to create one for role: " + role );
   
  -            try 
  +            try
               {
                   final String className = m_roles.getDefaultClassNameForRole( role );
  -                final Class componentClass = 
  +                final Class componentClass =
                       getClass().getClassLoader().loadClass( className );
   
                   final Configuration configuration = new DefaultConfiguration( "", "-" );
   
  -                handler = 
  -                    new DefaultComponentHandler( componentClass, 
  -                                                 configuration, 
  -                                                 this, 
  +                handler =
  +                    new DefaultComponentHandler( componentClass,
  +                                                 configuration,
  +                                                 this,
                                                    m_context,
                                                    m_roles );
   
                   handler.setLogger( getLogger() );
                   handler.init();
  -            } 
  +            }
               catch( final Exception e )
               {
                   final String message =
  @@ -166,7 +166,7 @@
   
           Component component = null;
   
  -        try 
  +        try
           {
               component = handler.get();
   
  @@ -174,7 +174,7 @@
               {
                   ((DefaultComponentSelector)component).setRoleManager( m_roles );
               }
  -        } 
  +        }
           catch( final IllegalStateException ise )
           {
               handler.init();
  @@ -182,13 +182,13 @@
               try
               {
                   component = handler.get();
  -            } 
  +            }
               catch( final Exception e )
               {
                   final String message = "Could not access the Component for role: " + role;
                   throw new ComponentException( message, e );
               }
  -        } 
  +        }
           catch( final Exception e )
           {
               final String message = "Could not access the Component for role: " + role;
  @@ -202,10 +202,10 @@
       /**
        * Configure the ComponentManager.
        */
  -    public void configure( final Configuration configuration ) 
  +    public void configure( final Configuration configuration )
           throws ConfigurationException
       {
  -        if( null != m_roles )
  +        if( null == m_roles )
           {
               DefaultRoleManager role_info = new DefaultRoleManager();
               role_info.setLogger( getLogger() );
  @@ -241,14 +241,14 @@
                       try
                       {
                           getLogger().debug( "Adding component (" + role + " = " + className + ")" );
  -                        final Class clazz = 
  +                        final Class clazz =
                               getClass().getClassLoader().loadClass( className );
                           addComponent( role, clazz, configurations[ i ] );
  -                    } 
  +                    }
                       catch( final Exception e )
                       {
  -                        final String message = 
  -                            "Could not get class " + className + " for role " + role + 
  +                        final String message =
  +                            "Could not get class " + className + " for role " + role +
                               " on configuration element " + configurations[ i ].getName();
   
                           getLogger().error( message, e );
  @@ -279,7 +279,7 @@
       {
           if( null == component ) return;
   
  -        final DefaultComponentHandler handler = 
  +        final DefaultComponentHandler handler =
               (DefaultComponentHandler)m_componentMapping.get( component );
   
           if( null != handler )
  @@ -294,19 +294,19 @@
        * @param component the class of this component.
        * @param Configuration the configuration for this component.
        */
  -    public void addComponent( final String role, 
  -                              final Class component, 
  +    public void addComponent( final String role,
  +                              final Class component,
                                 final Configuration configuration )
           throws ComponentException
       {
           try
           {
  -            final DefaultComponentHandler handler = 
  +            final DefaultComponentHandler handler =
                   new DefaultComponentHandler( component, configuration, this, m_context, m_roles );
   
               handler.setLogger( getLogger() );
               m_componentHandlers.put( role, handler );
  -        } 
  +        }
           catch( final Exception e )
           {
               throw new ComponentException( "Could not set up Component for role: " + role, e );
  @@ -319,12 +319,12 @@
        */
       public void addComponentInstance( final String role, final Object instance )
       {
  -        try 
  +        try
           {
               DefaultComponentHandler handler = new DefaultComponentHandler( (Component)instance );
               handler.setLogger( getLogger() );
               m_componentHandlers.put( role, handler );
  -        } 
  +        }
           catch( final Exception e )
           {
               getLogger().warn( "Could not set up Component for role: " + role, e );
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org