You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sa...@apache.org on 2002/02/03 02:28:00 UTC
cvs commit: jakarta-commons/logging/src/java/org/apache/commons/logging LogSource.java
sanders 02/02/02 17:28:00
Modified: logging/src/java/org/apache/commons/logging LogSource.java
Log:
Use Hashtable instead of HashMap, for JDK 1.1
compatibility, and to solve sync issues
Revision Changes Path
1.11 +30 -31 jakarta-commons/logging/src/java/org/apache/commons/logging/LogSource.java
Index: LogSource.java
===================================================================
RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/LogSource.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- LogSource.java 17 Jan 2002 22:55:43 -0000 1.10
+++ LogSource.java 3 Feb 2002 01:28:00 -0000 1.11
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/LogSource.java,v 1.10 2002/01/17 22:55:43 rdonkin Exp $
- * $Revision: 1.10 $
- * $Date: 2002/01/17 22:55:43 $
+ * $Header: /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.11 $
+ * $Date: 2002/02/03 01:28:00 $
*
* ====================================================================
*
@@ -62,10 +62,8 @@
package org.apache.commons.logging;
-import java.util.HashMap;
import java.lang.reflect.Constructor;
-import java.util.Iterator;
-import java.lang.reflect.InvocationTargetException;
+import java.util.Hashtable;
/**
@@ -94,31 +92,31 @@
* </ul>
*
* @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 {
// ------------------------------------------------------- Class Attributes
-
- static protected HashMap logs = new HashMap();
+
+ static protected Hashtable logs = new Hashtable();
/** Is log4j available (in the current classpath) */
static protected boolean log4jIsAvailable = false;
/** Is JD 1.4 logging available */
static protected boolean jdk14IsAvailable = false;
-
+
/** Constructor for current log class */
static protected Constructor logImplctor = null;
// ----------------------------------------------------- Class Initializers
-
+
static {
// Is Log4J Available?
try {
- if(null != Class.forName("org.apache.log4j.Category")) {
+ if (null != Class.forName("org.apache.log4j.Category")) {
log4jIsAvailable = true;
} else {
log4jIsAvailable = false;
@@ -129,7 +127,7 @@
// Is JDK 1.4 Logging Available?
try {
- if(null != Class.forName("java.util.logging.Logger")) {
+ if (null != Class.forName("java.util.logging.Logger")) {
jdk14IsAvailable = true;
} else {
jdk14IsAvailable = false;
@@ -142,14 +140,15 @@
String name = null;
try {
name = System.getProperty("org.apache.commons.logging.log");
- } catch (Throwable t) { }
+ } catch (Throwable t) {
+ }
if (name != null) {
try {
setLogImplementation(name);
} catch (Throwable t) {
try {
setLogImplementation
- ("org.apache.commons.logging.NoOpLog");
+ ("org.apache.commons.logging.NoOpLog");
} catch (Throwable u) {
;
}
@@ -158,18 +157,18 @@
try {
if (log4jIsAvailable) {
setLogImplementation
- ("org.apache.commons.logging.Log4JCategoryLog");
+ ("org.apache.commons.logging.Log4JCategoryLog");
} else if (jdk14IsAvailable) {
setLogImplementation
- ("org.apache.commons.logging.Jdk14Logger");
+ ("org.apache.commons.logging.Jdk14Logger");
} else {
setLogImplementation
- ("org.apache.commons.logging.NoOpLog");
+ ("org.apache.commons.logging.NoOpLog");
}
} catch (Throwable t) {
try {
setLogImplementation
- ("org.apache.commons.logging.NoOpLog");
+ ("org.apache.commons.logging.NoOpLog");
} catch (Throwable u) {
;
}
@@ -180,7 +179,7 @@
// ------------------------------------------------------------ Constructor
-
+
/** Don't allow others to create instances */
private LogSource() {
@@ -198,9 +197,9 @@
* of the log).
*/
static public void setLogImplementation(String classname) throws
- LinkageError, ExceptionInInitializerError,
- NoSuchMethodException, SecurityException,
- ClassNotFoundException {
+ LinkageError, ExceptionInInitializerError,
+ NoSuchMethodException, SecurityException,
+ ClassNotFoundException {
try {
Class logclass = Class.forName(classname);
Class[] argtypes = new Class[1];
@@ -219,8 +218,8 @@
* argument (containing the name of the log).
*/
static public void setLogImplementation(Class logclass) throws
- LinkageError, ExceptionInInitializerError,
- NoSuchMethodException, SecurityException {
+ LinkageError, ExceptionInInitializerError,
+ NoSuchMethodException, SecurityException {
Class[] argtypes = new Class[1];
argtypes[0] = "".getClass();
logImplctor = logclass.getConstructor(argtypes);
@@ -229,10 +228,10 @@
/** Get a <code>Log</code> instance by class name */
static public Log getInstance(String name) {
- Log log = (Log)(logs.get(name));
- if(null == log) {
+ Log log = (Log) (logs.get(name));
+ if (null == log) {
log = makeNewLogInstance(name);
- logs.put(name,log);
+ logs.put(name, log);
}
return log;
}
@@ -274,11 +273,11 @@
try {
Object[] args = new Object[1];
args[0] = name;
- log = (Log)(logImplctor.newInstance(args));
+ log = (Log) (logImplctor.newInstance(args));
} catch (Throwable t) {
log = null;
}
- if(null == log) {
+ if (null == log) {
log = new NoOpLog(name);
}
return log;
@@ -291,7 +290,7 @@
* all logs known to me.
*/
static public String[] getLogNames() {
- return (String[])(logs.keySet().toArray(new String[logs.size()]));
+ return (String[]) (logs.keySet().toArray(new String[logs.size()]));
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>