org.apache.commons.logging_1.0.4.v201101211617

16:41:03.146 INFO  jd.cli.Main - Decompiling org.apache.commons.logging_1.0.4.v201101211617.jar
package org.apache.commons.logging;

public abstract interface Log
{
  public abstract boolean isDebugEnabled();
  
  public abstract boolean isErrorEnabled();
  
  public abstract boolean isFatalEnabled();
  
  public abstract boolean isInfoEnabled();
  
  public abstract boolean isTraceEnabled();
  
  public abstract boolean isWarnEnabled();
  
  public abstract void trace(Object paramObject);
  
  public abstract void trace(Object paramObject, Throwable paramThrowable);
  
  public abstract void debug(Object paramObject);
  
  public abstract void debug(Object paramObject, Throwable paramThrowable);
  
  public abstract void info(Object paramObject);
  
  public abstract void info(Object paramObject, Throwable paramThrowable);
  
  public abstract void warn(Object paramObject);
  
  public abstract void warn(Object paramObject, Throwable paramThrowable);
  
  public abstract void error(Object paramObject);
  
  public abstract void error(Object paramObject, Throwable paramThrowable);
  
  public abstract void fatal(Object paramObject);
  
  public abstract void fatal(Object paramObject, Throwable paramThrowable);
}

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

public class LogConfigurationException
  extends RuntimeException
{
  public LogConfigurationException() {}
  
  public LogConfigurationException(String message)
  {
    super(message);
  }
  
  public LogConfigurationException(Throwable cause)
  {
    this(cause == null ? null : cause.toString(), cause);
  }
  
  public LogConfigurationException(String message, Throwable cause)
  {
    super(message + " (Caused by " + cause + ")");
    this.cause = cause;
  }
  
  protected Throwable cause = null;
  
  public Throwable getCause()
  {
    return cause;
  }
}

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

import java.security.PrivilegedAction;

class LogFactory$1
  implements PrivilegedAction
{
  public Object run()
  {
    return LogFactory.getContextClassLoader();
  }
}

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

import java.security.PrivilegedAction;

class LogFactory$2
  implements PrivilegedAction
{
  private final ClassLoader val$classLoader;
  private final String val$factoryClass;
  
  LogFactory$2(ClassLoader val$classLoader, String val$factoryClass)
  {
    this.val$classLoader = val$classLoader;this.val$factoryClass = val$factoryClass;
  }
  
  public Object run()
  {
    Class logFactoryClass = null;
    try
    {
      if (val$classLoader != null) {
        try
        {
          logFactoryClass = val$classLoader.loadClass(val$factoryClass);
          return (LogFactory)logFactoryClass.newInstance();
        }
        catch (ClassNotFoundException ex)
        {
          if (val$classLoader == LogFactory.class.getClassLoader()) {
            throw ex;
          }
        }
        catch (NoClassDefFoundError e)
        {
          if (val$classLoader == LogFactory.class.getClassLoader()) {
            throw e;
          }
        }
        catch (ClassCastException e)
        {
          if (val$classLoader == LogFactory.class.getClassLoader()) {
            throw e;
          }
        }
      }
      logFactoryClass = Class.forName(val$factoryClass);
      return (LogFactory)logFactoryClass.newInstance();
    }
    catch (Exception e)
    {
      if ((logFactoryClass != null) && (!LogFactory.class.isAssignableFrom(logFactoryClass))) {
        return new LogConfigurationException("The chosen LogFactory implementation does not extend LogFactory. Please check your configuration.", e);
      }
      return new LogConfigurationException(e);
    }
  }
}

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

import java.security.PrivilegedAction;

class LogFactory$3
  implements PrivilegedAction
{
  private final ClassLoader val$loader;
  private final String val$name;
  
  LogFactory$3(ClassLoader val$loader, String val$name)
  {
    this.val$loader = val$loader;this.val$name = val$name;
  }
  
  public Object run()
  {
    if (val$loader != null) {
      return val$loader.getResourceAsStream(val$name);
    }
    return ClassLoader.getSystemResourceAsStream(val$name);
  }
}

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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;

