commons-logging-1.1.3

16:34:52.017 INFO  jd.cli.Main - Decompiling commons-logging-1.1.3.jar
package org.apache.commons.logging.impl;

import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

public class AvalonLogger
  implements Log
{
  private static volatile Logger defaultLogger = null;
  private final transient Logger logger;
  
  public AvalonLogger(Logger logger)
  {
    this.logger = logger;
  }
  
  public AvalonLogger(String name)
  {
    if (defaultLogger == null) {
      throw new NullPointerException("default logger has to be specified if this constructor is used!");
    }
    logger = defaultLogger.getChildLogger(name);
  }
  
  public Logger getLogger()
  {
    return logger;
  }
  
  public static void setDefaultLogger(Logger logger)
  {
    defaultLogger = logger;
  }
  
  public void debug(Object message, Throwable t)
  {
    if (getLogger().isDebugEnabled()) {
      getLogger().debug(String.valueOf(message), t);
    }
  }
  
  public void debug(Object message)
  {
    if (getLogger().isDebugEnabled()) {
      getLogger().debug(String.valueOf(message));
    }
  }
  
  public void error(Object message, Throwable t)
  {
    if (getLogger().isErrorEnabled()) {
      getLogger().error(String.valueOf(message), t);
    }
  }
  
  public void error(Object message)
  {
    if (getLogger().isErrorEnabled()) {
      getLogger().error(String.valueOf(message));
    }
  }
  
  public void fatal(Object message, Throwable t)
  {
    if (getLogger().isFatalErrorEnabled()) {
      getLogger().fatalError(String.valueOf(message), t);
    }
  }
  
  public void fatal(Object message)
  {
    if (getLogger().isFatalErrorEnabled()) {
      getLogger().fatalError(String.valueOf(message));
    }
  }
  
  public void info(Object message, Throwable t)
  {
    if (getLogger().isInfoEnabled()) {
      getLogger().info(String.valueOf(message), t);
    }
  }
  
  public void info(Object message)
  {
    if (getLogger().isInfoEnabled()) {
      getLogger().info(String.valueOf(message));
    }
  }
  
  public boolean isDebugEnabled()
  {
    return getLogger().isDebugEnabled();
  }
  
  public boolean isErrorEnabled()
  {
    return getLogger().isErrorEnabled();
  }
  
  public boolean isFatalEnabled()
  {
    return getLogger().isFatalErrorEnabled();
  }
  
  public boolean isInfoEnabled()
  {
    return getLogger().isInfoEnabled();
  }
  
  public boolean isTraceEnabled()
  {
    return getLogger().isDebugEnabled();
  }
  
  public boolean isWarnEnabled()
  {
    return getLogger().isWarnEnabled();
  }
  
  public void trace(Object message, Throwable t)
  {
    if (getLogger().isDebugEnabled()) {
      getLogger().debug(String.valueOf(message), t);
    }
  }
  
  public void trace(Object message)
  {
    if (getLogger().isDebugEnabled()) {
      getLogger().debug(String.valueOf(message));
    }
  }
  
  public void warn(Object message, Throwable t)
  {
    if (getLogger().isWarnEnabled()) {
      getLogger().warn(String.valueOf(message), t);
    }
  }
  
  public void warn(Object message)
  {
    if (getLogger().isWarnEnabled()) {
      getLogger().warn(String.valueOf(message));
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.AvalonLogger
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogConfigurationException;

public class SimpleLog
  implements Log, Serializable
{
  private static final long serialVersionUID = 136942970684951178L;
  protected static final String systemPrefix = "org.apache.commons.logging.simplelog.";
  protected static final Properties simpleLogProps = new Properties();
  protected static final String DEFAULT_DATE_TIME_FORMAT = "yyyy/MM/dd HH:mm:ss:SSS zzz";
  protected static volatile boolean showLogName = false;
  protected static volatile boolean showShortName = true;
  protected static volatile boolean showDateTime = false;
  protected static volatile String dateTimeFormat = "yyyy/MM/dd HH:mm:ss:SSS zzz";
  protected static DateFormat dateFormatter = null;
  public static final int LOG_LEVEL_TRACE = 1;
  public static final int LOG_LEVEL_DEBUG = 2;
  public static final int LOG_LEVEL_INFO = 3;
  public static final int LOG_LEVEL_WARN = 4;
  public static final int LOG_LEVEL_ERROR = 5;
  public static final int LOG_LEVEL_FATAL = 6;
  public static final int LOG_LEVEL_ALL = 0;
  public static final int LOG_LEVEL_OFF = 7;
  
  private static String getStringProperty(String name)
  {
    String prop = null;
    try
    {
      prop = System.getProperty(name);
    }
    catch (SecurityException e) {}
    return prop == null ? simpleLogProps.getProperty(name) : prop;
  }
  
  private static String getStringProperty(String name, String dephault)
  {
    String prop = getStringProperty(name);
    return prop == null ? dephault : prop;
  }
  
  private static boolean getBooleanProperty(String name, boolean dephault)
  {
    String prop = getStringProperty(name);
    return prop == null ? dephault : "true".equalsIgnoreCase(prop);
  }
  
  static
  {
    InputStream in = getResourceAsStream("simplelog.properties");
    if (null != in) {
      try
      {
        simpleLogProps.load(in);
        in.close();
      }
      catch (IOException e) {}
    }
    showLogName = getBooleanProperty("org.apache.commons.logging.simplelog.showlogname", showLogName);
    showShortName = getBooleanProperty("org.apache.commons.logging.simplelog.showShortLogname", showShortName);
    showDateTime = getBooleanProperty("org.apache.commons.logging.simplelog.showdatetime", showDateTime);
    if (showDateTime)
    {
      dateTimeFormat = getStringProperty("org.apache.commons.logging.simplelog.dateTimeFormat", dateTimeFormat);
      try
      {
        dateFormatter = new SimpleDateFormat(dateTimeFormat);
      }
      catch (IllegalArgumentException e)
      {
        dateTimeFormat = "yyyy/MM/dd HH:mm:ss:SSS zzz";
        dateFormatter = new SimpleDateFormat(dateTimeFormat);
      }
    }
  }
  
  protected volatile String logName = null;
  protected volatile int currentLogLevel;
  private volatile String shortLogName = null;
  
  public SimpleLog(String name)
  {
    logName = name;
    
    setLevel(3);
    
    String lvl = getStringProperty("org.apache.commons.logging.simplelog.log." + logName);
    int i = String.valueOf(name).lastIndexOf(".");
    while ((null == lvl) && (i > -1))
    {
      name = name.substring(0, i);
      lvl = getStringProperty("org.apache.commons.logging.simplelog.log." + name);
      i = String.valueOf(name).lastIndexOf(".");
    }
    if (null == lvl) {
      lvl = getStringProperty("org.apache.commons.logging.simplelog.defaultlog");
    }
    if ("all".equalsIgnoreCase(lvl)) {
      setLevel(0);
    } else if ("trace".equalsIgnoreCase(lvl)) {
      setLevel(1);
    } else if ("debug".equalsIgnoreCase(lvl)) {
      setLevel(2);
    } else if ("info".equalsIgnoreCase(lvl)) {
      setLevel(3);
    } else if ("warn".equalsIgnoreCase(lvl)) {
      setLevel(4);
    } else if ("error".equalsIgnoreCase(lvl)) {
      setLevel(5);
    } else if ("fatal".equalsIgnoreCase(lvl)) {
      setLevel(6);
    } else if ("off".equalsIgnoreCase(lvl)) {
      setLevel(7);
    }
  }
  
  public void setLevel(int currentLogLevel)
  {
    this.currentLogLevel = currentLogLevel;
  }
  
  public int getLevel()
  {
    return currentLogLevel;
  }
  
  protected void log(int type, Object message, Throwable t)
  {
    StringBuffer buf = new StringBuffer();
    if (showDateTime)
    {
      Date now = new Date();
      String dateText;
      synchronized (dateFormatter)
      {
        dateText = dateFormatter.format(now);
      }
      buf.append(dateText);
      buf.append(" ");
    }
    switch (type)
    {
    case 1: 
      buf.append("[TRACE] "); break;
    case 2: 
      buf.append("[DEBUG] "); break;
    case 3: 
      buf.append("[INFO] "); break;
    case 4: 
      buf.append("[WARN] "); break;
    case 5: 
      buf.append("[ERROR] "); break;
    case 6: 
      buf.append("[FATAL] ");
    }
    if (showShortName)
    {
      if (shortLogName == null)
      {
        String slName = logName.substring(logName.lastIndexOf(".") + 1);
        shortLogName = slName.substring(slName.lastIndexOf("/") + 1);
      }
      buf.append(String.valueOf(shortLogName)).append(" - ");
    }
    else if (showLogName)
    {
      buf.append(String.valueOf(logName)).append(" - ");
    }
    buf.append(String.valueOf(message));
    if (t != null)
    {
      buf.append(" <");
      buf.append(t.toString());
      buf.append(">");
      
      StringWriter sw = new StringWriter(1024);
      PrintWriter pw = new PrintWriter(sw);
      t.printStackTrace(pw);
      pw.close();
      buf.append(sw.toString());
    }
    write(buf);
  }
  
  protected void write(StringBuffer buffer)
  {
    System.err.println(buffer.toString());
  }
  
  protected boolean isLevelEnabled(int logLevel)
  {
    return logLevel >= currentLogLevel;
  }
  
  public final void debug(Object message)
  {
    if (isLevelEnabled(2)) {
      log(2, message, null);
    }
  }
  
  public final void debug(Object message, Throwable t)
  {
    if (isLevelEnabled(2)) {
      log(2, message, t);
    }
  }
  
  public final void trace(Object message)
  {
    if (isLevelEnabled(1)) {
      log(1, message, null);
    }
  }
  
  public final void trace(Object message, Throwable t)
  {
    if (isLevelEnabled(1)) {
      log(1, message, t);
    }
  }
  
  public final void info(Object message)
  {
    if (isLevelEnabled(3)) {
      log(3, message, null);
    }
  }
  
  public final void info(Object message, Throwable t)
  {
    if (isLevelEnabled(3)) {
      log(3, message, t);
    }
  }
  
  public final void warn(Object message)
  {
    if (isLevelEnabled(4)) {
      log(4, message, null);
    }
  }
  
  public final void warn(Object message, Throwable t)
  {
    if (isLevelEnabled(4)) {
      log(4, message, t);
    }
  }
  
  public final void error(Object message)
  {
    if (isLevelEnabled(5)) {
      log(5, message, null);
    }
  }
  
  public final void error(Object message, Throwable t)
  {
    if (isLevelEnabled(5)) {
      log(5, message, t);
    }
  }
  
  public final void fatal(Object message)
  {
    if (isLevelEnabled(6)) {
      log(6, message, null);
    }
  }
  
  public final void fatal(Object message, Throwable t)
  {
    if (isLevelEnabled(6)) {
      log(6, message, t);
    }
  }
  
  public final boolean isDebugEnabled()
  {
    return isLevelEnabled(2);
  }
  
  public final boolean isErrorEnabled()
  {
    return isLevelEnabled(5);
  }
  
  public final boolean isFatalEnabled()
  {
    return isLevelEnabled(6);
  }
  
  public final boolean isInfoEnabled()
  {
    return isLevelEnabled(3);
  }
  
  public final boolean isTraceEnabled()
  {
    return isLevelEnabled(1);
  }
  
  public final boolean isWarnEnabled()
  {
    return isLevelEnabled(4);
  }
  
  private static ClassLoader getContextClassLoader()
  {
    ClassLoader classLoader = null;
    try
    {
      Method method = Thread.class.getMethod("getContextClassLoader", (Class[])null);
      try
      {
        classLoader = (ClassLoader)method.invoke(Thread.currentThread(), (Class[])null);
      }
      catch (IllegalAccessException e) {}catch (InvocationTargetException e)
      {
        if (!(e.getTargetException() instanceof SecurityException)) {
          throw new LogConfigurationException("Unexpected InvocationTargetException", e.getTargetException());
        }
      }
    }
    catch (NoSuchMethodException e) {}
    if (classLoader == null) {
      classLoader = SimpleLog.class.getClassLoader();
    }
    return classLoader;
  }
  
  private static InputStream getResourceAsStream(String name)
  {
    (InputStream)AccessController.doPrivileged(new PrivilegedAction()
    {
      private final String val$name;
      
      public Object run()
      {
        ClassLoader threadCL = SimpleLog.access$000();
        if (threadCL != null) {
          return threadCL.getResourceAsStream(val$name);
        }
        return ClassLoader.getSystemResourceAsStream(val$name);
      }
    });
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.SimpleLog
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.io.Serializable;
import java.lang.reflect.Field;
import org.apache.commons.logging.Log;
import org.apache.log4j.Category;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;

public class Log4JLogger
  implements Log, Serializable
{
  private static final long serialVersionUID = 5160705895411730424L;
  private static final String FQCN = Log4JLogger.class.getName();
  private volatile transient Logger logger = null;
  private final String name;
  private static final Priority traceLevel;
  
  static
  {
    if (!Priority.class.isAssignableFrom(Level.class)) {
      throw new InstantiationError("Log4J 1.2 not available");
    }
    Priority _traceLevel;
    try
    {
      _traceLevel = (Priority)Level.class.getDeclaredField("TRACE").get(null);
    }
    catch (Exception ex)
    {
      _traceLevel = Level.DEBUG;
    }
    traceLevel = _traceLevel;
  }
  
  public Log4JLogger()
  {
    name = null;
  }
  
  public Log4JLogger(String name)
  {
    this.name = name;
    logger = getLogger();
  }
  
  public Log4JLogger(Logger logger)
  {
    if (logger == null) {
      throw new IllegalArgumentException("Warning - null logger in constructor; possible log4j misconfiguration.");
    }
    name = logger.getName();
    this.logger = logger;
  }
  
  public void trace(Object message)
  {
    getLogger().log(FQCN, traceLevel, message, null);
  }
  
  public void trace(Object message, Throwable t)
  {
    getLogger().log(FQCN, traceLevel, message, t);
  }
  
  public void debug(Object message)
  {
    getLogger().log(FQCN, Level.DEBUG, message, null);
  }
  
  public void debug(Object message, Throwable t)
  {
    getLogger().log(FQCN, Level.DEBUG, message, t);
  }
  
  public void info(Object message)
  {
    getLogger().log(FQCN, Level.INFO, message, null);
  }
  
  public void info(Object message, Throwable t)
  {
    getLogger().log(FQCN, Level.INFO, message, t);
  }
  
  public void warn(Object message)
  {
    getLogger().log(FQCN, Level.WARN, message, null);
  }
  
  public void warn(Object message, Throwable t)
  {
    getLogger().log(FQCN, Level.WARN, message, t);
  }
  
  public void error(Object message)
  {
    getLogger().log(FQCN, Level.ERROR, message, null);
  }
  
  public void error(Object message, Throwable t)
  {
    getLogger().log(FQCN, Level.ERROR, message, t);
  }
  
  public void fatal(Object message)
  {
    getLogger().log(FQCN, Level.FATAL, message, null);
  }
  
  public void fatal(Object message, Throwable t)
  {
    getLogger().log(FQCN, Level.FATAL, message, t);
  }
  
  public Logger getLogger()
  {
    Logger result = logger;
    if (result == null) {
      synchronized (this)
      {
        result = logger;
        if (result == null) {
          logger = (result = Logger.getLogger(name));
        }
      }
    }
    return result;
  }
  
  public boolean isDebugEnabled()
  {
    return getLogger().isDebugEnabled();
  }
  
  public boolean isErrorEnabled()
  {
    return getLogger().isEnabledFor(Level.ERROR);
  }
  
  public boolean isFatalEnabled()
  {
    return getLogger().isEnabledFor(Level.FATAL);
  }
  
  public boolean isInfoEnabled()
  {
    return getLogger().isInfoEnabled();
  }
  
  public boolean isTraceEnabled()
  {
    return getLogger().isEnabledFor(traceLevel);
  }
  
  public boolean isWarnEnabled()
  {
    return getLogger().isEnabledFor(Level.WARN);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.Log4JLogger
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public final class WeakHashtable
  extends Hashtable
{
  private static final long serialVersionUID = -1546036869799732453L;
  private static final int MAX_CHANGES_BEFORE_PURGE = 100;
  private static final int PARTIAL_PURGE_COUNT = 10;
  private final ReferenceQueue queue = new ReferenceQueue();
  private int changeCount = 0;
  
  public boolean containsKey(Object key)
  {
    Referenced referenced = new Referenced(key, null);
    return super.containsKey(referenced);
  }
  
  public Enumeration elements()
  {
    purge();
    return super.elements();
  }
  
  public Set entrySet()
  {
    purge();
    Set referencedEntries = super.entrySet();
    Set unreferencedEntries = new HashSet();
    for (Iterator it = referencedEntries.iterator(); it.hasNext();)
    {
      Map.Entry entry = (Map.Entry)it.next();
      Referenced referencedKey = (Referenced)entry.getKey();
      Object key = referencedKey.getValue();
      Object value = entry.getValue();
      if (key != null)
      {
        Entry dereferencedEntry = new Entry(key, value, null);
        unreferencedEntries.add(dereferencedEntry);
      }
    }
    return unreferencedEntries;
  }
  
  public Object get(Object key)
  {
    Referenced referenceKey = new Referenced(key, null);
    return super.get(referenceKey);
  }
  
  public Enumeration keys()
  {
    purge();
    Enumeration enumer = super.keys();
    new Enumeration()
    {
      private final Enumeration val$enumer;
      
      public boolean hasMoreElements()
      {
        return val$enumer.hasMoreElements();
      }
      
      public Object nextElement()
      {
        WeakHashtable.Referenced nextReference = (WeakHashtable.Referenced)val$enumer.nextElement();
        return nextReference.getValue();
      }
    };
  }
  
  public Set keySet()
  {
    purge();
    Set referencedKeys = super.keySet();
    Set unreferencedKeys = new HashSet();
    for (Iterator it = referencedKeys.iterator(); it.hasNext();)
    {
      Referenced referenceKey = (Referenced)it.next();
      Object keyValue = referenceKey.getValue();
      if (keyValue != null) {
        unreferencedKeys.add(keyValue);
      }
    }
    return unreferencedKeys;
  }
  
  public synchronized Object put(Object key, Object value)
  {
    if (key == null) {
      throw new NullPointerException("Null keys are not allowed");
    }
    if (value == null) {
      throw new NullPointerException("Null values are not allowed");
    }
    if (changeCount++ > 100)
    {
      purge();
      changeCount = 0;
    }
    else if (changeCount % 10 == 0)
    {
      purgeOne();
    }
    Referenced keyRef = new Referenced(key, queue, null);
    return super.put(keyRef, value);
  }
  
  public void putAll(Map t)
  {
    Iterator it;
    if (t != null)
    {
      Set entrySet = t.entrySet();
      for (it = entrySet.iterator(); it.hasNext();)
      {
        Map.Entry entry = (Map.Entry)it.next();
        put(entry.getKey(), entry.getValue());
      }
    }
  }
  
  public Collection values()
  {
    purge();
    return super.values();
  }
  
  public synchronized Object remove(Object key)
  {
    if (changeCount++ > 100)
    {
      purge();
      changeCount = 0;
    }
    else if (changeCount % 10 == 0)
    {
      purgeOne();
    }
    return super.remove(new Referenced(key, null));
  }
  
  public boolean isEmpty()
  {
    purge();
    return super.isEmpty();
  }
  
  public int size()
  {
    purge();
    return super.size();
  }
  
  public String toString()
  {
    purge();
    return super.toString();
  }
  
  protected void rehash()
  {
    purge();
    super.rehash();
  }
  
  private void purge()
  {
    List toRemove = new ArrayList();
    synchronized (queue)
    {
      WeakKey key;
      while ((key = (WeakKey)queue.poll()) != null) {
        toRemove.add(key.getReferenced());
      }
    }
    int size = toRemove.size();
    for (int i = 0; i < size; i++) {
      super.remove(toRemove.get(i));
    }
  }
  
  private void purgeOne()
  {
    synchronized (queue)
    {
      WeakKey key = (WeakKey)queue.poll();
      if (key != null) {
        super.remove(key.getReferenced());
      }
    }
  }
  
  private static final class Entry
    implements Map.Entry
  {
    private final Object key;
    private final Object value;
    
    Entry(Object x0, Object x1, WeakHashtable.1 x2)
    {
      this(x0, x1);
    }
    
    private Entry(Object key, Object value)
    {
      this.key = key;
      this.value = value;
    }
    
    public boolean equals(Object o)
    {
      boolean result = false;
      if ((o != null) && ((o instanceof Map.Entry)))
      {
        Map.Entry entry = (Map.Entry)o;
        result = (getKey() == null ? entry.getKey() == null : getKey().equals(entry.getKey())) && (getValue() == null ? entry.getValue() == null : getValue().equals(entry.getValue()));
      }
      return result;
    }
    
    public int hashCode()
    {
      return (getKey() == null ? 0 : getKey().hashCode()) ^ (getValue() == null ? 0 : getValue().hashCode());
    }
    
    public Object setValue(Object value)
    {
      throw new UnsupportedOperationException("Entry.setValue is not supported.");
    }
    
    public Object getValue()
    {
      return value;
    }
    
    public Object getKey()
    {
      return key;
    }
  }
  
  private static final class Referenced
  {
    private final WeakReference reference;
    private final int hashCode;
    
    Referenced(Object x0, WeakHashtable.1 x1)
    {
      this(x0);
    }
    
    Referenced(Object x0, ReferenceQueue x1, WeakHashtable.1 x2)
    {
      this(x0, x1);
    }
    
    private Referenced(Object referant)
    {
      reference = new WeakReference(referant);
      
      hashCode = referant.hashCode();
    }
    
    private Referenced(Object key, ReferenceQueue queue)
    {
      reference = new WeakHashtable.WeakKey(key, queue, this, null);
      
      hashCode = key.hashCode();
    }
    
    public int hashCode()
    {
      return hashCode;
    }
    
    private Object getValue()
    {
      return reference.get();
    }
    
    public boolean equals(Object o)
    {
      boolean result = false;
      if ((o instanceof Referenced))
      {
        Referenced otherKey = (Referenced)o;
        Object thisKeyValue = getValue();
        Object otherKeyValue = otherKey.getValue();
        if (thisKeyValue == null)
        {
          result = otherKeyValue == null;
          
          result = (result) && (hashCode() == otherKey.hashCode());
        }
        else
        {
          result = thisKeyValue.equals(otherKeyValue);
        }
      }
      return result;
    }
  }
  
  private static final class WeakKey
    extends WeakReference
  {
    private final WeakHashtable.Referenced referenced;
    
    WeakKey(Object x0, ReferenceQueue x1, WeakHashtable.Referenced x2, WeakHashtable.1 x3)
    {
      this(x0, x1, x2);
    }
    
    private WeakKey(Object key, ReferenceQueue queue, WeakHashtable.Referenced referenced)
    {
      super(queue);
      this.referenced = referenced;
    }
    
    private WeakHashtable.Referenced getReferenced()
    {
      return referenced;
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.WeakHashtable
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.util.Enumeration;

class WeakHashtable$1
  implements Enumeration
{
  private final Enumeration val$enumer;
  private final WeakHashtable this$0;
  
  WeakHashtable$1(WeakHashtable paramWeakHashtable, Enumeration paramEnumeration)
  {
    this$0 = paramWeakHashtable;val$enumer = paramEnumeration;
  }
  
  public boolean hasMoreElements()
  {
    return val$enumer.hasMoreElements();
  }
  
  public Object nextElement()
  {
    WeakHashtable.Referenced nextReference = (WeakHashtable.Referenced)val$enumer.nextElement();
    return WeakHashtable.Referenced.access$100(nextReference);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.WeakHashtable.1
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.logging.Log;

public class Jdk14Logger
  implements Log, Serializable
{
  private static final long serialVersionUID = 4784713551416303804L;
  protected static final Level dummyLevel = Level.FINE;
  
  public Jdk14Logger(String name)
  {
    this.name = name;
    logger = getLogger();
  }
  
  protected transient Logger logger = null;
  protected String name = null;
  
  protected void log(Level level, String msg, Throwable ex)
  {
    Logger logger = getLogger();
    if (logger.isLoggable(level))
    {
      Throwable dummyException = new Throwable();
      StackTraceElement[] locations = dummyException.getStackTrace();
      
      String cname = name;
      String method = "unknown";
      if ((locations != null) && (locations.length > 2))
      {
        StackTraceElement caller = locations[2];
        method = caller.getMethodName();
      }
      if (ex == null) {
        logger.logp(level, cname, method, msg);
      } else {
        logger.logp(level, cname, method, msg, ex);
      }
    }
  }
  
  public void debug(Object message)
  {
    log(Level.FINE, String.valueOf(message), null);
  }
  
  public void debug(Object message, Throwable exception)
  {
    log(Level.FINE, String.valueOf(message), exception);
  }
  
  public void error(Object message)
  {
    log(Level.SEVERE, String.valueOf(message), null);
  }
  
  public void error(Object message, Throwable exception)
  {
    log(Level.SEVERE, String.valueOf(message), exception);
  }
  
  public void fatal(Object message)
  {
    log(Level.SEVERE, String.valueOf(message), null);
  }
  
  public void fatal(Object message, Throwable exception)
  {
    log(Level.SEVERE, String.valueOf(message), exception);
  }
  
  public Logger getLogger()
  {
    if (logger == null) {
      logger = Logger.getLogger(name);
    }
    return logger;
  }
  
  public void info(Object message)
  {
    log(Level.INFO, String.valueOf(message), null);
  }
  
  public void info(Object message, Throwable exception)
  {
    log(Level.INFO, String.valueOf(message), exception);
  }
  
  public boolean isDebugEnabled()
  {
    return getLogger().isLoggable(Level.FINE);
  }
  
  public boolean isErrorEnabled()
  {
    return getLogger().isLoggable(Level.SEVERE);
  }
  
  public boolean isFatalEnabled()
  {
    return getLogger().isLoggable(Level.SEVERE);
  }
  
  public boolean isInfoEnabled()
  {
    return getLogger().isLoggable(Level.INFO);
  }
  
  public boolean isTraceEnabled()
  {
    return getLogger().isLoggable(Level.FINEST);
  }
  
  public boolean isWarnEnabled()
  {
    return getLogger().isLoggable(Level.WARNING);
  }
  
  public void trace(Object message)
  {
    log(Level.FINEST, String.valueOf(message), null);
  }
  
  public void trace(Object message, Throwable exception)
  {
    log(Level.FINEST, String.valueOf(message), exception);
  }
  
  public void warn(Object message)
  {
    log(Level.WARNING, String.valueOf(message), null);
  }
  
  public void warn(Object message, Throwable exception)
  {
    log(Level.WARNING, String.valueOf(message), exception);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.Jdk14Logger
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.logging.LogFactory;

public class ServletContextCleaner
  implements ServletContextListener
{
  private static final Class[] RELEASE_SIGNATURE = { ClassLoader.class };
  
  public void contextDestroyed(ServletContextEvent sce)
  {
    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    
    Object[] params = new Object[1];
    params[0] = tccl;
    
    ClassLoader loader = tccl;
    while (loader != null) {
      try
      {
        Class logFactoryClass = loader.loadClass("org.apache.commons.logging.LogFactory");
        Method releaseMethod = logFactoryClass.getMethod("release", RELEASE_SIGNATURE);
        releaseMethod.invoke(null, params);
        loader = logFactoryClass.getClassLoader().getParent();
      }
      catch (ClassNotFoundException ex)
      {
        loader = null;
      }
      catch (NoSuchMethodException ex)
      {
        System.err.println("LogFactory instance found which does not support release method!");
        loader = null;
      }
      catch (IllegalAccessException ex)
      {
        System.err.println("LogFactory instance found which is not accessable!");
        loader = null;
      }
      catch (InvocationTargetException ex)
      {
        System.err.println("LogFactory instance release method failed!");
        loader = null;
      }
    }
    LogFactory.release(tccl);
  }
  
  public void contextInitialized(ServletContextEvent sce) {}
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.ServletContextCleaner
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;

final class WeakHashtable$WeakKey
  extends WeakReference
{
  private final WeakHashtable.Referenced referenced;
  
  WeakHashtable$WeakKey(Object x0, ReferenceQueue x1, WeakHashtable.Referenced x2, WeakHashtable.1 x3)
  {
    this(x0, x1, x2);
  }
  
  private WeakHashtable$WeakKey(Object key, ReferenceQueue queue, WeakHashtable.Referenced referenced)
  {
    super(key, queue);
    this.referenced = referenced;
  }
  
  private WeakHashtable.Referenced getReferenced()
  {
    return referenced;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.WeakHashtable.WeakKey
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.io.Serializable;
import org.apache.commons.logging.Log;

public class NoOpLog
  implements Log, Serializable
{
  private static final long serialVersionUID = 561423906191706148L;
  
  public NoOpLog() {}
  
  public NoOpLog(String name) {}
  
  public void trace(Object message) {}
  
  public void trace(Object message, Throwable t) {}
  
  public void debug(Object message) {}
  
  public void debug(Object message, Throwable t) {}
  
  public void info(Object message) {}
  
  public void info(Object message, Throwable t) {}
  
  public void warn(Object message) {}
  
  public void warn(Object message, Throwable t) {}
  
  public void error(Object message) {}
  
  public void error(Object message, Throwable t) {}
  
  public void fatal(Object message) {}
  
  public void fatal(Object message, Throwable t) {}
  
  public final boolean isDebugEnabled()
  {
    return false;
  }
  
  public final boolean isErrorEnabled()
  {
    return false;
  }
  
  public final boolean isFatalEnabled()
  {
    return false;
  }
  
  public final boolean isInfoEnabled()
  {
    return false;
  }
  
  public final boolean isTraceEnabled()
  {
    return false;
  }
  
  public final boolean isWarnEnabled()
  {
    return false;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.NoOpLog
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.io.Serializable;
import org.apache.commons.logging.Log;
import org.apache.log.Hierarchy;
import org.apache.log.Logger;

public class LogKitLogger
  implements Log, Serializable
{
  private static final long serialVersionUID = 3768538055836059519L;
  protected volatile transient Logger logger = null;
  protected String name = null;
  
  public LogKitLogger(String name)
  {
    this.name = name;
    logger = getLogger();
  }
  
  public Logger getLogger()
  {
    Logger result = logger;
    if (result == null) {
      synchronized (this)
      {
        result = logger;
        if (result == null) {
          logger = (result = Hierarchy.getDefaultHierarchy().getLoggerFor(name));
        }
      }
    }
    return result;
  }
  
  public void trace(Object message)
  {
    debug(message);
  }
  
  public void trace(Object message, Throwable t)
  {
    debug(message, t);
  }
  
  public void debug(Object message)
  {
    if (message != null) {
      getLogger().debug(String.valueOf(message));
    }
  }
  
  public void debug(Object message, Throwable t)
  {
    if (message != null) {
      getLogger().debug(String.valueOf(message), t);
    }
  }
  
  public void info(Object message)
  {
    if (message != null) {
      getLogger().info(String.valueOf(message));
    }
  }
  
  public void info(Object message, Throwable t)
  {
    if (message != null) {
      getLogger().info(String.valueOf(message), t);
    }
  }
  
  public void warn(Object message)
  {
    if (message != null) {
      getLogger().warn(String.valueOf(message));
    }
  }
  
  public void warn(Object message, Throwable t)
  {
    if (message != null) {
      getLogger().warn(String.valueOf(message), t);
    }
  }
  
  public void error(Object message)
  {
    if (message != null) {
      getLogger().error(String.valueOf(message));
    }
  }
  
  public void error(Object message, Throwable t)
  {
    if (message != null) {
      getLogger().error(String.valueOf(message), t);
    }
  }
  
  public void fatal(Object message)
  {
    if (message != null) {
      getLogger().fatalError(String.valueOf(message));
    }
  }
  
  public void fatal(Object message, Throwable t)
  {
    if (message != null) {
      getLogger().fatalError(String.valueOf(message), t);
    }
  }
  
  public boolean isDebugEnabled()
  {
    return getLogger().isDebugEnabled();
  }
  
  public boolean isErrorEnabled()
  {
    return getLogger().isErrorEnabled();
  }
  
  public boolean isFatalEnabled()
  {
    return getLogger().isFatalErrorEnabled();
  }
  
  public boolean isInfoEnabled()
  {
    return getLogger().isInfoEnabled();
  }
  
  public boolean isTraceEnabled()
  {
    return getLogger().isDebugEnabled();
  }
  
  public boolean isWarnEnabled()
  {
    return getLogger().isWarnEnabled();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.LogKitLogger
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.security.PrivilegedAction;

class LogFactoryImpl$3
  implements PrivilegedAction
{
  private final ClassLoader val$cl;
  private final LogFactoryImpl this$0;
  
  LogFactoryImpl$3(LogFactoryImpl paramLogFactoryImpl, ClassLoader paramClassLoader)
  {
    this$0 = paramLogFactoryImpl;val$cl = paramClassLoader;
  }
  
  public Object run()
  {
    return val$cl.getParent();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.LogFactoryImpl.3
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.security.PrivilegedAction;

final class LogFactoryImpl$1
  implements PrivilegedAction
{
  public Object run()
  {
    return LogFactoryImpl.access$000();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.LogFactoryImpl.1
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;

final class WeakHashtable$Referenced
{
  private final WeakReference reference;
  private final int hashCode;
  
  WeakHashtable$Referenced(Object x0, WeakHashtable.1 x1)
  {
    this(x0);
  }
  
  WeakHashtable$Referenced(Object x0, ReferenceQueue x1, WeakHashtable.1 x2)
  {
    this(x0, x1);
  }
  
  private WeakHashtable$Referenced(Object referant)
  {
    reference = new WeakReference(referant);
    
    hashCode = referant.hashCode();
  }
  
  private WeakHashtable$Referenced(Object key, ReferenceQueue queue)
  {
    reference = new WeakHashtable.WeakKey(key, queue, this, null);
    
    hashCode = key.hashCode();
  }
  
  public int hashCode()
  {
    return hashCode;
  }
  
  private Object getValue()
  {
    return reference.get();
  }
  
  public boolean equals(Object o)
  {
    boolean result = false;
    if ((o instanceof Referenced))
    {
      Referenced otherKey = (Referenced)o;
      Object thisKeyValue = getValue();
      Object otherKeyValue = otherKey.getValue();
      if (thisKeyValue == null)
      {
        result = otherKeyValue == null;
        
        result = (result) && (hashCode() == otherKey.hashCode());
      }
      else
      {
        result = thisKeyValue.equals(otherKeyValue);
      }
    }
    return result;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.WeakHashtable.Referenced
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.security.PrivilegedAction;

final class SimpleLog$1
  implements PrivilegedAction
{
  private final String val$name;
  
  SimpleLog$1(String paramString)
  {
    val$name = paramString;
  }
  
  public Object run()
  {
    ClassLoader threadCL = SimpleLog.access$000();
    if (threadCL != null) {
      return threadCL.getResourceAsStream(val$name);
    }
    return ClassLoader.getSystemResourceAsStream(val$name);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.SimpleLog.1
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import org.apache.commons.logging.Log;

public class Jdk13LumberjackLogger
  implements Log, Serializable
{
  private static final long serialVersionUID = -8649807923527610591L;
  protected transient Logger logger = null;
  protected String name = null;
  private String sourceClassName = "unknown";
  private String sourceMethodName = "unknown";
  private boolean classAndMethodFound = false;
  protected static final Level dummyLevel = Level.FINE;
  
  public Jdk13LumberjackLogger(String name)
  {
    this.name = name;
    logger = getLogger();
  }
  
  private void log(Level level, String msg, Throwable ex)
  {
    if (getLogger().isLoggable(level))
    {
      LogRecord record = new LogRecord(level, msg);
      if (!classAndMethodFound) {
        getClassAndMethod();
      }
      record.setSourceClassName(sourceClassName);
      record.setSourceMethodName(sourceMethodName);
      if (ex != null) {
        record.setThrown(ex);
      }
      getLogger().log(record);
    }
  }
  
  private void getClassAndMethod()
  {
    try
    {
      Throwable throwable = new Throwable();
      throwable.fillInStackTrace();
      StringWriter stringWriter = new StringWriter();
      PrintWriter printWrite
1 2 3

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd