[slf4j-dev] svn commit: r121 - in slf4j/branches/marker-experiment/src/java/org/slf4j: . impl spi

ceki at slf4j.org ceki at slf4j.org
Wed Jul 13 18:50:48 CEST 2005


Author: ceki
Date: Wed Jul 13 18:50:46 2005
New Revision: 121

Added:
   slf4j/branches/marker-experiment/src/java/org/slf4j/ILoggerrFactory.java
   slf4j/branches/marker-experiment/src/java/org/slf4j/IMarkerFactory.java
   slf4j/branches/marker-experiment/src/java/org/slf4j/Util.java
   slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerFactory.java
      - copied, changed from r102, slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerAdapterFactory.java
   slf4j/branches/marker-experiment/src/java/org/slf4j/impl/NOPLoggerFactory.java
      - copied, changed from r102, slf4j/branches/marker-experiment/src/java/org/slf4j/impl/NOPLoggerAdapterFactory.java
   slf4j/branches/marker-experiment/src/java/org/slf4j/impl/SimpleLoggerFactory.java
      - copied, changed from r102, slf4j/branches/marker-experiment/src/java/org/slf4j/impl/SimpleLoggerAdapterFactory.java
Removed:
   slf4j/branches/marker-experiment/src/java/org/slf4j/CompositeMarker.java
   slf4j/branches/marker-experiment/src/java/org/slf4j/StarMarker.java
   slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerAdapterFactory.java
   slf4j/branches/marker-experiment/src/java/org/slf4j/impl/NOPLoggerAdapterFactory.java
   slf4j/branches/marker-experiment/src/java/org/slf4j/impl/SimpleLoggerAdapterFactory.java
   slf4j/branches/marker-experiment/src/java/org/slf4j/spi/LoggerAdapterFactory.java
Modified:
   slf4j/branches/marker-experiment/src/java/org/slf4j/Marker.java
   slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerAdapter.java
   slf4j/branches/marker-experiment/src/java/org/slf4j/impl/SimpleLogger.java
Log:

- LoggerAdapterFactory interface renamed as ILoggerFactory. 
  Altough contrary to the java naming conventions, the I prefix 
  was required given that the name LoggerFactory was already taken.

- XLoggerAdapterFactory renamed as XLoggerFactory. The new names are
  simpler to remember.

- Added IMarkerFactory interhace, Marker interface, and Basic implementations.

- MarkerFactory is a static Marker factory

Added: slf4j/branches/marker-experiment/src/java/org/slf4j/ILoggerrFactory.java
==============================================================================
--- (empty file)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/ILoggerrFactory.java	Wed Jul 13 18:50:46 2005
@@ -0,0 +1,52 @@
+/* 
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * 
+ * 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.slf4j;
+
+
+/**
+ * ILoggerrFactory interface is used internally by {@link
+ * LoggerFactory}.
+ * 
+ * <p>Only developers wishing to write new SLF4J adapters need to
+ * worry about this interface.
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ *
+ */
+public interface ILoggerrFactory {
+  
+  /**
+   * Return the appropriate named {@link Logger} instance.
+   */
+  public Logger getLogger(String name);
+}

Added: slf4j/branches/marker-experiment/src/java/org/slf4j/IMarkerFactory.java
==============================================================================
--- (empty file)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/IMarkerFactory.java	Wed Jul 13 18:50:46 2005
@@ -0,0 +1,52 @@
+/*
+ * 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.slf4j;
+
+
+/**
+ * Implementaitons of this interface are used to manufacture {@link Marker}
+ * instances.
+ *
+ *  * @author Ceki G&uuml;lc&uuml;
+ */
+public interface IMarkerFactory {
+    /**
+     * Manufacture a {@link Marker} instance by name. If the instance has been 
+     * created earlier, return the previously created instance. 
+     * 
+     * @param name the name of the marker to be created
+     * @return a Marker instance
+     */
+    Marker getMarker(String name);
+}

Modified: slf4j/branches/marker-experiment/src/java/org/slf4j/Marker.java
==============================================================================
--- slf4j/branches/marker-experiment/src/java/org/slf4j/Marker.java	(original)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/Marker.java	Wed Jul 13 18:50:46 2005
@@ -33,84 +33,17 @@
 
 package org.slf4j;
 
-import java.util.Hashtable;
-import java.util.Map;
+import java.util.Iterator;
 
