Author: ceki
Date: Tue Aug 15 22:41:06 2006
New Revision: 612

Added:
   slf4j/trunk/jcl104-over-slf4j/src/main/
   slf4j/trunk/jcl104-over-slf4j/src/main/java/
   slf4j/trunk/jcl104-over-slf4j/src/main/java/org/
   slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/
   slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/
   slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/
   
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/Log.java
   
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/LogConfigurationException.java
   
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/LogFactory.java
   slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/
   
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4FLogFactory.java
   
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLog.java
   
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/package.html
   
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/package.html
   slf4j/trunk/jcl104-over-slf4j/src/test/
   slf4j/trunk/jcl104-over-slf4j/src/test/java/
   slf4j/trunk/jcl104-over-slf4j/src/test/java/org/
   slf4j/trunk/jcl104-over-slf4j/src/test/java/org/apache/
   slf4j/trunk/jcl104-over-slf4j/src/test/java/org/apache/commons/
   slf4j/trunk/jcl104-over-slf4j/src/test/java/org/apache/commons/logging/
   
slf4j/trunk/jcl104-over-slf4j/src/test/java/org/apache/commons/logging/InvokeJCLTest.java
Log:
Mavenizing of SLF4J, on going work

Added: 
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/Log.java
==============================================================================
--- (empty file)
+++ 
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/Log.java 
    Tue Aug 15 22:41:06 2006
@@ -0,0 +1,235 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+
+package org.apache.commons.logging;
+
+/**
+ * <p>A simple logging interface abstracting logging APIs.  In order to be
+ * instantiated successfully by [EMAIL PROTECTED] LogFactory}, classes that 
implement
+ * this interface must have a constructor that takes a single String
+ * parameter representing the "name" of this Log.</p>
+ *
+ * <p> The six logging levels used by <code>Log</code> are (in order):
+ * <ol>
+ * <li>trace (the least serious)</li>
+ * <li>debug</li>
+ * <li>info</li>
+ * <li>warn</li>
+ * <li>error</li>
+ * <li>fatal (the most serious)</li>
+ * </ol>
+ * The mapping of these log levels to the concepts used by the underlying
+ * logging system is implementation dependent.
+ * The implemention should ensure, though, that this ordering behaves
+ * as expected.</p>
+ *
+ * <p>Performance is often a logging concern.
+ * By examining the appropriate property,
+ * a component can avoid expensive operations (producing information
+ * to be logged).</p>
+ *
+ * <p> For example,
+ * <code><pre>
+ *    if (log.isDebugEnabled()) {
+ *        ... do something expensive ...
+ *        log.debug(theResult);
+ *    }
+ * </pre></code>
+ * </p>
+ *
+ * <p>Configuration of the underlying logging system will generally be done
+ * external to the Logging APIs, through whatever mechanism is supported by
+ * that system.</p>
+ *
+ * <p style="color: #E40; font-weight: bold;">Please note that this interface 
is identical to that found in JCL 1.0.4.</p>
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Scott Sanders</a>
+ * @author Rod Waldhoff
+ * @version $Id: Log.java,v 1.19 2004/06/06 21:16:04 rdonkin Exp $
+ */
+public interface Log {
+
+
+    // ----------------------------------------------------- Logging Properties
+
+
+    /**
+     * <p> Is debug logging currently enabled? </p>
+     *
+     * <p> Call this method to prevent having to perform expensive operations
+     * (for example, <code>String</code> concatenation)
+     * when the log level is more than debug. </p>
+     */
+    public boolean isDebugEnabled();
+
+
+    /**
+     * <p> Is error logging currently enabled? </p>
+     *
+     * <p> Call this method to prevent having to perform expensive operations
+     * (for example, <code>String</code> concatenation)
+     * when the log level is more than error. </p>
+     */
+    public boolean isErrorEnabled();
+
+
+    /**
+     * <p> Is fatal logging currently enabled? </p>
+     *
+     * <p> Call this method to prevent having to perform expensive operations
+     * (for example, <code>String</code> concatenation)
+     * when the log level is more than fatal. </p>
+     */
+    public boolean isFatalEnabled();
+
+
+    /**
+     * <p> Is info logging currently enabled? </p>
+     *
+     * <p> Call this method to prevent having to perform expensive operations
+     * (for example, <code>String</code> concatenation)
+     * when the log level is more than info. </p>
+     */
+    public boolean isInfoEnabled();
+
+
+    /**
+     * <p> Is trace logging currently enabled? </p>
+     *
+     * <p> Call this method to prevent having to perform expensive operations
+     * (for example, <code>String</code> concatenation)
+     * when the log level is more than trace. </p>
+     */
+    public boolean isTraceEnabled();
+
+
+    /**
+     * <p> Is warn logging currently enabled? </p>
+     *
+     * <p> Call this method to prevent having to perform expensive operations
+     * (for example, <code>String</code> concatenation)
+     * when the log level is more than warn. </p>
+     */
+    public boolean isWarnEnabled();
+
+
+    // -------------------------------------------------------- Logging Methods
+
+
+    /**
+     * <p> Log a message with trace log level. </p>
+     *
+     * @param message log this message
+     */
+    public void trace(Object message);
+
+
+    /**
+     * <p> Log an error with trace log level. </p>
+     *
+     * @param message log this message
+     * @param t log this cause
+     */
+    public void trace(Object message, Throwable t);
+
+
+    /**
+     * <p> Log a message with debug log level. </p>
+     *
+     * @param message log this message
+     */
+    public void debug(Object message);
+
+
+    /**
+     * <p> Log an error with debug log level. </p>
+     *
+     * @param message log this message
+     * @param t log this cause
+     */
+    public void debug(Object message, Throwable t);
+
+
+    /**
+     * <p> Log a message with info log level. </p>
+     *
+     * @param message log this message
+     */
+    public void info(Object message);
+
+
+    /**
+     * <p> Log an error with info log level. </p>
+     *
+     * @param message log this message
+     * @param t log this cause
+     */
+    public void info(Object message, Throwable t);
+
+
+    /**
+     * <p> Log a message with warn log level. </p>
+     *
+     * @param message log this message
+     */
+    public void warn(Object message);
+
+
+    /**
+     * <p> Log an error with warn log level. </p>
+     *
+     * @param message log this message
+     * @param t log this cause
+     */
+    public void warn(Object message, Throwable t);
+
+
+    /**
+     * <p> Log a message with error log level. </p>
+     *
+     * @param message log this message
+     */
+    public void error(Object message);
+
+
+    /**
+     * <p> Log an error with error log level. </p>
+     *
+     * @param message log this message
+     * @param t log this cause
+     */
+    public void error(Object message, Throwable t);
+
+
+    /**
+     * <p> Log a message with fatal log level. </p>
+     *
+     * @param message log this message
+     */
+    public void fatal(Object message);
+
+
+    /**
+     * <p> Log an error with fatal log level. </p>
+     *
+     * @param message log this message
+     * @param t log this cause
+     */
+    public void fatal(Object message, Throwable t);
+
+
+}

