bloritsch    2003/07/21 13:05:17

  Modified:    meta/tools/src/java/org/apache/avalon/meta/info/builder/tags
                        DependencyTag.java LoggerTag.java
  Log:
  Update LoggerTag to recognize the deprecated setLogger method.  Also format that 
class and the DependencyTag class.
  
  Revision  Changes    Path
  1.3       +43 -53    
avalon-sandbox/meta/tools/src/java/org/apache/avalon/meta/info/builder/tags/DependencyTag.java
  
  Index: DependencyTag.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/meta/tools/src/java/org/apache/avalon/meta/info/builder/tags/DependencyTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DependencyTag.java        15 Jul 2003 19:05:45 -0000      1.2
  +++ DependencyTag.java        21 Jul 2003 20:05:17 -0000      1.3
  @@ -50,17 +50,17 @@
   package org.apache.avalon.meta.info.builder.tags;
   
   
  -
   import com.thoughtworks.qdox.model.DocletTag;
   import com.thoughtworks.qdox.model.JavaClass;
   import com.thoughtworks.qdox.model.JavaMethod;
  -import java.util.ArrayList;
  -import java.util.HashSet;
  -import java.util.Set;
   import org.apache.avalon.framework.Version;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.ReferenceDescriptor;
   
  +import java.util.ArrayList;
  +import java.util.HashSet;
  +import java.util.Set;
  +
   /**
    * A doclet tag representing the lifestyle assigned to the Type.
    *
  @@ -69,75 +69,74 @@
    */
   public class DependencyTag extends AbstractTag
   {
  -   /**
  -    * The dependency tag name.
  -    */
  +    /**
  +     * The dependency tag name.
  +     */
       public static final String KEY = "dependency";
   
  -   /**
  -    * The dependency tag key parameter name.
  -    */
  +    /**
  +     * The dependency tag key parameter name.
  +     */
       public static final String KEY_PARAM = "key";
   
  -   /**
  -    * The dependency tag optional parameter name.
  -    */
  +    /**
  +     * The dependency tag optional parameter name.
  +     */
       public static final String OPTIONAL_PARAM = "optional";
   
  -   /**
  -    * The default component manager class.
  -    */
  +    /**
  +     * The default component manager class.
  +     */
       protected static final String COMPONENT_MANAGER_CLASS =
  -        "org.apache.avalon.framework.component.ComponentManager";
  +            "org.apache.avalon.framework.component.ComponentManager";
   
  -   /**
  -    * The default service manager class.
  -    */
  +    /**
  +     * The default service manager class.
  +     */
       protected static final String SERVICE_MANAGER_CLASS =
  -        "org.apache.avalon.framework.service.ServiceManager";
  +            "org.apache.avalon.framework.service.ServiceManager";
   
       private JavaMethod[] m_methods;
   
  -
  -   /**
  -    * Class constructor.
  -    * @param clazz the javadoc class descriptor
  -    */
  +    /**
  +     * Class constructor.
  +     * @param clazz the javadoc class descriptor
  +     */
       public DependencyTag( final JavaClass clazz )
       {
           super( clazz );
           setMethods();
       }
   
  -   /**
  -    * Return the array of dependency descriptors based on the set of
  -    * 'dependency' tags associated with the components compose or service method.
  -    * @return the set of dependencies
  -    */
  +    /**
  +     * Return the array of dependency descriptors based on the set of
  +     * 'dependency' tags associated with the components compose or service method.
  +     * @return the set of dependencies
  +     */
       public DependencyDescriptor[] getDependencies()
       {
           final ArrayList deps = new ArrayList();
           final Set marked = new HashSet( 10 );
  -        for( int j = 0; j < m_methods.length; j++ )
  +        for ( int j = 0; j < m_methods.length; j++ )
           {
  -            final DocletTag[] tags = 
  -              m_methods[j].getTagsByName( getNS() 
  -                                    + Tags.DELIMITER + KEY );
  +            final DocletTag[] tags =
  +                    m_methods[j].getTagsByName( getNS()
  +                    + Tags.DELIMITER + KEY );
   
  -            for( int i = 0; i < tags.length; i++ )
  +            for ( int i = 0; i < tags.length; i++ )
               {
                   DocletTag tag = tags[i];
                   DependencyDescriptor dep = getDependency( tag );
                   final String key = dep.getKey();
  -                if( !marked.contains( key ) )
  +                if ( !marked.contains( key ) )
                   {
                       deps.add( dep );
                       marked.add( key );
                   }
               }
           }
  -        return (DependencyDescriptor[])deps.toArray( 
  -          new DependencyDescriptor[ deps.size() ] );
  +        return (DependencyDescriptor[]) deps.toArray(
  +                new DependencyDescriptor[deps.size()] );
       }
   
       private DependencyDescriptor getDependency( DocletTag tag )
  @@ -153,24 +152,15 @@
           return new DependencyDescriptor( key, ref, isOptional, null );
       }
   
  -   /**
  -    * Set the value of the composition method.
  -    */
  +    /**
  +     * Set the value of the composition method.
  +     */
       private void setMethods()
       {
           m_methods = getLifecycleMethods( "compose", COMPONENT_MANAGER_CLASS );
  -        if( m_methods.length == 0 )
  +        if ( m_methods.length == 0 )
           {
               m_methods = getLifecycleMethods( "service", SERVICE_MANAGER_CLASS );
           }
  -    }
  -
  -   /**
  -    * Return the composition method.
  -    * @return an array of methods
  -    */
  -    private JavaMethod[] getMethods()
  -    {
  -        return m_methods;
       }
   }
  
  
  
  1.4       +67 -47    
