1 49 50 package org.apache.avalon.meta.info.builder.tags; 51 52 53 import com.thoughtworks.qdox.model.DocletTag; 54 import com.thoughtworks.qdox.model.JavaClass; 55 import com.thoughtworks.qdox.model.JavaMethod; 56 import org.apache.avalon.meta.info.CategoryDescriptor; 57 58 import java.util.ArrayList ; 59 import java.util.HashSet ; 60 import java.util.Set ; 61 62 68 public class LoggerTag extends AbstractTag 69 { 70 73 protected static final String KEY = "logger"; 74 75 78 public static final String NAME_PARAM = "name"; 79 80 83 protected static final String LOGGER_CLASS = 84 "org.apache.avalon.framework.logger.Logger"; 85 86 89 protected static final String DEPRECATED_LOGGER_CLASS = 90 "org.apache.log.Logger"; 91 92 private JavaMethod[] m_methods; 93 94 98 public LoggerTag( final JavaClass clazz ) 99 { 100 super( clazz ); 101 setMethods(); 102 } 103 104 109 public CategoryDescriptor[] getCategories() 110 { 111 final ArrayList loggers = new ArrayList (); 112 final Set marked = new HashSet ( 10 ); 113 114 for ( int j = 0; j < m_methods.length; j++ ) 115 { 116 final DocletTag[] tags = 117 m_methods[j].getTagsByName( getNS() 118 + Tags.DELIMITER + KEY ); 119 120 for ( int i = 0; i < tags.length; i++ ) 121 { 122 final String name = 123 getNamedParameter( tags[i], NAME_PARAM, "" ); 124 125 if ( !marked.contains( name ) ) 126 { 127 final CategoryDescriptor logger = 128 new CategoryDescriptor( name, null ); 129 loggers.add( logger ); 130 marked.add( name ); 131 } 132 } 133 } 134 return (CategoryDescriptor[]) loggers.toArray( new CategoryDescriptor[loggers.size()] ); 135 } 136 137 140 private void setMethods() 141 { 142 m_methods = getLifecycleMethods( "enableLogging", LOGGER_CLASS ); 143 if ( m_methods.length == 0 ) 144 { 145 m_methods = getLifecycleMethods( "setLogger", DEPRECATED_LOGGER_CLASS ); 146 } 147 } 148 } 149 | Popular Tags |