Added: 
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/LogConfigurationException.java
==============================================================================
--- (empty file)
+++ 
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/LogConfigurationException.java
       Tue Aug 15 22:41:06 2006
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+package org.apache.commons.logging;
+
+
+/**
+ * <p>An exception that is thrown only if a suitable <code>LogFactory</code>
+ * or <code>Log</code> instance cannot be created by the corresponding
+ * factory methods.</p>
+ * 
+ * <p>In this version of JCL, this exception will never be thrown in practice. 
However, it is 
+ * included here to ensure total compile time and run time compatibility with 
the original JCL 1.0.4.
+ * 
+ * @author Craig R. McClanahan
+ */
+
+public class LogConfigurationException extends RuntimeException {
+
+
+    /**
+     * Construct a new exception with <code>null</code> as its detail message.
+     */
+    public LogConfigurationException() {
+
+        super();
+
+    }
+
+
+    /**
+     * Construct a new exception with the specified detail message.
+     *
+     * @param message The detail message
+     */
+    public LogConfigurationException(String message) {
+
+        super(message);
+
+    }
+
+
+    /**
+     * Construct a new exception with the specified cause and a derived
+     * detail message.
+     *
+     * @param cause The underlying cause
+     */
+    public LogConfigurationException(Throwable cause) {
+
+        this((cause == null) ? null : cause.toString(), cause);
+
+    }
+
+
+    /**
+     * Construct a new exception with the specified detail message and cause.
+     *
+     * @param message The detail message
+     * @param cause The underlying cause
+     */
+    public LogConfigurationException(String message, Throwable cause) {
+
+        super(message + " (Caused by " + cause + ")");
+        this.cause = cause; // Two-argument version requires JDK 1.4 or later
+
+    }
+
+
+    /**
+     * The underlying cause of this exception.
+     */
+    protected Throwable cause = null;
+
+
+    /**
+     * Return the underlying cause of this exception (if any).
+     */
+    public Throwable getCause() {
+
+        return (this.cause);
+
+    }
+
+
+}

Added: 
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/LogFactory.java
==============================================================================
--- (empty file)
+++ 
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/LogFactory.java
      Tue Aug 15 22:41:06 2006