public abstract class LogFactory
{
  public static final String FACTORY_PROPERTY = "org.apache.commons.logging.LogFactory";
  public static final String FACTORY_DEFAULT = "org.apache.commons.logging.impl.LogFactoryImpl";
  public static final String FACTORY_PROPERTIES = "commons-logging.properties";
  protected static final String SERVICE_ID = "META-INF/services/org.apache.commons.logging.LogFactory";
  protected static Hashtable factories = new Hashtable();
  
  public abstract Object getAttribute(String paramString);
  
  public abstract String[] getAttributeNames();
  
  public abstract Log getInstance(Class paramClass)
    throws LogConfigurationException;
  
  public abstract Log getInstance(String paramString)
    throws LogConfigurationException;
  
  public abstract void release();
  
  public abstract void removeAttribute(String paramString);
  
  public abstract void setAttribute(String paramString, Object paramObject);
  
  public static LogFactory getFactory()
    throws LogConfigurationException
  {
    ClassLoader contextClassLoader = (ClassLoader)AccessController.doPrivileged(new PrivilegedAction()
    {
      public Object run()
      {
        return LogFactory.getContextClassLoader();
      }
    });
    LogFactory factory = getCachedFactory(contextClassLoader);
    if (factory != null) {
      return factory;
    }
    Properties props = null;
    try
    {
      InputStream stream = getResourceAsStream(contextClassLoader, "commons-logging.properties");
      if (stream != null)
      {
        props = new Properties();
        props.load(stream);
        stream.close();
      }
    }
    catch (IOException e) {}catch (SecurityException e) {}
    try
    {
      String factoryClass = System.getProperty("org.apache.commons.logging.LogFactory");
      if (factoryClass != null) {
        factory = newFactory(factoryClass, contextClassLoader);
      }
    }
    catch (SecurityException e) {}
    if (factory == null) {
      try
      {
        InputStream is = getResourceAsStream(contextClassLoader, "META-INF/services/org.apache.commons.logging.LogFactory");
        if (is != null)
        {
          BufferedReader rd;
          try
          {
            rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
          }
          catch (UnsupportedEncodingException e)
          {
            rd = new BufferedReader(new InputStreamReader(is));
          }
          String factoryClassName = rd.readLine();
          rd.close();
          if ((factoryClassName != null) && (!"".equals(factoryClassName))) {
            factory = newFactory(factoryClassName, contextClassLoader);
          }
        }
      }
      catch (Exception ex) {}
    }
    if ((factory == null) && (props != null))
    {
      String factoryClass = props.getProperty("org.apache.commons.logging.LogFactory");
      if (factoryClass != null) {
        factory = newFactory(factoryClass, contextClassLoader);
      }
    }
    if (factory == null) {
      factory = newFactory("org.apache.commons.logging.impl.LogFactoryImpl", LogFactory.class.getClassLoader());
    }
    if (factory != null)
    {
      cacheFactory(contextClassLoader, factory);
      if (props != null)
      {
        Enumeration names = props.propertyNames();
        while (names.hasMoreElements())
        {
          String name = (String)names.nextElement();
          String value = props.getProperty(name);
          factory.setAttribute(name, value);
        }
      }
    }
    return factory;
  }
  
  public static Log getLog(Class clazz)
    throws LogConfigurationException
  {
    return getFactory().getInstance(clazz);
  }
  
  public static Log getLog(String name)
    throws LogConfigurationException
  {
    return getFactory().getInstance(name);
  }
  
  public static void release(ClassLoader classLoader)
  {
    synchronized (factories)
    {
      LogFactory factory = (LogFactory)factories.get(classLoader);
      if (factory != null)
      {
        factory.release();
        factories.remove(classLoader);
      }
    }
  }
  
  public static void releaseAll()
  {
    synchronized (factories)
    {
      Enumeration elements = factories.elements();
      while (elements.hasMoreElements())
      {
        LogFactory element = (LogFactory)elements.nextElement();
        element.release();
      }
      factories.clear();
    }
  }
  