-
-public class Marker {
-  public static final Marker STAR = new StarMarker();
-  static Map markerMap = new Hashtable();
-  String name;
-
-  Marker(String name) {
-    this.name = name;
-  }
-
-  public static final Marker getMarker(String name) {
-    if (name == null) {
-      throw new IllegalArgumentException("Marker name cannot be null");
-    }
-    if (name.equals(StarMarker.STAR_STR)) {
-      return STAR;
-    }
-
-    Marker marker = (Marker) markerMap.get(name);
-    if (marker == null) {
-      marker = new Marker(name);
-      markerMap.put(name, marker);
-    }
-
-    return marker;
-  }
-
-  //  public final static Marker getCompositeMarker(String name) {
-  //    if (name == null) {
-  //      throw new IllegalArgumentException("Marker name cannot be null");
-  //    }
-  //    Marker marker = (Marker) markerMap.get(name);
-  //    if (marker == null) {
-  //      marker = new CompositeMarker(name);
-  //      markerMap.put(name, marker);
-  //    }
-  //
-  //    return marker;
-  //  }
-  public String getName() {
-    return name;
-  }
-
-  public boolean matches(Marker marker) {
-    if ((this == marker) || (STAR == marker)) {
-      return true;
-    }
-
-    return false;
-  }
-
-  public boolean matches(String name) {
-    if (this.name.equals(name)) {
-      return true;
-    }
-
-    // Every marker matches "*"
-    if (StarMarker.STAR_STR.equals(name)) {
-      return true;
-    }
-    return false;
-  }
-
-  //  public void add(Marker child) {
-  //      throw new IllegalStateException(
-  //        "Cannot add child [" + child.getName()
-  //        + "] to immutable Marker named [" + name + "].");
-  //    
-  //  }
-  //
-  //  void makeImmutable() {
-  //      // primitive marker is always immutable
-  //  }
-  //
-  //  public boolean isImmutable() {
-  //    return true;
-  //  }
+public interface Marker {
+ 
+  public String getName();
+
+  public void add(Marker child);
+  public boolean remove(Marker child);
+  public boolean hasChildren();
+  public Iterator iterator();
+  
+//  void makeImmutable();
+//  public boolean isImmutable();
 }

Added: slf4j/branches/marker-experiment/src/java/org/slf4j/Util.java
==============================================================================
--- (empty file)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/Util.java	Wed Jul 13 18:50:46 2005
@@ -0,0 +1,50 @@
+/*
+ * 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.slf4j;
+
+
+/**
+ *
+ * A package internal utility class.
+ *
+ * @author Ceki Gulcu
+ */
+class Util {
+    
+  static void reportFailure(String msg, Throwable t) {
+    System.err.println(msg);
+    System.err.println("Reported exception follows.");
+    t.printStackTrace();
+  }
+}

Modified: slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerAdapter.java
==============================================================================
--- slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerAdapter.java	(original)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerAdapter.java	Wed Jul 13 18:50:46 2005
@@ -49,7 +49,7 @@
   final java.util.logging.Logger logger;
 
   // WARN: JDK14LoggerAdapter constructor should have only package access so that
-  // only JDK14LoggerAdapterFactory be able to create one.
+  // only JDK14LoggerFactory be able to create one.
   JDK14LoggerAdapter(java.util.logging.Logger logger) {
     this.logger = logger;
   }

Copied: slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerFactory.java (from r102, slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerAdapterFactory.java)
==============================================================================
--- slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerAdapterFactory.java	(original)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerFactory.java	Wed Jul 13 18:50:46 2005
@@ -34,28 +34,28 @@
 package org.slf4j.impl;
 
 import org.slf4j.Logger;
-import org.slf4j.spi.LoggerAdapterFactory;
+import org.slf4j.ILoggerrFactory;
 
 import java.util.HashMap;
 import java.util.Map;
 
 /**
- * JDK14LoggerAdapterFactory is an implementation of {@link LoggerAdapterFactory}
+ * JDK14LoggerFactory is an implementation of {@link ILoggerrFactory}
  * returning the appropriate named {@link JDK14LoggerAdapter} instance.
  *
  * @author Ceki G&uuml;lc&uuml;
  */
-public class JDK14LoggerAdapterFactory implements LoggerAdapterFactory {
+public class JDK14LoggerFactory implements ILoggerrFactory {
 
   // key: name (String), value: a JDK14LoggerAdapter;
   Map loggerMap;
 
-  public JDK14LoggerAdapterFactory() {
+  public JDK14LoggerFactory() {
     loggerMap = new HashMap();
   }
 
   /* (non-Javadoc)
-   * @see org.slf4j.LoggerAdapterFactory#getLogger(java.lang.String)
+   * @see org.slf4j.ILoggerrFactory#getLogger(java.lang.String)
    */
   public Logger getLogger(String name) {
     Logger ulogger = (Logger) loggerMap.get(name);
@@ -66,11 +66,4 @@
     }
     return ulogger;
   }
-
-  /* (non-Javadoc)
-   * @see org.slf4j.LoggerAdapterFactory#getLogger(java.lang.String, java.lang.String)
-   */
-  public Logger getLogger(String domainName, String subDomainName) {
-    return getLogger(domainName);
-  }
 }

Copied: slf4j/branches/marker-experiment/src/java/org/slf4j/impl/NOPLoggerFactory.java (from r102, slf4j/branches/marker-experiment/src/java/org/slf4j/impl/NOPLoggerAdapterFactory.java)
==============================================================================
--- slf4j/branches/marker-experiment/src/java/org/slf4j/impl/NOPLoggerAdapterFactory.java	(original)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/impl/NOPLoggerFactory.java	Wed Jul 13 18:50:46 2005
@@ -34,26 +34,24 @@
 package org.slf4j.impl;
 
 import org.slf4j.Logger;
-import org.slf4j.spi.LoggerAdapterFactory;
+import org.slf4j.ILoggerrFactory;
 
 
 /**
- * NOPLoggerAdapterFactory is an trivial implementation of {@link
- * LoggerAdapterFactory} which always returns the unique instance of
+ * NOPLoggerFactory is an trivial implementation of {@link
+ * ILoggerrFactory} which always returns the unique instance of
  * NOPLogger.
  * 
  * @author Ceki Gulcu
  */
-public class NOPLoggerAdapterFactory implements LoggerAdapterFactory {
+public class NOPLoggerFactory implements ILoggerrFactory {
   
-  public NOPLoggerAdapterFactory() {
+  public NOPLoggerFactory() {
     // nothing to do
   }
   
   public Logger getLogger(String name) {
     return NOPLogger.NOP_LOGGER;
   }
-  public Logger getLogger(String domainName, String subDomainName) {
-    return NOPLogger.NOP_LOGGER;  
-  }  
+
 }

Modified: slf4j/branches/marker-experiment/src/java/org/slf4j/impl/SimpleLogger.java
==============================================================================
--- slf4j/branches/marker-experiment/src/java/org/slf4j/impl/SimpleLogger.java	(original)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/impl/SimpleLogger.java	Wed Jul 13 18:50:46 2005
@@ -77,7 +77,7 @@
   static private String ERROR_STR = "ERROR";
   
   /**
-   * Package access allows only {@link SimpleLoggerAdapterFactory} to instantiate 
+   * Package access allows only {@link SimpleLoggerFactory} to instantiate 
    * SimpleLogger instances.
    */
   SimpleLogger(String name) {

Copied: slf4j/branches/marker-experiment/src/java/org/slf4j/impl/SimpleLoggerFactory.java (from r102, slf4j/branches/marker-experiment/src/java/org/slf4j/impl/SimpleLoggerAdapterFactory.java)
==============================================================================
--- slf4j/branches/marker-experiment/src/java/org/slf4j/impl/SimpleLoggerAdapterFactory.java	(original)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/impl/SimpleLoggerFactory.java	Wed Jul 13 18:50:46 2005
@@ -37,20 +37,20 @@
 import java.util.Map;
 
 import org.slf4j.Logger;
-import org.slf4j.spi.LoggerAdapterFactory;
+import org.slf4j.ILoggerrFactory;
 
 
 /**
- * An implementation of {@link LoggerAdapterFactory} which always returns
+ * An implementation of {@link ILoggerrFactory} which always returns
  * {@link SimpleLogger} instances.
  * 
  * @author Ceki G&uuml;lc&uuml;
  */
-public class SimpleLoggerAdapterFactory implements LoggerAdapterFactory {
+public class SimpleLoggerFactory implements ILoggerrFactory {
 
   Map map;
   
-  public SimpleLoggerAdapterFactory() {
+  public SimpleLoggerFactory() {
     map = new HashMap();
   }
 
@@ -70,7 +70,7 @@
 
   /*
    *  (non-Javadoc)
-   * @see org.slf4j.LoggerAdapterFactory#getLogger(java.lang.String, java.lang.String)
+   * @see org.slf4j.ILoggerrFactory#getLogger(java.lang.String, java.lang.String)
    */
   public Logger getLogger(String domainName, String subDomainName) {
     return getLogger(domainName);



More information about the slf4j-dev mailing list