[slf4j-dev] svn commit: r102 - in slf4j/branches/marker-experiment/src/java/org/slf4j: . impl
ceki at slf4j.org
ceki at slf4j.org
Thu Jun 30 15:55:49 CEST 2005
Author: ceki
Date: Thu Jun 30 15:55:48 2005
New Revision: 102
Added:
slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerAdapter.java
- copied, changed from r100, slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14Logger.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
Removed:
slf4j/branches/marker-experiment/src/java/org/slf4j/LoggerAdapterFactory.java
slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14Logger.java
slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerFA.java
slf4j/branches/marker-experiment/src/java/org/slf4j/impl/NOPLoggerFA.java
slf4j/branches/marker-experiment/src/java/org/slf4j/impl/SimpleLoggerFA.java
Modified:
slf4j/branches/marker-experiment/src/java/org/slf4j/impl/SimpleLogger.java
Log:
- Renamed files of the form XYZLoggerFA as XYZLoggerAdapterFactory
- Renamed JDK14Logger as JDK14LoggerApapter because, the class adapts java.util.logging.Logger class
to conform to the org.slf4j.Logger interface.
Copied: slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerAdapter.java (from r100, slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14Logger.java)
==============================================================================
--- slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14Logger.java (original)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerAdapter.java Thu Jun 30 15:55:48 2005
@@ -45,12 +45,12 @@
* @author Ceki Gülcü
*/
-public class JDK14Logger implements Logger {
+public class JDK14LoggerAdapter implements Logger {
final java.util.logging.Logger logger;
- // WARN: JDK14Logger constructor should have only package access so that
- // only JDK14LoggerFA be able to create one.
- JDK14Logger(java.util.logging.Logger logger) {
+ // WARN: JDK14LoggerAdapter constructor should have only package access so that
+ // only JDK14LoggerAdapterFactory be able to create one.
+ JDK14LoggerAdapter(java.util.logging.Logger logger) {
this.logger = logger;
}
Added: slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerAdapterFactory.java
==============================================================================
--- (empty file)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/impl/JDK14LoggerAdapterFactory.java Thu Jun 30 15:55:48 2005
@@ -0,0 +1,76 @@
+/*
+ * 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.impl;
+
+import org.slf4j.Logger;
+import org.slf4j.spi.LoggerAdapterFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * JDK14LoggerAdapterFactory is an implementation of {@link LoggerAdapterFactory}
+ * returning the appropriate named {@link JDK14LoggerAdapter} instance.
+ *
+ * @author Ceki Gülcü
+ */
+public class JDK14LoggerAdapterFactory implements LoggerAdapterFactory {
+
+ // key: name (String), value: a JDK14LoggerAdapter;
+ Map loggerMap;
+
+ public JDK14LoggerAdapterFactory() {
+ loggerMap = new HashMap();
+ }
+
+ /* (non-Javadoc)
+ * @see org.slf4j.LoggerAdapterFactory#getLogger(java.lang.String)
+ */
+ public Logger getLogger(String name) {
+ Logger ulogger = (Logger) loggerMap.get(name);
+ if (ulogger == null) {
+ java.util.logging.Logger logger = java.util.logging.Logger.getLogger(name);
+ ulogger = new JDK14LoggerAdapter(logger);
+ loggerMap.put(name, ulogger);
+ }
+ 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);
+ }
+}
Added: slf4j/branches/marker-experiment/src/java/org/slf4j/impl/NOPLoggerAdapterFactory.java
==============================================================================
--- (empty file)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/impl/NOPLoggerAdapterFactory.java Thu Jun 30 15:55:48 2005
@@ -0,0 +1,59 @@
+/*
+ * 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.impl;
+
+import org.slf4j.Logger;
+import org.slf4j.spi.LoggerAdapterFactory;
+
+
+/**
+ * NOPLoggerAdapterFactory is an trivial implementation of {@link
+ * LoggerAdapterFactory} which always returns the unique instance of
+ * NOPLogger.
+ *
+ * @author Ceki Gulcu
+ */
+public class NOPLoggerAdapterFactory implements LoggerAdapterFactory {
+
+ public NOPLoggerAdapterFactory() {
+ // 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 Thu Jun 30 15:55:48 2005
@@ -77,7 +77,7 @@
static private String ERROR_STR = "ERROR";
/**
- * Package access allows only {@link SimpleLoggerFA} to instantiate
+ * Package access allows only {@link SimpleLoggerAdapterFactory} to instantiate
* SimpleLogger instances.
*/
SimpleLogger(String name) {
Added: slf4j/branches/marker-experiment/src/java/org/slf4j/impl/SimpleLoggerAdapterFactory.java
==============================================================================
--- (empty file)
+++ slf4j/branches/marker-experiment/src/java/org/slf4j/impl/SimpleLoggerAdapterFactory.java Thu Jun 30 15:55:48 2005
@@ -0,0 +1,80 @@
+/*
+ * 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.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.spi.LoggerAdapterFactory;
+
+
+/**
+ * An implementation of {@link LoggerAdapterFactory} which always returns
+ * {@link SimpleLogger} instances.
+ *
+ * @author Ceki Gülcü
+ */
+public class SimpleLoggerAdapterFactory implements LoggerAdapterFactory {
+
+ Map map;
+
+ public SimpleLoggerAdapterFactory() {
+ map = new HashMap();
+ }
+
+
+ /**
+ * Return an appropriate {@link SimpleLogger} instance by name.
+ *
+ */
+ public Logger getLogger(String name) {
+ Logger ulogger = (Logger) map.get(name);
+ if(ulogger == null) {
+ ulogger = new SimpleLogger(name);
+ map.put(name, ulogger);
+ }
+ 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);
+ }
+
+
+}
More information about the slf4j-dev
mailing list