1 17 18 package org.sape.carbon.services.log.console; 19 20 import java.util.Enumeration ; 21 import java.util.Hashtable ; 22 import java.util.Vector ; 23 24 import org.apache.commons.logging.Log; 25 import org.apache.commons.logging.LogConfigurationException; 26 import org.apache.commons.logging.LogFactory; 27 28 36 public class ConsoleLogFactory extends LogFactory { 37 38 41 private Hashtable attributes = new Hashtable (); 42 43 46 private Hashtable instances = new Hashtable (); 47 48 51 public ConsoleLogFactory() { 52 super(); 53 } 54 55 58 public Object getAttribute(String name) { 59 return (attributes.get(name)); 60 } 61 62 65 public String [] getAttributeNames() { 66 Vector names = new Vector (); 67 Enumeration keys = attributes.keys(); 68 while (keys.hasMoreElements()) { 69 names.addElement((String ) keys.nextElement()); 70 } 71 String results[] = new String [names.size()]; 72 for (int i = 0; i < results.length; i++) { 73 results[i] = (String ) names.elementAt(i); 74 } 75 return (results); 76 } 77 78 81 public Log getInstance(Class className) throws LogConfigurationException { 82 return getInstance(className.getName()); 83 } 84 85 88 public Log getInstance(String className) throws LogConfigurationException { 89 Log consoleLogger = null; 90 91 consoleLogger = (ConsoleLogger) instances.get(className); 92 93 if ( consoleLogger == null ) { 94 consoleLogger = new ConsoleLogger(className); 95 } 96 97 return consoleLogger; 98 } 99 100 103 public void release() { 104 instances.clear(); 106 } 107 108 111 public void removeAttribute(String name) { 112 attributes.remove(name); 113 } 114 115 118 public void setAttribute(String name, Object value) { 119 attributes.put(name, value); 120 } 121 122 } 123 | Popular Tags |