@@ -0,0 +1,252 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.logging;
+
+import org.apache.commons.logging.impl.SLF4FLogFactory;
+
+/**
+ * <p>
+ * Factory for creating [EMAIL PROTECTED] Log} instances, which always 
delegates to an instance of
+ * [EMAIL PROTECTED] SLF4FLogFactory}.
+ * 
+ * </p>
+ * 
+ * @author Craig R. McClanahan
+ * @author Costin Manolache
+ * @author Richard A. Sitze
+ * @author Ceki G&uuml;lc&uuml; 
+ */
+
+public abstract class LogFactory {
+
+  static LogFactory logFactory = new SLF4FLogFactory();
+
+  /**
+   * The name of the property used to identify the LogFactory implementation
+   * class name.
+   * <p>
+   * This property is not used but preserved here for compatibility.
+   */
+  public static final String FACTORY_PROPERTY =
+      "org.apache.commons.logging.LogFactory";
+
+  /**
+   * The fully qualified class name of the fallback <code>LogFactory</code>
+   * implementation class to use, if no other can be found. 
+   * 
+   * <p>This property is not used but preserved here for compatibility.
+   */
+  public static final String FACTORY_DEFAULT =
+      "org.apache.commons.logging.impl.SLF4FLogFactory";
+
+  /**
+   * The name of the properties file to search for. 
+   * <p>
+   * This property is not used but preserved here for compatibility.
+   */
+  public static final String FACTORY_PROPERTIES =
+      "commons-logging.properties";
+
+  
+  /**
+   * Protected constructor that is not available for public use.
+   */
+  protected LogFactory() {
+  }
+
+  // --------------------------------------------------------- Public Methods
+
+  /**
+   * Return the configuration attribute with the specified name (if any), or
+   * <code>null</code> if there is no such attribute.
+   * 
+   * @param name
+   *          Name of the attribute to return
+   */
+  public abstract Object getAttribute(String name);
+
+  /**
+   * Return an array containing the names of all currently defined 
configuration
+   * attributes. If there are no such attributes, a zero length array is
+   * returned.
+   */
+  public abstract String[] getAttributeNames();
+
+  /**
+   * Convenience method to derive a name from the specified class and call
+   * <code>getInstance(String)</code> with it.
+   * 
+   * @param clazz
+   *          Class for which a suitable Log name will be derived
+   * 
+   * @exception LogConfigurationException
+   *              if a suitable <code>Log</code> instance cannot be returned
+   */
+  public abstract Log getInstance(Class clazz) throws 
LogConfigurationException;
+
+  /**
+   * <p>
+   * Construct (if necessary) and return a <code>Log</code> instance, using
+   * the factory's current set of configuration attributes.
+   * </p>
+   * 
+   * <p>
+   * <strong>NOTE </strong>- Depending upon the implementation of the
+   * <code>LogFactory</code> you are using, the <code>Log</code> instance
+   * you are returned may or may not be local to the current application, and
+   * may or may not be returned again on a subsequent call with the same name
+   * argument.
+   * </p>
+   * 
+   * @param name
+   *          Logical name of the <code>Log</code> instance to be returned
+   *          (the meaning of this name is only known to the underlying logging
+   *          implementation that is being wrapped)
+   * 
+   * @exception LogConfigurationException
+   *              if a suitable <code>Log</code> instance cannot be returned
+   */
+  public abstract Log getInstance(String name) throws 
LogConfigurationException;
+
+  /**
+   * Release any internal references to previously created [EMAIL PROTECTED] 
Log}instances
+   * returned by this factory. This is useful in environments like servlet
+   * containers, which implement application reloading by throwing away a
+   * ClassLoader. Dangling references to objects in that class loader would
+   * prevent garbage collection.
+   */
+  public abstract void release();
+
+  /**
+   * Remove any configuration attribute associated with the specified name. If
+   * there is no such attribute, no action is taken.
+   * 
+   * @param name
+   *          Name of the attribute to remove
+   */
+  public abstract void removeAttribute(String name);
+
+  /**
+   * Set the configuration attribute with the specified name. Calling this with
+   * a <code>null</code> value is equivalent to calling
+   * <code>removeAttribute(name)</code>.
+   * 
+   * @param name
+   *          Name of the attribute to set
+   * @param value
+   *          Value of the attribute to set, or <code>null</code> to remove
+   *          any setting for this attribute
+   */
+  public abstract void setAttribute(String name, Object value);
+
+  // --------------------------------------------------------- Static Methods
+
+  /**
+   * <p>
+   * Construct (if necessary) and return a <code>LogFactory</code> instance,
+   * using the following ordered lookup procedure to determine the name of the
+   * implementation class to be loaded.
+   * </p>
+   * <ul>
+   * <li>The <code>org.apache.commons.logging.LogFactory</code> system
+   * property.</li>
+   * <li>The JDK 1.3 Service Discovery mechanism</li>
+   * <li>Use the properties file <code>commons-logging.properties</code>
+   * file, if found in the class path of this class. The configuration file is
+   * in standard <code>java.util.Properties</code> format and contains the
+   * fully qualified name of the implementation class with the key being the
+   * system property defined above.</li>
+   * <li>Fall back to a default implementation class (
+   * <code>org.apache.commons.logging.impl.SLF4FLogFactory</code>).</li>
+   * </ul>
+   * 
+   * <p>
+   * <em>NOTE</em>- If the properties file method of identifying the
+   * <code>LogFactory</code> implementation class is utilized, all of the
+   * properties defined in this file will be set as configuration attributes on
+   * the corresponding <code>LogFactory</code> instance.
+   * </p>
+   * 
+   * @exception LogConfigurationException
+   *              if the implementation class is not available or cannot be
+   *              instantiated.
+   */
+  public static LogFactory getFactory() throws LogConfigurationException {
+    return logFactory;
+  }
+
+  /**
+   * Convenience method to return a named logger, without the application 
having
+   * to care about factories.
+   * 
+   * @param clazz
+   *          Class from which a log name will be derived
+   * 
+   * @exception LogConfigurationException
+   *              if a suitable <code>Log</code> instance cannot be returned
+   */
+  public static Log getLog(Class clazz) throws LogConfigurationException {
+
+    return (getFactory().getInstance(clazz));
+  }
+
+  /**
+   * Convenience method to return a named logger, without the application 
having
+   * to care about factories.
+   * 
+   * @param name
+   *          Logical name of the <code>Log</code> instance to be returned
+   *          (the meaning of this name is only known to the underlying logging
+   *          implementation that is being wrapped)
+   * 
+   * @exception LogConfigurationException
+   *              if a suitable <code>Log</code> instance cannot be returned
+   */
+  public static Log getLog(String name) throws LogConfigurationException {
+
+    return (getFactory().getInstance(name));
+
+  }
+
+  /**
+   * Release any internal references to previously created [EMAIL PROTECTED] 
LogFactory}
+   * instances that have been associated with the specified class loader (if
+   * any), after calling the instance method <code>release()</code> on each of
+   * them.
+   * 
+   * @param classLoader
+   *          ClassLoader for which to release the LogFactory
+   */
+  public static void release(ClassLoader classLoader) {
+    // since SLF4J based JCL does not make use of classloaders, there is 
nothing
+    // to do here
+  }
+
+  /**
+   * Release any internal references to previously created [EMAIL PROTECTED] 
LogFactory}
+   * instances, after calling the instance method <code>release()</code> on
+   * each of them. This is useful in environments like servlet containers, 
which
+   * implement application reloading by throwing away a ClassLoader. Dangling
+   * references to objects in that class loader would prevent garbage
+   * collection.
+   */
+  public static void releaseAll() {
+    // since SLF4J based JCL does not make use of classloaders, there is 
nothing
+    // to do here
+  }
+
+}
\ No newline at end of file

