1 package org.jzonic.jlo; 2 3 import java.util.HashMap ; 4 import java.util.Vector ; 5 import org.jzonic.jlo.filter.LogFilter; 6 15 public class LogConfiguration { 16 17 private String configurationName; 18 private HashMap logger; 19 private HashMap generator; 20 private HashMap channels; 21 private Vector pipes; 22 private HashMap filters; 23 26 public LogConfiguration(String configurationName) { 27 logger = new HashMap (); 28 generator = new HashMap (); 29 channels = new HashMap (); 30 pipes = new Vector (); 31 filters = new HashMap (); 32 this.configurationName = configurationName; 33 } 34 35 41 public Channel getChannel(String name) { 42 Channel channel = (Channel)channels.get(name); 43 return channel; 44 } 45 46 51 private String findChannelName(String name) { 52 boolean searching = true; 53 String myName = name; 54 while ( searching ) { 55 if ( !channels.containsKey(myName) ) { 56 int pos = myName.lastIndexOf("."); 57 if ( pos != -1 ) { 58 myName = myName.substring(0,pos); 59 } 60 else { 61 searching = false; 62 myName = null; 63 } 64 } 65 else { 66 searching = false; 67 } 68 } 69 return myName; 70 } 71 72 80 public Logger getLogger(String name) { 81 String myName = findLoggerName(name); 82 Logger myLogger = (Logger)logger.get(myName); 83 return myLogger; 84 } 85 86 93 private String findLoggerName(String name) { 94 boolean searching = true; 95 String myName = name; 96 while ( searching ) { 97 if ( !logger.containsKey(myName) ) { 98 int pos = myName.lastIndexOf("."); 99 if ( pos != -1 ) { 100 myName = myName.substring(0,pos); 101 } 102 else { 103 searching = false; 104 myName = null; 105 } 106 } 107 else { 108 searching = false; 109 } 110 } 111 return myName; 112 } 113 114 122 public void addLogger(Logger l) { 123 if ( l != null ) { 124 if ( l.getLoggerName() != null ) { 125 logger.put(l.getLoggerName(), l); 126 } 127 } 128 } 129 130 136 public int getLoggerCount() { 137 return logger.size(); 138 } 139 140 148 public void addLogGenerator(LogGenerator lg) { 149 if ( lg != null ) { 150 if ( lg.getName() != null ) { 151 generator.put(lg.getName(),lg); 152 } 153 } 154 } 155 156 163 public LogGenerator getLogGenerator(String name) { 164 return (LogGenerator)generator.get(name); 165 } 166 167 173 public int getLogGeneratorCount() { 174 return generator.size(); 175 } 176 177 185 public void addChannel(Channel channel) { 186 if ( channel != null ) { 187 if ( channel.getChannelName() != null ) { 188 channels.put(channel.getChannelName(),channel); 189 } 190 } 191 } 192 193 199 public int getChannelCount() { 200 return channels.size(); 201 } 202 203 209 public String getName() { 210 return configurationName; 211 } 212 213 216 public void addLogPipe(LogPipe pipe) { 217 if ( pipe != null ) { 218 pipes.add(pipe); 219 } 220 } 221 222 227 public Vector getLogPipes() { 228 return pipes; 229 } 230 236 public int getLogPipesCount() { 237 return pipes.size(); 238 } 239 240 244 public void addLogFilter(String name,LogFilter filter) { 245 filters.put(name,filter); 246 } 247 248 252 public LogFilter getLogFilter(String name) { 253 return (LogFilter)filters.get(name); 254 } 255 256 259 public int getFilterCount() { 260 return filters.size(); 261 } 262 } 263 | Popular Tags |