  protected static ClassLoader getContextClassLoader()
    throws LogConfigurationException
  {
    ClassLoader classLoader = null;
    try
    {
      Method method = Thread.class.getMethod("getContextClassLoader", null);
      try
      {
        classLoader = (ClassLoader)method.invoke(Thread.currentThread(), null);
      }
      catch (IllegalAccessException e)
      {
        throw new LogConfigurationException("Unexpected IllegalAccessException", e);
      }
      catch (InvocationTargetException e)
      {
        if (!(e.getTargetException() instanceof SecurityException)) {
          throw new LogConfigurationException("Unexpected InvocationTargetException", e.getTargetException());
        }
      }
    }
    catch (NoSuchMethodException e)
    {
      classLoader = LogFactory.class.getClassLoader();
    }
    return classLoader;
  }
  
  private static LogFactory getCachedFactory(ClassLoader contextClassLoader)
  {
    LogFactory factory = null;
    if (contextClassLoader != null) {
      factory = (LogFactory)factories.get(contextClassLoader);
    }
    return factory;
  }
  
  private static void cacheFactory(ClassLoader classLoader, LogFactory factory)
  {
    if ((classLoader != null) && (factory != null)) {
      factories.put(classLoader, factory);
    }
  }
  
  protected static LogFactory newFactory(String factoryClass, ClassLoader classLoader)
    throws LogConfigurationException
  {
    Object result = AccessController.doPrivileged(new PrivilegedAction()
    {
      private final ClassLoader val$classLoader;
      private final String val$factoryClass;
      
      public Object run()
      {
        Class logFactoryClass = null;
        try
        {
          if (val$classLoader != null) {
            try
            {
              logFactoryClass = val$classLoader.loadClass(val$factoryClass);
              return (LogFactory)logFactoryClass.newInstance();
            }
            catch (ClassNotFoundException ex)
            {
              if (val$classLoader == LogFactory.class.getClassLoader()) {
                throw ex;
              }
            }
            catch (NoClassDefFoundError e)
            {
              if (val$classLoader == LogFactory.class.getClassLoader()) {
                throw e;
              }
            }
            catch (ClassCastException e)
            {
              if (val$classLoader == LogFactory.class.getClassLoader()) {
                throw e;
              }
            }
          }
          logFactoryClass = Class.forName(val$factoryClass);
          return (LogFactory)logFactoryClass.newInstance();
        }
        catch (Exception e)
        {
          if ((logFactoryClass != null) && (!LogFactory.class.isAssignableFrom(logFactoryClass))) {
            return new LogConfigurationException("The chosen LogFactory implementation does not extend LogFactory. Please check your configuration.", e);
          }
          return new LogConfigurationException(e);
        }
      }
    });
    if ((result instanceof LogConfigurationException)) {
      throw ((LogConfigurationException)result);
    }
    return (LogFactory)result;
  }
  
  private static InputStream getResourceAsStream(ClassLoader loader, String name)
  {
    (InputStream)AccessController.doPrivileged(new PrivilegedAction()
    {
      private final ClassLoader val$loader;
      private final String val$name;
      
      public Object run()
      {
        if (val$loader != null) {
          return val$loader.getResourceAsStream(val$name);
        }
        return ClassLoader.getSystemResourceAsStream(val$name);
      }
    });
  }
}

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

import java.lang.reflect.Constructor;
import java.util.Hashtable;
import java.util.Set;
import org.apache.commons.logging.impl.NoOpLog;

/**
 * @deprecated
 */
public class LogSource
{
  protected static Hashtable logs = new Hashtable();
  protected static boolean log4jIsAvailable = false;
  protected static boolean jdk14IsAvailable = false;
  protected static Constructor logImplctor = null;
  