Added: 
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4FLogFactory.java
==============================================================================
--- (empty file)
+++ 
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4FLogFactory.java
    Tue Aug 15 22:41:06 2006
@@ -0,0 +1,210 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.logging.impl;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Vector;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogConfigurationException;
+import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * <p>
+ * Concrete subclass of [EMAIL PROTECTED] LogFactory} which always delegates 
to the
+ * [EMAIL PROTECTED] LoggerFactory org.slf4j.LoggerFactory} class. 
+ * 
+ * <p>
+ * This factory generates instances of [EMAIL PROTECTED] SLF4JLog}. It will 
remember 
+ * previously created instances for the same name, and will 
+ * return them on repeated requests to the
+ * <code>getInstance()</code> method. 
+ * 
+ * <p>This implementation ignores any configured attributes.
+ * </p>
+ * 
+ * @author Rod Waldhoff
+ * @author Craig R. McClanahan
+ * @author Richard A. Sitze
+ * @author Ceki G&uuml;lc&uuml;
+ */
+
+public class SLF4FLogFactory extends LogFactory {
+
+  // ----------------------------------------------------------- Constructors
+
+  /**
+   * The [EMAIL PROTECTED] org.apache.commons.logging.Log}instances that have 
already been
+   * created, keyed by logger name.
+   */
+  Map loggerMap;
+
+  /**
+   * Public no-arguments constructor required by the lookup mechanism.
+   */
+  public SLF4FLogFactory() {
+    loggerMap = new HashMap();
+  }
+
+  // ----------------------------------------------------- Manifest Constants
+
+  /**
+   * The name of the system property identifying our [EMAIL PROTECTED] 
Log}implementation
+   * class.
+   */
+  public static final String LOG_PROPERTY = "org.apache.commons.logging.Log";
+
+  // ----------------------------------------------------- Instance Variables
+
+  /**
+   * Configuration attributes.
+   */
+  protected Hashtable attributes = new Hashtable();
+
+  // --------------------------------------------------------- Public Methods
+
+  /**
+   * Return the configuration attribute with the specified name (if any), or
+   * <code>null</code> if there is no such attribute.
+   * 
+   * @param name
+   *          Name of the attribute to return
+   */
+  public Object getAttribute(String name) {
+
+    return (attributes.get(name));
+
+  }
+
+  /**
+   * Return an array containing the names of all currently defined 
configuration
+   * attributes. If there are no such attributes, a zero length array is
+   * returned.
+   */
+  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);
+
+  }
+
+  /**
+   * Convenience method to derive a name from the specified class and call
+   * <code>getInstance(String)</code> with it.
+   * 
+   * @param clazz
+   *          Class for which a suitable Log name will be derived
+   * 
+   * @exception LogConfigurationException
+   *              if a suitable <code>Log</code> instance cannot be returned
+   */
+  public Log getInstance(Class clazz) throws LogConfigurationException {
+
+    return (getInstance(clazz.getName()));
+
+  }
+
+  /**
+   * <p>
+   * Construct (if necessary) and return a <code>Log</code> instance, using
+   * the factory's current set of configuration attributes.
+   * </p>
+   * 
+   * @param name
+   *          Logical name of the <code>Log</code> instance to be returned
+   *          (the meaning of this name is only known to the underlying logging
+   *          implementation that is being wrapped)
+   * 
+   * @exception LogConfigurationException
+   *              if a suitable <code>Log</code> instance cannot be returned
+   */
+  public Log getInstance(String name) throws LogConfigurationException {
+
+    Log instance = (Log) loggerMap.get(name);
+    if (instance == null) {
+      Logger logger = LoggerFactory.getLogger(name);
+      instance = new SLF4JLog(logger);
+      loggerMap.put(name, instance);
+    }
+    return (instance);
+
+  }
+
+  /**
+   * Release any internal references to previously created
+   * [EMAIL PROTECTED] org.apache.commons.logging.Log}instances returned by 
this factory.
+   * This is useful in environments like servlet containers, which implement
+   * application reloading by throwing away a ClassLoader. Dangling references
+   * to objects in that class loader would prevent garbage collection.
+   */
+  public void release() {
+    // This method is never called by jcl-over-slf4j classes. However,
+    // in certain deployment scenarios, in particular if jcl104-over-slf4j.jar 
is
+    // in the the web-app class loader and the official commons-logging.jar is
+    // deployed in some parent class loader (e.g. commons/lib), then it is 
possible 
+    // for the parent class loader to mask the classes shipping in 
+    // jcl104-over-slf4j.jar.
+    System.out.println("WARN: The method "+SLF4FLogFactory.class+"#release() 
was invoked.");
+    System.out.println("WARN: Please see http://www.slf4j.org/codes.html for 
an explanation.");
+    System.out.flush(); 
+   }
+
+  /**
+   * Remove any configuration attribute associated with the specified name. If
+   * there is no such attribute, no action is taken.
+   * 
+   * @param name
+   *          Name of the attribute to remove
+   */
+  public void removeAttribute(String name) {
+    attributes.remove(name);
+  }
+
+  /**
+   * Set the configuration attribute with the specified name. Calling this with
+   * a <code>null</code> value is equivalent to calling
+   * <code>removeAttribute(name)</code>.
+   * 
+   * @param name
+   *          Name of the attribute to set
+   * @param value
+   *          Value of the attribute to set, or <code>null</code> to remove
+   *          any setting for this attribute
+   */
+  public void setAttribute(String name, Object value) {
+
+    if (value == null) {
+      attributes.remove(name);
+    } else {
+      attributes.put(name, value);
+    }
+
+  }
+}
\ No newline at end of file

Added: 
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLog.java
==============================================================================
--- (empty file)
+++ 
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLog.java
   Tue Aug 15 22:41:06 2006
@@ -0,0 +1,197 @@
+// TOTO
+
+package org.apache.commons.logging.impl;
+
+import org.apache.commons.logging.Log;
+import org.slf4j.Logger;
+
+/**
+ * Implementation of [EMAIL PROTECTED] Log org.apache.commons.logging.Log} 
interface which 
+ * delegates all processing to a wrapped [EMAIL PROTECTED] Logger 
org.slf4j.Logger} instance.
+ * 
+ * <p>JCL's FATAL and TRACE levels are mapped to ERROR and DEBUG respectively. 
All 
+ * other levels map one to one.
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ */
+public class SLF4JLog implements Log {
+
+  private Logger logger;
+
+  SLF4JLog(Logger logger) {
+    this.logger = logger;
+  }
+
+  /**
+   * Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
+   */
+  public boolean isDebugEnabled() {
+    return logger.isDebugEnabled();
+  }
+
+  /**
+   * Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
+   */
+  public boolean isErrorEnabled() {
+    return logger.isErrorEnabled();
+  }
+
+  /**
+   * Delegates to the <code>isErrorEnabled<code> method of the wrapped 
+   * <code>org.slf4j.Logger</code> instance.
+   */
+  public boolean isFatalEnabled() {
+    return logger.isErrorEnabled();
+  }
+
+  /**
+   * Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
+   */
+  public boolean isInfoEnabled() {
+    return logger.isInfoEnabled();
+  }
+
+  /**
+   * Delegates to the <code>isDebugEnabled<code> method of the wrapped 
+   * <code>org.slf4j.Logger</code> instance.
+   */
+  public boolean isTraceEnabled() {
+    return logger.isDebugEnabled();
+  }
+
+  /**
+   * Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
+   */
+  public boolean isWarnEnabled() {
+    return logger.isWarnEnabled();
+  }
+
+  /**
+   * Converts the input parameter to String and then delegates to 
+   * the debug method of the wrapped <code>org.slf4j.Logger</code> instance.
+   * 
+   * @param message the message to log. Converted to [EMAIL PROTECTED] String} 
 
+   */
+  public void trace(Object message) {
+    logger.debug(String.valueOf(message));
+  }
+
+  /**
+   * Converts the first input parameter to String and then delegates to 
+   * the debug method of the wrapped <code>org.slf4j.Logger</code> instance.
+   * 
+   * @param message the message to log. Converted to [EMAIL PROTECTED] String} 
 
+   * @param t the exception to log
+   */
+  public void trace(Object message, Throwable t) {
+    logger.debug(String.valueOf(message), t);
+  }
+
+  /**
+   * Converts the input parameter to String and then delegates to the wrapped 
+   * <code>org.slf4j.Logger</code> instance.
+   * 
+   * @param message the message to log. Converted to [EMAIL PROTECTED] String} 
+   */
+  public void debug(Object message) {
+    logger.debug(String.valueOf(message));
+  }
+
+  /**
+   * Converts the first input parameter to String and then delegates to 
+   * the wrapped <code>org.slf4j.Logger</code> instance.
+   * 
+   * @param message the message to log. Converted to [EMAIL PROTECTED] String} 
 
+   * @param t the exception to log
+   */
+  public void debug(Object message, Throwable t) {
+    logger.debug(String.valueOf(message), t);
+  }
+
+  /**
+   * Converts the input parameter to String and then delegates to the wrapped 
+   * <code>org.slf4j.Logger</code> instance.
+   * 
+   * @param message the message to log. Converted to [EMAIL PROTECTED] String} 
+   */
+  public void info(Object message) {
+    logger.info(String.valueOf(message));
+  }
+
+  /**
+   * Converts the first input parameter to String and then delegates to 
+   * the wrapped <code>org.slf4j.Logger</code> instance.
+   * 
+   * @param message the message to log. Converted to [EMAIL PROTECTED] String} 
 
+   * @param t the exception to log
+   */
+  public void info(Object message, Throwable t) {
+    logger.info(String.valueOf(message), t);
+  }
+
+  /**
+   * Converts the input parameter to String and then delegates to the wrapped 
+   * <code>org.slf4j.Logger</code> instance.
+   * 
+   * @param message the message to log. Converted to [EMAIL PROTECTED] String} 
 
+   */
+  public void warn(Object message) {
+    logger.warn(String.valueOf(message));
+  }
+
+  /**
+   * Converts the first input parameter to String and then delegates to 
+   * the wrapped <code>org.slf4j.Logger</code> instance.
+   * 
+   * @param message the message to log. Converted to [EMAIL PROTECTED] String} 
 
+   * @param t the exception to log
+   */
+  public void warn(Object message, Throwable t) {
+    logger.warn(String.valueOf(message), t);
+  }
+
+  /**
+   * Converts the input parameter to String and then delegates to the wrapped 
+   * <code>org.slf4j.Logger</code> instance.
+   * 
+   * @param message the message to log. Converted to [EMAIL PROTECTED] String} 
 
+   */
+  public void error(Object message) {
+    logger.error(String.valueOf(message));
+  }
+
+  /**
+   * Converts the first input parameter to String and then delegates to 
+   * the wrapped <code>org.slf4j.Logger</code> instance.
+   * 
+   * @param message the message to log. Converted to [EMAIL PROTECTED] String} 
 
+   * @param t the exception to log
+   */
+  public void error(Object message, Throwable t) {
+    logger.error(String.valueOf(message), t);
+  }
+
+
+ 
+  /**
+   * Converts the input parameter to String and then delegates to 
+   * the error method of the wrapped <code>org.slf4j.Logger</code> instance.
+   * 
+   * @param message the message to log. Converted to [EMAIL PROTECTED] String} 
 
+   */
+  public void fatal(Object message) {
+    logger.error(String.valueOf(message));
+  }
+
+  /**
+   * Converts the first input parameter to String and then delegates to 
+   * the error method of the wrapped <code>org.slf4j.Logger</code> instance.
+   * 
+   * @param message the message to log. Converted to [EMAIL PROTECTED] String} 
 
+   * @param t the exception to log
+   */
+  public void fatal(Object message, Throwable t) {
+    logger.error(String.valueOf(message), t);
+  }
+
+}
\ No newline at end of file

Added: 
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/package.html
==============================================================================
--- (empty file)
+++ 
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/package.html
    Tue Aug 15 22:41:06 2006
@@ -0,0 +1,5 @@
+<body>
+
+  <p>SLF4J based implementation of commons-logging wrapper APIs.</p>
+
+</body>

Added: 
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/package.html
==============================================================================
--- (empty file)
+++ 
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/package.html
 Tue Aug 15 22:41:06 2006
@@ -0,0 +1,169 @@
+<!--
+
+ Copyright 2001-2004 The Apache Software Foundation.
+ 
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ 
+      http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+<body>
+<p>Jakarta Commons Logging implemented over SLF4J.</p>
+
+
+<h3>Overview</h3>
+
+<p>This package contains the same public user interface as <a
+href="http://jakarta.apache.org/commons/logging/";>Jakarta Commons
+Logging (JCL)</a>. It is intended as a 100% compatible drop-in
+replacement for the original JCL version 1.0.4.
+</p>
+
+<p>As the original JCL version 1.0.4, the present version supports
+various logging APIs. It differs from the original in implementation
+but not the public API. This implementation uses SLF4J under the
+covers. As as such, all the logging systems that SLF4J supports,
+e.g. NOP, Simple, JDK14, nlog4j are supported by this version of JCL.
+</p>
+
+<h3>Quick Start Guide</h3>
+
+<p>For those impatient to just get on with it, the following example
+illustrates the typical declaration and use of a logger that is named (by
+convention) after the calling class:
+
+<pre>
+    import org.apache.commons.logging.Log;
+    import org.apache.commons.logging.LogFactory;
+
+    public class Foo {
+
+        static Log log = LogFactory.getLog(Foo.class);
+
+        public void foo() {
+            ...
+            try {
+                if (log.isDebugEnabled()) {
+                    log.debug("About to do something to object " + name);
+                }
+                name.bar();
+            } catch (IllegalStateException e) {
+                log.error("Something bad happened to " + name, e);
+            }
+            ...
+        }
+</pre>
+
+<h3>Configuring the Commons Logging Package</h3>
+
+<p>In this version of JCL, the selection of the logging system to use
+is chosen by the underlying SLF4J API. Consequently, all JCL-specific
+configration parameters are ignored.
+</p>
+
+<h4>Choosing a <code>LogFactory</code> Implementation</h4>
+
+<p>From an application perspective, the first requirement is to
+retrieve an object reference to the <code>LogFactory</code> instance
+that will be used to create <code><a href="Log.html">Log</a></code>
+instances for this application.  This is normally accomplished by
+calling the static <code>getFactory()</code> method.  This method
+always returns the same factory, i.e. a unique instance of the <a
+href="impl/SLF4FLogFactory.html">SLF4FLogFactory</a> class.
+</p>
+
+
+
+<h4>Configuring the Underlying Logging System</h4>
+
+<p>The basic principle is that the user is totally responsible for the
+configuration of the underlying logging system.
+Commons-logging should not change the existing configuration.</p>
+
+<p>Each individual <a href="Log.html">Log</a> implementation may
+support its own configuration properties.  These will be documented in the
+class descriptions for the corresponding implementation class.</p>
+
+<p>Finally, some <code>Log</code> implementations (such as the one for Log4J)
+require an external configuration file for the entire logging environment.
+This file should be prepared in a manner that is specific to the actual logging
+technology being used.</p>
+
+
+<h3>Using the Logging Package APIs</h3>
+
+<p>Use of the Logging Package APIs, from the perspective of an application
+component, consists of the following steps:</p>
+<ol>
+<li>Acquire a reference to an instance of
+    <a href="Log.html">org.apache.commons.logging.Log</a>, by calling the
+    factory method
+    <a href="LogFactory.html#getInstance(java.lang.String)">
+    LogFactory.getInstance(String name)</a>.  Your application can contain
+    references to multiple loggers that are used for different
+    purposes.  A typical scenario for a server application is to have each
+    major component of the server use its own Log instance.</li>
+<li>Cause messages to be logged (if the corresponding detail level is enabled)
+    by calling appropriate methods (<code>trace()</code>, <code>debug()</code>,
+    <code>info()</code>, <code>warn()</code>, <code>error</code>, and
+    <code>fatal()</code>).</li>
+</ol>
+
+<p>For convenience, <code>LogFactory</code> also offers a static method
+<code>getLog()</code> that combines the typical two-step pattern:</p>
+<pre>
+  Log log = LogFactory.getFactory().getInstance(Foo.class);
+</pre>
+<p>into a single method call:</p>
+<pre>
+  Log log = LogFactory.getLog(Foo.class);
+</pre>
+
+<p>For example, you might use the following technique to initialize and
+use a <a href="Log.html">Log</a> instance in an application component:</p>
+<pre>
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class MyComponent {
+
+  protected static Log log =
+    LogFactory.getLog(MyComponent.class);
+
+  // Called once at startup time
+  public void start() {
+    ...
+    log.info("MyComponent started");
+    ...
+  }
+
+  // Called once at shutdown time
+  public void stop() {
+    ...
+    log.info("MyComponent stopped");
+    ...
+  }
+
+  // Called repeatedly to process a particular argument value
+  // which you want logged if debugging is enabled
+  public void process(String value) {
+    ...
+    // Do the string concatenation only if logging is enabled
+    if (log.isDebugEnabled())
+      log.debug("MyComponent processing " + value);
+    ...
+  }
+
+}
+</pre>
+
+</body>

Added: 
slf4j/trunk/jcl104-over-slf4j/src/test/java/org/apache/commons/logging/InvokeJCLTest.java
==============================================================================
--- (empty file)
+++ 
slf4j/trunk/jcl104-over-slf4j/src/test/java/org/apache/commons/logging/InvokeJCLTest.java
   Tue Aug 15 22:41:06 2006
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * Copyright (c) 2004-2005 QOS.ch
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+
+package org.apache.commons.logging;
+
+import junit.framework.TestCase;
+
+
+public class InvokeJCLTest extends TestCase {
+
+  public void testIsEnabledAPI() {
+    // assume that we are running over slf4j-simple
+    Log log = LogFactory.getLog(InvokeJCLTest.class);
+    assertFalse(log.isTraceEnabled());
+    assertFalse(log.isDebugEnabled());
+    assertTrue(log.isInfoEnabled());
+    assertTrue(log.isWarnEnabled());
+    assertTrue(log.isErrorEnabled());
+    assertTrue(log.isFatalEnabled());
+  }
+  
+  public void testPrintAPI() {
+    Log log = LogFactory.getLog(InvokeJCLTest.class);
+    Exception e = new Exception("just testing");
+  
+    log.trace(null);
+    log.trace("trace message");
+    
+    log.debug(null);
+    log.debug("debug message");
+    
+    log.info(null);
+    log.info("info  message");
+    
+    log.warn(null);
+    log.warn("warn message");
+
+    log.error(null);
+    log.error("error message");
+
+    log.fatal(null);
+    log.fatal("fatal message");
+    
+
+    log.trace(null, e);
+    log.trace("trace message", e);
+    
+    log.debug(null, e);
+    log.debug("debug message", e);
+    
+    log.info(null, e);    
+    log.info("info  message", e);
+    
+    log.warn(null, e);
+    log.warn("warn message", e);
+    
+    log.error(null, e);
+    log.error("error message", e);
+    
+    log.fatal(null, e);
+    log.fatal("fatal message", e);
+  }
+}
_______________________________________________
dev mailing list
[email protected]
http://slf4j.org/mailman/listinfo/dev

Reply via email to