Use Hashtable instead of HashMap, for JDK 1.1
compatibility, and to solve sync issues git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138851 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/LogSource.java,v 1.10 2002/01/17 22:55:43 rdonkin Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/LogSource.java,v 1.11 2002/02/03 01:28:00 sanders Exp $
|
||||||
* $Revision: 1.10 $
|
* $Revision: 1.11 $
|
||||||
* $Date: 2002/01/17 22:55:43 $
|
* $Date: 2002/02/03 01:28:00 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -62,10 +62,8 @@
|
|||||||
package org.apache.commons.logging;
|
package org.apache.commons.logging;
|
||||||
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.Iterator;
|
import java.util.Hashtable;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,13 +92,13 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @author Rod Waldhoff
|
* @author Rod Waldhoff
|
||||||
* @version $Id: LogSource.java,v 1.10 2002/01/17 22:55:43 rdonkin Exp $
|
* @version $Id: LogSource.java,v 1.11 2002/02/03 01:28:00 sanders Exp $
|
||||||
*/
|
*/
|
||||||
public class LogSource {
|
public class LogSource {
|
||||||
|
|
||||||
// ------------------------------------------------------- Class Attributes
|
// ------------------------------------------------------- Class Attributes
|
||||||
|
|
||||||
static protected HashMap logs = new HashMap();
|
static protected Hashtable logs = new Hashtable();
|
||||||
|
|
||||||
/** Is log4j available (in the current classpath) */
|
/** Is log4j available (in the current classpath) */
|
||||||
static protected boolean log4jIsAvailable = false;
|
static protected boolean log4jIsAvailable = false;
|
||||||
@@ -118,7 +116,7 @@ public class LogSource {
|
|||||||
|
|
||||||
// Is Log4J Available?
|
// Is Log4J Available?
|
||||||
try {
|
try {
|
||||||
if(null != Class.forName("org.apache.log4j.Category")) {
|
if (null != Class.forName("org.apache.log4j.Category")) {
|
||||||
log4jIsAvailable = true;
|
log4jIsAvailable = true;
|
||||||
} else {
|
} else {
|
||||||
log4jIsAvailable = false;
|
log4jIsAvailable = false;
|
||||||
@@ -129,7 +127,7 @@ public class LogSource {
|
|||||||
|
|
||||||
// Is JDK 1.4 Logging Available?
|
// Is JDK 1.4 Logging Available?
|
||||||
try {
|
try {
|
||||||
if(null != Class.forName("java.util.logging.Logger")) {
|
if (null != Class.forName("java.util.logging.Logger")) {
|
||||||
jdk14IsAvailable = true;
|
jdk14IsAvailable = true;
|
||||||
} else {
|
} else {
|
||||||
jdk14IsAvailable = false;
|
jdk14IsAvailable = false;
|
||||||
@@ -142,14 +140,15 @@ public class LogSource {
|
|||||||
String name = null;
|
String name = null;
|
||||||
try {
|
try {
|
||||||
name = System.getProperty("org.apache.commons.logging.log");
|
name = System.getProperty("org.apache.commons.logging.log");
|
||||||
} catch (Throwable t) { }
|
} catch (Throwable t) {
|
||||||
|
}
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
try {
|
try {
|
||||||
setLogImplementation(name);
|
setLogImplementation(name);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
try {
|
try {
|
||||||
setLogImplementation
|
setLogImplementation
|
||||||
("org.apache.commons.logging.NoOpLog");
|
("org.apache.commons.logging.NoOpLog");
|
||||||
} catch (Throwable u) {
|
} catch (Throwable u) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@@ -158,18 +157,18 @@ public class LogSource {
|
|||||||
try {
|
try {
|
||||||
if (log4jIsAvailable) {
|
if (log4jIsAvailable) {
|
||||||
setLogImplementation
|
setLogImplementation
|
||||||
("org.apache.commons.logging.Log4JCategoryLog");
|
("org.apache.commons.logging.Log4JCategoryLog");
|
||||||
} else if (jdk14IsAvailable) {
|
} else if (jdk14IsAvailable) {
|
||||||
setLogImplementation
|
setLogImplementation
|
||||||
("org.apache.commons.logging.Jdk14Logger");
|
("org.apache.commons.logging.Jdk14Logger");
|
||||||
} else {
|
} else {
|
||||||
setLogImplementation
|
setLogImplementation
|
||||||
("org.apache.commons.logging.NoOpLog");
|
("org.apache.commons.logging.NoOpLog");
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
try {
|
try {
|
||||||
setLogImplementation
|
setLogImplementation
|
||||||
("org.apache.commons.logging.NoOpLog");
|
("org.apache.commons.logging.NoOpLog");
|
||||||
} catch (Throwable u) {
|
} catch (Throwable u) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@@ -198,9 +197,9 @@ public class LogSource {
|
|||||||
* of the log).
|
* of the log).
|
||||||
*/
|
*/
|
||||||
static public void setLogImplementation(String classname) throws
|
static public void setLogImplementation(String classname) throws
|
||||||
LinkageError, ExceptionInInitializerError,
|
LinkageError, ExceptionInInitializerError,
|
||||||
NoSuchMethodException, SecurityException,
|
NoSuchMethodException, SecurityException,
|
||||||
ClassNotFoundException {
|
ClassNotFoundException {
|
||||||
try {
|
try {
|
||||||
Class logclass = Class.forName(classname);
|
Class logclass = Class.forName(classname);
|
||||||
Class[] argtypes = new Class[1];
|
Class[] argtypes = new Class[1];
|
||||||
@@ -219,8 +218,8 @@ public class LogSource {
|
|||||||
* argument (containing the name of the log).
|
* argument (containing the name of the log).
|
||||||
*/
|
*/
|
||||||
static public void setLogImplementation(Class logclass) throws
|
static public void setLogImplementation(Class logclass) throws
|
||||||
LinkageError, ExceptionInInitializerError,
|
LinkageError, ExceptionInInitializerError,
|
||||||
NoSuchMethodException, SecurityException {
|
NoSuchMethodException, SecurityException {
|
||||||
Class[] argtypes = new Class[1];
|
Class[] argtypes = new Class[1];
|
||||||
argtypes[0] = "".getClass();
|
argtypes[0] = "".getClass();
|
||||||
logImplctor = logclass.getConstructor(argtypes);
|
logImplctor = logclass.getConstructor(argtypes);
|
||||||
@@ -229,10 +228,10 @@ public class LogSource {
|
|||||||
|
|
||||||
/** Get a <code>Log</code> instance by class name */
|
/** Get a <code>Log</code> instance by class name */
|
||||||
static public Log getInstance(String name) {
|
static public Log getInstance(String name) {
|
||||||
Log log = (Log)(logs.get(name));
|
Log log = (Log) (logs.get(name));
|
||||||
if(null == log) {
|
if (null == log) {
|
||||||
log = makeNewLogInstance(name);
|
log = makeNewLogInstance(name);
|
||||||
logs.put(name,log);
|
logs.put(name, log);
|
||||||
}
|
}
|
||||||
return log;
|
return log;
|
||||||
}
|
}
|
||||||
@@ -274,11 +273,11 @@ public class LogSource {
|
|||||||
try {
|
try {
|
||||||
Object[] args = new Object[1];
|
Object[] args = new Object[1];
|
||||||
args[0] = name;
|
args[0] = name;
|
||||||
log = (Log)(logImplctor.newInstance(args));
|
log = (Log) (logImplctor.newInstance(args));
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
log = null;
|
log = null;
|
||||||
}
|
}
|
||||||
if(null == log) {
|
if (null == log) {
|
||||||
log = new NoOpLog(name);
|
log = new NoOpLog(name);
|
||||||
}
|
}
|
||||||
return log;
|
return log;
|
||||||
@@ -291,7 +290,7 @@ public class LogSource {
|
|||||||
* all logs known to me.
|
* all logs known to me.
|
||||||
*/
|
*/
|
||||||
static public String[] getLogNames() {
|
static public String[] getLogNames() {
|
||||||
return (String[])(logs.keySet().toArray(new String[logs.size()]));
|
return (String[]) (logs.keySet().toArray(new String[logs.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user