avalon-sandbox/meta/tools/src/java/org/apache/avalon/meta/info/builder/tags/LoggerTag.java
  
  Index: LoggerTag.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/meta/tools/src/java/org/apache/avalon/meta/info/builder/tags/LoggerTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LoggerTag.java    10 Jul 2003 21:22:27 -0000      1.3
  +++ LoggerTag.java    21 Jul 2003 20:05:17 -0000      1.4
  @@ -50,14 +50,14 @@
   package org.apache.avalon.meta.info.builder.tags;
   
   
  -
   import com.thoughtworks.qdox.model.DocletTag;
   import com.thoughtworks.qdox.model.JavaClass;
   import com.thoughtworks.qdox.model.JavaMethod;
  +import org.apache.avalon.meta.info.CategoryDescriptor;
  +
   import java.util.ArrayList;
   import java.util.HashSet;
   import java.util.Set;
  -import org.apache.avalon.meta.info.CategoryDescriptor;
   
   /**
    * A doclet tag handler supporting 'logger' tags.
  @@ -67,62 +67,82 @@
    */
   public class LoggerTag extends AbstractTag
   {
  -   /**
  -    * The javadoc key for the logger tag.
  -    */
  +    /**
  +     * The javadoc key for the logger tag.
  +     */
       protected static final String KEY = "logger";
   
  -   /**
  -    * The javadoc parameter name for the logging channel name
  -    */
  +    /**
  +     * The javadoc parameter name for the logging channel name
  +     */
       public static final String NAME_PARAM = "name";
   
  -   /**
  -    * The default logger class.
  -    */
  +    /**
  +     * The default logger class.
  +     */
       protected static final String LOGGER_CLASS =
  -        "org.apache.avalon.framework.logger.Logger";
  +            "org.apache.avalon.framework.logger.Logger";
   
  -   /**
  -    * The logger tag constructor.
  -    * @param clazz the javadoc class descriptor.
  -    */
  +    /**
  +     * The deprecated logger class
  +     */
  +    protected static final String DEPRECATED_LOGGER_CLASS =
  +            "org.apache.log.Logger";
  +
  +    private JavaMethod[] m_methods;
  +
  +    /**
  +     * The logger tag constructor.
  +     * @param clazz the javadoc class descriptor.
  +     */
       public LoggerTag( final JavaClass clazz )
       {
           super( clazz );
  +        setMethods();
       }
   
  -   /**
  -    * Return an array of logger descriptors relative to the 'logger' tags declared 
under the
  -    * LogEnabled interface.
  -    * @return the set of logger descriptos
  -    */
  +    /**
  +     * Return an array of logger descriptors relative to the 'logger' tags declared 
under the
  +     * LogEnabled interface.
  +     * @return the set of logger descriptos
  +     */
       public CategoryDescriptor[] getCategories()
       {
  -        final JavaMethod[] methods =
  -            getLifecycleMethods( "enableLogging", LOGGER_CLASS );
  -     final ArrayList loggers = new ArrayList();
  -     final Set marked = new HashSet( 10 );
  -        
  -     for( int j = 0; j < methods.length; j++ )
  -     {
  -         final DocletTag[] tags = 
  -             methods[j].getTagsByName( getNS() 
  -                                       + Tags.DELIMITER + KEY );
  -
  -         for( int i = 0; i < tags.length; i++ )
  -         {
  -             final String name =
  -                    getNamedParameter( tags[ i ], NAME_PARAM, "" );
  -                
  -             if( !marked.contains( name ) ){
  -                 final CategoryDescriptor logger =
  -                     new CategoryDescriptor( name, null );
  -                 loggers.add( logger );
  -                 marked.add( name );
  -             }
  -         }
  -     }
  -     return (CategoryDescriptor[])loggers.toArray( new CategoryDescriptor[ 
loggers.size() ] );
  +        final ArrayList loggers = new ArrayList();
  +        final Set marked = new HashSet( 10 );
  +
  +        for ( int j = 0; j < m_methods.length; j++ )
  +        {
  +            final DocletTag[] tags =
  +                    m_methods[j].getTagsByName( getNS()
  +                    + Tags.DELIMITER + KEY );
  +
  +            for ( int i = 0; i < tags.length; i++ )
  +            {
  +                final String name =
  +                        getNamedParameter( tags[i], NAME_PARAM, "" );
  +
  +                if ( !marked.contains( name ) )
  +                {
  +                    final CategoryDescriptor logger =
  +                            new CategoryDescriptor( name, null );
  +                    loggers.add( logger );
  +                    marked.add( name );
  +                }
  +            }
  +        }
  +        return (CategoryDescriptor[]) loggers.toArray( new 
CategoryDescriptor[loggers.size()] );
  +    }
  +
  +    /**
  +     * Set the value of the composition method.
  +     */
  +    private void setMethods()
  +    {
  +        m_methods = getLifecycleMethods( "enableLogging", LOGGER_CLASS );
  +        if ( m_methods.length == 0 )
  +        {
  +            m_methods = getLifecycleMethods( "setLogger", DEPRECATED_LOGGER_CLASS );
  +        }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to