1 23 24 29 30 package com.sun.jdo.spi.persistence.utility.logging; 31 32 import java.util.Map ; 33 import java.util.HashMap ; 34 35 40 abstract public class AbstractLoggerFactory implements LoggerFactory 41 { 42 private final static String _domainPrefix = "com.sun.jdo."; 44 private final static Map _loggerCache = new HashMap (); 45 46 private static final String _bundleName = 47 "com.sun.jdo.spi.persistence.utility.logging.Bundle"; 49 50 53 protected static Logger getErrorLogger () 54 { 55 return LogHelper.getLogger("", _bundleName, AbstractLoggerFactory.class.getClassLoader()); 57 } 58 59 68 public synchronized Logger getLogger (String relativeLoggerName, 69 String bundleName, ClassLoader loader) 70 { 71 String absoluteLoggerName = getAbsoluteLoggerName(relativeLoggerName); 72 Logger value = (Logger)_loggerCache.get(absoluteLoggerName); 73 74 if (value == null) 75 { 76 value = createLogger(absoluteLoggerName, bundleName, loader); 77 78 if (value != null) 79 _loggerCache.put(absoluteLoggerName, value); 80 } 81 82 return value; 83 } 84 85 94 abstract protected Logger createLogger (String absoluteLoggerName, 95 String bundleName, ClassLoader loader); 96 97 protected String getDomainRoot () { return _domainPrefix; } 98 99 protected String getAbsoluteLoggerName (String relativeLoggerName) 100 { 101 return (relativeLoggerName.startsWith("java") ? relativeLoggerName : (getDomainRoot() + relativeLoggerName)); 103 } 104 } 105 | Popular Tags |