commons-logging

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

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

public final class Jdk14Logger
  implements Log
{
  public Jdk14Logger(String name)
  {
    logger = Logger.getLogger(name);
  }
  
  protected Logger logger = null;
  
  private void log(Level level, String msg, Throwable ex)
  {
    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()
  {
    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 logger.isLoggable(Level.FINE);
  }
  
  public boolean isErrorEnabled()
  {
    return logger.isLoggable(Level.SEVERE);
  }
  
  public boolean isFatalEnabled()
  {
    return logger.isLoggable(Level.SEVERE);
  }
  
  public boolean isInfoEnabled()
  {
    return logger.isLoggable(Level.INFO);
  }
  
  public boolean isTraceEnabled()
  {
    return logger.isLoggable(Level.FINEST);
  }
  
  public boolean isWarnEnabled()
  {
    return logger.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 java.util.Enumeration;
import org.apache.commons.logging.Log;
import org.apache.log4j.Category;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.Priority;

public final class Log4JCategoryLog
  implements Log
{
  private static final String FQCN = Log4JCategoryLog.class.getName();
  private static boolean initialized = false;
  private static String LAYOUT = "%r [%t] %p %c{2} %x - %m%n";
  private Category category = null;
  
  public Log4JCategoryLog()
  {
    if (!initialized) {
      initialize();
    }
  }
  
  public Log4JCategoryLog(String name)
  {
    if (!initialized) {
      initialize();
    }
    category = Category.getInstance(name);
  }
  
  public Log4JCategoryLog(Category category)
  {
    if (!initialized) {
      initialize();
    }
    this.category = category;
  }
  
  private void initialize()
  {
    Category root = Category.getRoot();
    Enumeration appenders = root.getAllAppenders();
    if ((appenders == null) || (!appenders.hasMoreElements()))
    {
      ConsoleAppender app = new ConsoleAppender(new PatternLayout(LAYOUT), "System.err");
      
      app.setName("commons-logging");
      
      root.addAppender(app);
      root.setPriority(Priority.INFO);
    }
    initialized = true;
  }
  
  public void trace(Object message)
  {
    category.log(FQCN, Priority.DEBUG, message, null);
  }
  
  public void trace(Object message, Throwable t)
  {
    category.log(FQCN, Priority.DEBUG, message, t);
  }
  
  public void debug(Object message)
  {
    category.log(FQCN, Priority.DEBUG, message, null);
  }
  
  public void debug(Object message, Throwable t)
  {
    category.log(FQCN, Priority.DEBUG, message, t);
  }
  
  public void info(Object message)
  {
    category.log(FQCN, Priority.INFO, message, null);
  }
  
  public void info(Object message, Throwable t)
  {
    category.log(FQCN, Priority.INFO, message, t);
  }
  
  public void warn(Object message)
  {
    category.log(FQCN, Priority.WARN, message, null);
  }
  
  public void warn(Object message, Throwable t)
  {
    category.log(FQCN, Priority.WARN, message, t);
  }
  
  public void error(Object message)
  {
    category.log(FQCN, Priority.ERROR, message, null);
  }
  
  public void error(Object message, Throwable t)
  {
    category.log(FQCN, Priority.ERROR, message, t);
  }
  
  public void fatal(Object message)
  {
    category.log(FQCN, Priority.FATAL, message, null);
  }
  
  public void fatal(Object message, Throwable t)
  {
    category.log(FQCN, Priority.FATAL, message, t);
  }
  
  public boolean isDebugEnabled()
  {
    return category.isDebugEnabled();
  }
  
  public boolean isErrorEnabled()
  {
    return category.isEnabledFor(Priority.ERROR);
  }
  
  public boolean isFatalEnabled()
  {
    return category.isEnabledFor(Priority.FATAL);
  }
  
  public boolean isInfoEnabled()
  {
    return category.isInfoEnabled();
  }
  
  public boolean isTraceEnabled()
  {
    return category.isDebugEnabled();
  }
  
  public boolean isWarnEnabled()
  {
    return category.isEnabledFor(Priority.WARN);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.Log4JCategoryLog
 * Java Class Version: 1.2 (46.0)
 * 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.Category;

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 Log4JCategoryLog(Category.getInstance(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 Log4JCategoryLog(Category.getInstance(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.2 (46.0)
 * 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.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.lang.reflect.Constructor;
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 LogFactoryImpl()
  {
    guessConfig();
  }
  
  public static final String LOG_DEFAULT = "org.apache.commons.logging.impl.SimpleLog";
  public static final String LOG_PROPERTY = "org.apache.commons.logging.Log";
  protected static final String LOG_PROPERTY_OLD = "org.apache.commons.logging.log";
  protected Hashtable attributes = new Hashtable();
  protected Hashtable instances = new Hashtable();
  protected Constructor logConstructor = null;
  protected LogFactory proxyFactory = null;
  protected Class[] logConstructorSignature = { String.class };
  protected Method logMethod = null;
  protected Class[] logMethodSignature = { LogFactory.class };
  
  public Object getAttribute(String name)
  {
    if (proxyFactory != null) {
      return proxyFactory.getAttribute(name);
    }
    return attributes.get(name);
  }
  
  public String[] getAttributeNames()
  {
    if (proxyFactory != null) {
      return proxyFactory.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
  {
    if (proxyFactory != null) {
      return proxyFactory.getInstance(clazz);
    }
    return getInstance(clazz.getName());
  }
  
  public Log getInstance(String name)
    throws LogConfigurationException
  {
    if (proxyFactory != null) {
      return proxyFactory.getInstance(name);
    }
    Log instance = (Log)instances.get(name);
    if (instance == null)
    {
      instance = newInstance(name);
      instances.put(name, instance);
    }
    return instance;
  }
  
  public void release()
  {
    if (proxyFactory != null) {
      proxyFactory.release();
    }
    instances.clear();
  }
  
  public void removeAttribute(String name)
  {
    if (proxyFactory != null) {
      proxyFactory.removeAttribute(name);
    }
    attributes.remove(name);
  }
  
  public void setAttribute(String name, Object value)
  {
    if (proxyFactory != null) {
      proxyFactory.setAttribute(name, value);
    }
    if (value == null) {
      attributes.remove(name);
    } else {
      attributes.put(name, value);
    }
  }
  
  protected Constructor getLogConstructor()
    throws LogConfigurationException
  {
    if (logConstructor != null) {
      return logConstructor;
    }
    String logClassName = null;
    if (logClassName == null) {
      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.Log4JCategoryLog";
    }
    if ((logClassName == null) && (isJdk14Available())) {
      logClassName = "org.apache.commons.logging.impl.Jdk14Logger";
    }
    if (logClassName == null) {
      logClassName = "org.apache.commons.logging.impl.SimpleLog";
    }
    Class logClass = null;
    try
    {
      logClass = loadClass(logClassName);
      if (logClass == null) {
        throw new LogConfigurationException("No suitable Log implementation for " + logClassName);
      }
      if (!Log.class.isAssignableFrom(logClass)) {
        throw new LogConfigurationException("Class " + logClassName + " does not implement 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 void guessConfig()
  {
    if (isLog4JAvailable())
    {
      proxyFactory = null;
      try
      {
        Class proxyClass = loadClass("org.apache.commons.logging.impl.Log4jFactory");
        if (proxyClass != null) {
          proxyFactory = ((LogFactory)proxyClass.newInstance());
        }
      }
      catch (Throwable t) {}
    }
  }
  
  protected boolean isJdk14Available()
  {
    try
    {
      loadClass("java.util.logging.Logger");
      loadClass("org.apache.commons.logging.impl.Jdk14Logger");
      return true;
    }
    catch (Throwable t) {}
    return false;
  }
  
  protected boolean isLog4JAvailable()
  {
    try
    {
      loadClass("org.apache.log4j.Category");
      loadClass("org.apache.commons.logging.impl.Log4JCategoryLog");
      return true;
    }
    catch (Throwable t) {}
    return false;
  }
  
  protected Log newInstance(String name)
    throws LogConfigurationException
  {
    Log instance = null;
    try
    {
      Object[] params = new Object[1];
      params[0] = name;
      instance = (Log)getLogConstructor().newInstance(params);
      if (logMethod != null)
      {
        params[0] = this;
        logMethod.invoke(instance, params);
      }
      return instance;
    }
    catch (Throwable t)
    {
      throw new LogConfigurationException(t);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.LogFactoryImpl
 * 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.log.Hierarchy;
import org.apache.log.Logger;

public final class LogKitLogger
  implements Log
{
  protected Logger logger = null;
  
  public LogKitLogger(String name)
  {
    logger = Hierarchy.getDefaultHierarchy().getLoggerFor(name);
  }
  
  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) {
      logger.debug(String.valueOf(message));
    }
  }
  
  public void debug(Object message, Throwable t)
  {
    if (message != null) {
      logger.debug(String.valueOf(message), t);
    }
  }
  
  public void info(Object message)
  {
    if (message != null) {
      logger.info(String.valueOf(message));
    }
  }
  
  public void info(Object message, Throwable t)
  {
    if (message != null) {
      logger.info(String.valueOf(message), t);
    }
  }
  
  public void warn(Object message)
  {
    if (message != null) {
      logger.warn(String.valueOf(message));
    }
  }
  
  public void warn(Object message, Throwable t)
  {
    if (message != null) {
      logger.warn(String.valueOf(message), t);
    }
  }
  
  public void error(Object message)
  {
    if (message != null) {
      logger.error(String.valueOf(message));
    }
  }
  
  public void error(Object message, Throwable t)
  {
    if (message != null) {
      logger.error(String.valueOf(message), t);
    }
  }
  
  public void fatal(Object message)
  {
    if (message != null) {
      logger.fatalError(String.valueOf(message));
    }
  }
  
  public void fatal(Object message, Throwable t)
  {
    if (message != null) {
      logger.fatalError(String.valueOf(message), t);
    }
  }
  
  public boolean isDebugEnabled()
  {
    return logger.isDebugEnabled();
  }
  
  public boolean isErrorEnabled()
  {
    return logger.isErrorEnabled();
  }
  
  public boolean isFatalEnabled()
  {
    return logger.isFatalErrorEnabled();
  }
  
  public boolean isInfoEnabled()
  {
    return logger.isInfoEnabled();
  }
  
  public boolean isTraceEnabled()
  {
    return logger.isDebugEnabled();
  }
  
  public boolean isWarnEnabled()
  {
    return logger.isWarnEnabled();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.LogKitLogger
 * 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;

public final class NoOpLog
  implements Log
{
  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.2 (46.0)
 * 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.lang.reflect.Method;
import java.security.AccessControlException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.Properties;
import org.apache.commons.logging.Log;

public class SimpleLog
  implements Log
{
  protected static final String systemPrefix = "org.apache.commons.logging.simplelog.";
  protected static final Properties simpleLogProps = new Properties();
  protected static boolean showLogName = false;
  protected static boolean showShortName = true;
  protected static boolean showDateTime = false;
  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;
  
  static
  {
    try
    {
      Enumeration enum = System.getProperties().propertyNames();
      while (enum.hasMoreElements())
      {
        String name = (String)enum.nextElement();
        if ((null != name) && (name.startsWith("org.apache.commons.logging.simplelog."))) {
          simpleLogProps.setProperty(name, System.getProperty(name));
        }
      }
      ClassLoader classLoader = null;
      try
      {
        Method method = Thread.class.getMethod("getContextClassLoader", null);
        
        classLoader = (ClassLoader)method.invoke(Thread.currentThread(), null);
      }
      catch (Exception e) {}
      if (classLoader == null) {
        classLoader = SimpleLog.class.getClassLoader();
      }
      InputStream in = classLoader.getResourceAsStream("simplelog.properties");
      if (null != in) {
        try
        {
          simpleLogProps.load(in);
          in.close();
        }
        catch (IOException e) {}
      }
      String prop = simpleLogProps.getProperty("org.apache.commons.logging.simplelog.showlogname");
      if (prop != null) {
        showLogName = "true".equalsIgnoreCase(prop);
      }
      prop = simpleLogProps.getProperty("org.apache.commons.logging.simplelog.showShortLogname");
      if (prop != null) {
        showShortName = "true".equalsIgnoreCase(prop);
      }
      prop = simpleLogProps.getProperty("org.apache.commons.logging.simplelog.showdatetime");
      if (prop != null) {
        showDateTime = "true".equalsIgnoreCase(prop);
      }
      if (showDateTime) {
        dateFormatter = new SimpleDateFormat(simpleLogProps.getProperty("org.apache.commons.logging.simplelog.dateformat", "yyyy/MM/dd HH:mm:ss:SSS zzz"));
      }
    }
    catch (AccessControlException e) {}
  }
  
  protected String logName = null;
  protected int currentLogLevel;
  private String prefix = null;
  
  public SimpleLog(String name)
  {
    logName = name;
    
    setLevel(3);
    
    String lvl = simpleLogProps.getProperty("org.apache.commons.logging.simplelog.log." + logName);
    int i = String.valueOf(name).lastIndexOf(".");
    while ((null == lvl) && (i > -1))
    {
      name = name.substring(0, i);
      lvl = simpleLogProps.getProperty("org.apache.commons.logging.simplelog.log." + name);
      i = String.valueOf(name).lastIndexOf(".");
    }
    if (null == lvl) {
      lvl = simpleLogProps.getProperty("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)
    {
      buf.append(dateFormatter.format(new Date()));
      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 (prefix == null)
      {
        prefix = (logName.substring(logName.lastIndexOf(".") + 1) + " - ");
        prefix = (prefix.substring(prefix.lastIndexOf("/") + 1) + "-");
      }
      buf.append(prefix);
    }
    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(">");
      t.printStackTrace();
    }
    System.err.println(buf.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);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.SimpleLog
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
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.2 (46.0)
 * 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);
    this.cause = cause;
  }
  
  protected Throwable cause = null;
  
  public Throwable getCause()
  {
    return cause;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.LogConfigurationException
 * Java Class Version: 1.2 (46.0)
 * 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.2 (46.0)
 * 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;
    }
    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 = contextClassLoader == null ? ClassLoader.getSystemResourceAsStream("META-INF/services/org.apache.commons.logging.LogFactory") : contextClassLoader.getResourceAsStream("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) {}
    }
    Properties props = null;
    try
    {
      InputStream stream = contextClassLoader == null ? ClassLoader.getSystemResourceAsStream("commons-logging.properties") : contextClassLoader.getResourceAsStream("commons-logging.properties");
      if (stream != null)
      {
        props = new Properties();
        props.load(stream);
        stream.close();
        String factoryClass = props.getProperty("org.apache.commons.logging.LogFactory");
        if (factory == null)
        {
          if (factoryClass == null) {
            factoryClass = "org.apache.commons.logging.impl.LogFactoryImpl";
          }
          factory = newFactory(factoryClass, contextClassLoader);
        }
      }
    }
    catch (IOException e) {}catch (SecurityException e) {}
    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 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
  {
    try
    {
      if (classLoader == null) {
        classLoader = LogFactory.class.getClassLoader();
      }
      Class clazz = null;
      try
      {
        clazz = classLoader.loadClass(factoryClass);
      }
      catch (ClassNotFoundException ex)
      {
        if (classLoader != LogFactory.class.getClassLoader())
        {
          classLoader = LogFactory.class.getClassLoader();
          clazz = classLoader.loadClass(factoryClass);
        }
      }
      return (LogFactory)clazz.newInstance();
    }
    catch (Exception e)
    {
      throw new LogConfigurationException(e);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.LogFactory
 * Java Class Version: 1.2 (46.0)
 * 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.Category")) {
        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.Log4JCategoryLog");
        } 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 (n
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