  static
  {
    try
    {
      if (null != Class.forName("org.apache.log4j.Logger")) {
        log4jIsAvailable = true;
      } else {
        log4jIsAvailable = false;
      }
    }
    catch (Throwable t)
    {
      log4jIsAvailable = false;
    }
    try
    {
      if ((null != Class.forName("java.util.logging.Logger")) && (null != Class.forName("org.apache.commons.logging.impl.Jdk14Logger"))) {
        jdk14IsAvailable = true;
      } else {
        jdk14IsAvailable = false;
      }
    }
    catch (Throwable t)
    {
      jdk14IsAvailable = false;
    }
    String name = null;
    try
    {
      name = System.getProperty("org.apache.commons.logging.log");
      if (name == null) {
        name = System.getProperty("org.apache.commons.logging.Log");
      }
    }
    catch (Throwable t) {}
    if (name != null) {
      try
      {
        setLogImplementation(name);
      }
      catch (Throwable t)
      {
        try
        {
          setLogImplementation("org.apache.commons.logging.impl.NoOpLog");
        }
        catch (Throwable u) {}
      }
    } else {
      try
      {
        if (log4jIsAvailable) {
          setLogImplementation("org.apache.commons.logging.impl.Log4JLogger");
        } else if (jdk14IsAvailable) {
          setLogImplementation("org.apache.commons.logging.impl.Jdk14Logger");
        } else {
          setLogImplementation("org.apache.commons.logging.impl.NoOpLog");
        }
      }
      catch (Throwable t)
      {
        try
        {
          setLogImplementation("org.apache.commons.logging.impl.NoOpLog");
        }
        catch (Throwable u) {}
      }
    }
  }
  
  public static void setLogImplementation(String classname)
    throws LinkageError, ExceptionInInitializerError, NoSuchMethodException, SecurityException, ClassNotFoundException
  {
    try
    {
      Class logclass = Class.forName(classname);
      Class[] argtypes = new Class[1];
      argtypes[0] = "".getClass();
      logImplctor = logclass.getConstructor(argtypes);
    }
    catch (Throwable t)
    {
      logImplctor = null;
    }
  }
  
  public static void setLogImplementation(Class logclass)
    throws LinkageError, ExceptionInInitializerError, NoSuchMethodException, SecurityException
  {
    Class[] argtypes = new Class[1];
    argtypes[0] = "".getClass();
    logImplctor = logclass.getConstructor(argtypes);
  }
  
  public static Log getInstance(String name)
  {
    Log log = (Log)logs.get(name);
    if (null == log)
    {
      log = makeNewLogInstance(name);
      logs.put(name, log);
    }
    return log;
  }
  
  public static Log getInstance(Class clazz)
  {
    return getInstance(clazz.getName());
  }
  
  public static Log makeNewLogInstance(String name)
  {
    Log log = null;
    try
    {
      Object[] args = new Object[1];
      args[0] = name;
      log = (Log)logImplctor.newInstance(args);
    }
    catch (Throwable t)
    {
      log = null;
    }
    if (null == log) {
      log = new NoOpLog(name);
    }
    return log;
  }
  
