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/infobuilder XMLInfoCreator.java
Date Tue, 02 Jul 2002 02:45:48 GMT
donaldp     2002/07/01 19:45:48

  Modified:    containerkit/src/java/org/apache/excalibur/containerkit/infobuilder
                        XMLInfoCreator.java
  Log:
  Update builder to build LoggerDescriptors if present in componentinfo.xml
  
  Revision  Changes    Path
  1.3       +49 -5     jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/infobuilder/XMLInfoCreator.java
  
  Index: XMLInfoCreator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/infobuilder/XMLInfoCreator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLInfoCreator.java	28 Jun 2002 02:00:04 -0000	1.2
  +++ XMLInfoCreator.java	2 Jul 2002 02:45:48 -0000	1.3
  @@ -22,6 +22,7 @@
   import org.apache.excalibur.containerkit.metainfo.ContextDescriptor;
   import org.apache.excalibur.containerkit.metainfo.DependencyDescriptor;
   import org.apache.excalibur.containerkit.metainfo.EntryDescriptor;
  +import org.apache.excalibur.containerkit.metainfo.LoggerDescriptor;
   import org.apache.excalibur.containerkit.metainfo.ServiceDescriptor;
   import org.apache.excalibur.containerkit.metainfo.ServiceDesignator;
   import org.xml.sax.InputSource;
  @@ -62,7 +63,7 @@
       }
   
       /**
  -     * Create a <code>ComponentInfo</code> object for specified classname from
  +     * Create a {@link ComponentInfo} object for specified classname from
        * specified configuration data.
        *
        * @param classname The classname of Component
  @@ -94,6 +95,9 @@
   
           Configuration configuration = null;
   
  +        configuration = info.getChild( "loggers" );
  +        final LoggerDescriptor[] loggers = buildLoggers( configuration );
  +
           configuration = info.getChild( "context" );
           final ContextDescriptor context = buildContext( configuration );
   
  @@ -114,15 +118,55 @@
                                  classname,
                                  new Integer( services.length ),
                                  new Integer( dependencies.length ),
  -                               new Integer( context.getEntrys().length ) );
  +                               new Integer( context.getEntrys().length ),
  +                               new Integer( loggers.length ) );
               getLogger().debug( message );
           }
   
  -        return new ComponentInfo( descriptor, context, services, dependencies );
  +        return new ComponentInfo( descriptor, loggers, context, services, dependencies
);
  +    }
  +
  +    /**
  +     * A utility method to build an array of {@link LoggerDescriptor} objects
  +     * from specified configuraiton.
  +     *
  +     * @param configuration the loggers configuration
  +     * @return the created LoggerDescriptor
  +     * @throws ConfigurationException if an error occurs
  +     */
  +    private LoggerDescriptor[] buildLoggers( final Configuration configuration )
  +        throws ConfigurationException
  +    {
  +        final Configuration[] elements = configuration.getChildren( "logger" );
  +        final ArrayList loggers = new ArrayList();
  +
  +        for( int i = 0; i < elements.length; i++ )
  +        {
  +            final LoggerDescriptor logger = buildLogger( elements[ i ] );
  +            loggers.add( logger );
  +        }
  +
  +        return (LoggerDescriptor[])loggers.toArray( new LoggerDescriptor[ loggers.size()
] );
  +    }
  +
  +    /**
  +     * A utility method to build a {@link LoggerDescriptor}
  +     * object from specified configuraiton.
  +     *
  +     * @param logger the Logger configuration
  +     * @return the created LoggerDescriptor
  +     * @throws ConfigurationException if an error occurs
  +     */
  +    private LoggerDescriptor buildLogger( Configuration logger )
  +        throws ConfigurationException
  +    {
  +        final Properties attributes = buildAttributes( logger.getChild( "attributes" )
);
  +        final String name = logger.getAttribute( "name", "" );
  +        return new LoggerDescriptor( name, attributes );
       }
   
       /**
  -     * A utility method to build an array of <code>DependencyDescriptor</code>
  +     * A utility method to build an array of {@link DependencyDescriptor}
        * objects from specified configuraiton and classname.
        *
        * @param classname The classname of Component (used for logging purposes)
  
  
  

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