  public static String[] getLogNames()
  {
    return (String[])logs.keySet().toArray(new String[logs.size()]);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.LogSource
 * 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.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

public class AvalonLogger
  implements Log, Serializable
{
  private static Logger defaultLogger = null;
  private transient Logger logger = null;
  private String name = null;
  
  public AvalonLogger(Logger logger)
  {
    name = name;
    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 = getLogger();
  }
  
  public Logger getLogger()
  {
    if (logger == null) {
      logger = defaultLogger.getChildLogger(name);
    }
    return logger;
  }
  
  public static void setDefaultLogger(Logger logger)
  {
    defaultLogger = logger;
  }
  
  public void debug(Object o, Throwable t)
  {
    if (getLogger().isDebugEnabled()) {
      getLogger().debug(String.valueOf(o), t);
    }
  }
  
  public void debug(Object o)
  {
    if (getLogger().isDebugEnabled()) {
      getLogger().debug(String.valueOf(o));
    }
  }
  
  public void error(Object o, Throwable t)
  {
    if (getLogger().isErrorEnabled()) {
      getLogger().error(String.valueOf(o), t);
    }
  }
  
  public void error(Object o)
  {
    if (getLogger().isErrorEnabled()) {
      getLogger().error(String.valueOf(o));
    }
  }
  
  public void fatal(Object o, Throwable t)
  {
    if (getLogger().isFatalErrorEnabled()) {
      getLogger().fatalError(String.valueOf(o), t);
    }
  }
  
  public void fatal(Object o)
  {
    if (getLogger().isFatalErrorEnabled()) {
      getLogger().fatalError(String.valueOf(o));
    }
  }
  
  public void info(Object o, Throwable t)
  {
    if (getLogger().isInfoEnabled()) {
      getLogger().info(String.valueOf(o), t);
    }
  }
  
  public void info(Object o)
  {
    if (getLogger().isInfoEnabled()) {
      getLogger().info(String.valueOf(o));
    }
  }
  
  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 o, Throwable t)
  {
    if (getLogger().isDebugEnabled()) {
      getLogger().debug(String.valueOf(o), t);
    }
  }
  
  public void trace(Object o)
  {
    if (getLogger().isDebugEnabled()) {
      getLogger().debug(String.valueOf(o));
    }
  }
  
  public void warn(Object o, Throwable t)
  {
    if (getLogger().isWarnEnabled()) {
      getLogger().warn(String.valueOf(o), t);
    }
  }
  
  public void warn(Object o)
  {
    if (getLogger().isWarnEnabled()) {
      getLogger().warn(String.valueOf(o));
    }
  }
}

/* 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.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.logging.Log;

public class Jdk14Logger
  implements Log, Serializable
{
  public Jdk14Logger(String name)
  {
    this.name = name;
    logger = getLogger();
  }
  
  protected transient Logger logger = null;
  protected String name = null;
  
  private 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 = "unknown";
      String method = "unknown";
      if ((locations != null) && (locations.length > 2))
      {
        StackTraceElement caller = locations[2];
        cname = caller.getClassName();
        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.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import org.apache.commons.logging.Log;
import org.apache.log4j.Category;
import org.apache.log4j.Level;

/**
 * @deprecated
 */
public final class Log4JCategoryLog
  implements Log
{
  private static final String FQCN = Log4JCategoryLog.class.getName();
  private Category category = null;
  
  public Log4JCategoryLog() {}
  
  public Log4JCategoryLog(String name)
  {
    category = Category.getInstance(name);
  }
  
  public Log4JCategoryLog(Category category)
  {
    this.category = category;
  }
  
  public void trace(Object message)
  {
    category.log(FQCN, Level.DEBUG, message, null);
  }
  
  public void trace(Object message, Throwable t)
  {
    category.log(FQCN, Level.DEBUG, message, t);
  }
  
  public void debug(Object message)
  {
    category.log(FQCN, Level.DEBUG, message, null);
  }
  
  public void debug(Object message, Throwable t)
  {
    category.log(FQCN, Level.DEBUG, message, t);
  }
  
  public void info(Object message)
  {
    category.log(FQCN, Level.INFO, message, null);
  }
  
  public void info(Object message, Throwable t)
  {
    category.log(FQCN, Level.INFO, message, t);
  }
  
  public void warn(Object message)
  {
    category.log(FQCN, Level.WARN, message, null);
  }
  
  public void warn(Object message, Throwable t)
  {
    category.log(FQCN, Level.WARN, message, t);
  }
  
  public void error(Object message)
  {
    category.log(FQCN, Level.ERROR, message, null);
  }
  
  public void error(Object message, Throwable t)
  {
    category.log(FQCN, Level.ERROR, message, t);
  }
  
  public void fatal(Object message)
  {
    category.log(FQCN, Level.FATAL, message, null);
  }
  
  public void fatal(Object message, Throwable t)
  {
    category.log(FQCN, Level.FATAL, message, t);
  }
  
  public Category getCategory()
  {
    return category;
  }
  
  public boolean isDebugEnabled()
  {
    return category.isDebugEnabled();
  }
  
  public boolean isErrorEnabled()
  {
    return category.isEnabledFor(Level.ERROR);
  }
  
  public boolean isFatalEnabled()
  {
    return category.isEnabledFor(Level.FATAL);
  }
  
  public boolean isInfoEnabled()
  {
    return category.isInfoEnabled();
  }
  
  public boolean isTraceEnabled()
  {
    return category.isDebugEnabled();
  }
  
  public boolean isWarnEnabled()
  {
    return category.isEnabledFor(Level.WARN);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.Log4JCategoryLog
 * 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.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 String FQCN = Log4JLogger.class.getName();
  private static final boolean is12 = Priority.class.isAssignableFrom(Level.class);
  private transient Logger logger = null;
  private String name = null;
  
  public Log4JLogger() {}
  
  public Log4JLogger(String name)
  {
    this.name = name;
    logger = getLogger();
  }
  
  public Log4JLogger(Logger logger)
  {
    name = logger.getName();
    this.logger = logger;
  }
  
  public void trace(Object message)
  {
    if (is12) {
      getLogger().log(FQCN, (Priority)Level.DEBUG, message, null);
    } else {
      getLogger().log(FQCN, Level.DEBUG, message, null);
    }
  }
  
  public void trace(Object message, Throwable t)
  {
    if (is12) {
      getLogger().log(FQCN, (Priority)Level.DEBUG, message, t);
    } else {
      getLogger().log(FQCN, Level.DEBUG, message, t);
    }
  }
  
  public void debug(Object message)
  {
    if (is12) {
      getLogger().log(FQCN, (Priority)Level.DEBUG, message, null);
    } else {
      getLogger().log(FQCN, Level.DEBUG, message, null);
    }
  }
  
  public void debug(Object message, Throwable t)
  {
    if (is12) {
      getLogger().log(FQCN, (Priority)Level.DEBUG, message, t);
    } else {
      getLogger().log(FQCN, Level.DEBUG, message, t);
    }
  }
  
  public void info(Object message)
  {
    if (is12) {
      getLogger().log(FQCN, (Priority)Level.INFO, message, null);
    } else {
      getLogger().log(FQCN, Level.INFO, message, null);
    }
  }
  
  public void info(Object message, Throwable t)
  {
    if (is12) {
      getLogger().log(FQCN, (Priority)Level.INFO, message, t);
    } else {
      getLogger().log(FQCN, Level.INFO, message, t);
    }
  }
  
  public void warn(Object message)
  {
    if (is12) {
      getLogger().log(FQCN, (Priority)Level.WARN, message, null);
    } else {
      getLogger().log(FQCN, Level.WARN, message, null);
    }
  }
  
  public void warn(Object message, Throwable t)
  {
    if (is12) {
      getLogger().log(FQCN, (Priority)Level.WARN, message, t);
    } else {
      getLogger().log(FQCN, Level.WARN, message, t);
    }
  }
  
  public void error(Object message)
  {
    if (is12) {
      getLogger().log(FQCN, (Priority)Level.ERROR, message, null);
    } else {
      getLogger().log(FQCN, Level.ERROR, message, null);
    }
  }
  
  public void error(Object message, Throwable t)
  {
    if (is12) {
      getLogger().log(FQCN, (Priority)Level.ERROR, message, t);
    } else {
      getLogger().log(FQCN, Level.ERROR, message, t);
    }
  }
  
  public void fatal(Object message)
  {
    if (is12) {
      getLogger().log(FQCN, (Priority)Level.FATAL, message, null);
    } else {
      getLogger().log(FQCN, Level.FATAL, message, null);
    }
  }
  
  public void fatal(Object message, Throwable t)
  {
    if (is12) {
      getLogger().log(FQCN, (Priority)Level.FATAL, message, t);
    } else {
      getLogger().log(FQCN, Level.FATAL, message, t);
    }
  }
  
  public Logger getLogger()
  {
    if (logger == null) {
      logger = Logger.getLogger(name);
    }
    return logger;
  }
  
  public boolean isDebugEnabled()
  {
    return getLogger().isDebugEnabled();
  }
  
  public boolean isErrorEnabled()
  {
    if (is12) {
      return getLogger().isEnabledFor((Priority)Level.ERROR);
    }
    return getLogger().isEnabledFor(Level.ERROR);
  }
  
  public boolean isFatalEnabled()
  {
    if (is12) {
      return getLogger().isEnabledFor((Priority)Level.FATAL);
    }
    return getLogger().isEnabledFor(Level.FATAL);
  }
  
  public boolean isInfoEnabled()
  {
    return getLogger().isInfoEnabled();
  }
  
  public boolean isTraceEnabled()
  {
    return getLogger().isDebugEnabled();
  }
  
  public boolean isWarnEnabled()
  {
    if (is12) {
      return getLogger().isEnabledFor((Priority)Level.WARN);
    }
    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.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogConfigurationException;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Logger;

/**
 * @deprecated
 */
public final class Log4jFactory
  extends LogFactory
{
  private Hashtable attributes = new Hashtable();
  private Hashtable instances = new Hashtable();
  
  public Object getAttribute(String name)
  {
    return attributes.get(name);
  }
  
  public String[] getAttributeNames()
  {
    Vector names = new Vector();
    Enumeration keys = attributes.keys();
    while (keys.hasMoreElements()) {
      names.addElement((String)keys.nextElement());
    }
    String[] results = new String[names.size()];
    for (int i = 0; i < results.length; i++) {
      results[i] = ((String)names.elementAt(i));
    }
    return results;
  }
  
  public Log getInstance(Class clazz)
    throws LogConfigurationException
  {
    Log instance = (Log)instances.get(clazz);
    if (instance != null) {
      return instance;
    }
    instance = new Log4JLogger(Logger.getLogger(clazz));
    instances.put(clazz, instance);
    return instance;
  }
  
  public Log getInstance(String name)
    throws LogConfigurationException
  {
    Log instance = (Log)instances.get(name);
    if (instance != null) {
      return instance;
    }
    instance = new Log4JLogger(Logger.getLogger(name));
    instances.put(name, instance);
    return instance;
  }
  
  public void release()
  {
    instances.clear();
  }
  
  public void removeAttribute(String name)
  {
    attributes.remove(name);
  }
  
  public void setAttribute(String name, Object value)
  {
    if (value == null) {
      attributes.remove(name);
    } else {
      attributes.put(name, value);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.Log4jFactory
 * 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$1
  implements PrivilegedAction
{
  private final String val$name;
  
  LogFactoryImpl$1(String val$name)
  {
    this.val$name = val$name;
  }
  
  public Object run()
  {
    ClassLoader threadCL = LogFactoryImpl.access$001();
    if (threadCL != null) {
      try
      {
        return threadCL.loadClass(val$name);
      }
      catch (ClassNotFoundException ex) {}
    }
    try
    {
      return Class.forName(val$name);
    }
    catch (ClassNotFoundException e)
    {
      return e;
    }
  }
}

/* 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.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogConfigurationException;
import org.apache.commons.logging.LogFactory;

public class LogFactoryImpl
  extends LogFactory
{
  public static final String LOG_PROPERTY = "org.apache.commons.logging.Log";
  protected static final String LOG_PROPERTY_OLD = "org.apache.commons.logging.log";
  private static final String LOG_INTERFACE = "org.apache.commons.logging.Log";
  protected Hashtable attributes = new Hashtable();
  protected Hashtable instances = new Hashtable();
  private String logClassName;
  protected Constructor logConstructor = null;
  protected Class[] logConstructorSignature = { String.class };
  protected Method logMethod = null;
  protected Class[] logMethodSignature = { LogFactory.class };
  
  public Object getAttribute(String name)
  {
    return attributes.get(name);
  }
  
  public String[] getAttributeNames()
  {
    Vector names = new Vector();
    Enumeration keys = attributes.keys();
    while (keys.hasMoreElements()) {
      names.addElement((String)keys.nextElement());
    }
    String[] results = new String[names.size()];
    for (int i = 0; i < results.length; i++) {
      results[i] = ((String)names.elementAt(i));
    }
    return results;
  }
  
  public Log getInstance(Class clazz)
    throws LogConfigurationException
  {
    return getInstance(clazz.getName());
  }
  
  public Log getInstance(String name)
    throws LogConfigurationException
  {
    Log instance = (Log)instances.get(name);
    if (instance == null)
    {
      instance = newInstance(name);
      instances.put(name, instance);
    }
    return instance;
  }
  
  public void release()
  {
    instances.clear();
  }
  
  public void removeAttribute(String name)
  {
    attributes.remove(name);
  }
  
  public void setAttribute(String name, Object value)
  {
    if (value == null) {
      attributes.remove(name);
    } else {
      attributes.put(name, value);
    }
  }
  
  protected String getLogClassName()
  {
    if (logClassName != null) {
      return logClassName;
    }
    logClassName = ((String)getAttribute("org.apache.commons.logging.Log"));
    if (logClassName == null) {
      logClassName = ((String)getAttribute("org.apache.commons.logging.log"));
    }
    if (logClassName == null) {
      try
      {
        logClassName = System.getProperty("org.apache.commons.logging.Log");
      }
      catch (SecurityException e) {}
    }
    if (logClassName == null) {
      try
      {
        logClassName = System.getProperty("org.apache.commons.logging.log");
      }
      catch (SecurityException e) {}
    }
    if ((logClassName == null) && (isLog4JAvailable())) {
      logClassName = "org.apache.commons.logging.impl.Log4JLogger";
    }
    if ((logClassName == null) && (isJdk14Available())) {
      logClassName = "org.apache.commons.logging.impl.Jdk14Logger";
    }
    if ((logClassName == null) && (isJdk13LumberjackAvailable())) {
      logClassName = "org.apache.commons.logging.impl.Jdk13LumberjackLogger";
    }
    if (logClassName == null) {
      logClassName = "org.apache.commons.logging.impl.SimpleLog";
    }
    return logClassName;
  }
  
  protected Constructor getLogConstructor()
    throws LogConfigurationException
  {
    if (logConstructor != null) {
      return logConstructor;
    }
    String logClassName = getLogClassName();
    
    Class logClass = null;
    Class logInterface = null;
    try
    {
      logInterface = getClass().getClassLoader().loadClass("org.apache.commons.logging.Log");
      
      logClass = loadClass(logClassName);
      if (logClass == null) {
        throw new LogConfigurationException("No suitable Log implementation for " + logClassName);
      }
      if (!logInterface.isAssignableFrom(logClass))
      {
        Class[] interfaces = logClass.getInterfaces();
        for (int i = 0; i < interfaces.length; i++) {
          if ("org.apache.commons.logging.Log".equals(interfaces[i].getName())) {
            throw new LogConfigurationException("Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.");
          }
        }
        throw new LogConfigurationException("Class " + logClassName + " does not implement '" + "org.apache.commons.logging.Log" + "'.");
      }
    }
    catch (Throwable t)
    {
      throw new LogConfigurationException(t);
    }
    try
    {
      logMethod = logClass.getMethod("setLogFactory", logMethodSignature);
    }
    catch (Throwable t)
    {
      logMethod = null;
    }
    try
    {
      logConstructor = logClass.getConstructor(logConstructorSignature);
      return logConstructor;
    }
    catch (Throwable t)
    {
      throw new LogConfigurationException("No suitable Log constructor " + logConstructorSignature + " for " + logClassName, t);
    }
  }
  
  private static Class loadClass(String name)
    throws ClassNotFoundException
  {
    Object result = AccessController.doPrivileged(new PrivilegedAction()
    {
      private final String val$name;
      
      public Object run()
      {
        ClassLoader threadCL = LogFactoryImpl.access$001();
        if (threadCL != null) {
          try
          {
            return threadCL.loadClass(val$name);
          }
          catch (ClassNotFoundException ex) {}
        }
        try
        {
          return Class.forName(val$name);
        }
        catch (ClassNotFoundException e)
        {
          return e;
        }
      }
    });
    if ((result instanceof Class)) {
      return (Class)result;
    }
    throw ((ClassNotFoundException)result);
  }
  
  protected boolean isJdk13LumberjackAvailable()
  {
    try
    {
      loadClass("java.util.logging.Logger");
      loadClass("org.apache.commons.logging.impl.Jdk13LumberjackLogger");
      return true;
    }
    catch (Throwable t) {}
    return false;
  }
  
  protected boolean isJdk14Available()
  {
    try
    {
      loadClass("java.util.logging.Logger");
      loadClass("org.apache.commons.logging.impl.Jdk14Logger");
      Class throwable = loadClass("java.lang.Throwable");
      if (throwable.getDeclaredMethod("getStackTrace", null) == null) {
        return false;
      }
      return true;
    }
    catch (Throwable t) {}
    return false;
  }
1 2

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