You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-cvs@jakarta.apache.org by ce...@apache.org on 2002/02/22 11:39:55 UTC
cvs commit: jakarta-log4j/src/java/org/apache/log4j/xml DOMConfigurator.java
ceki 02/02/22 02:39:55
Modified: docs HISTORY
src/java/org/apache/log4j/helpers Loader.java
OptionConverter.java
src/java/org/apache/log4j/or RendererMap.java
src/java/org/apache/log4j/spi LocationInfo.java
LoggingEvent.java
src/java/org/apache/log4j/xml DOMConfigurator.java
Log:
- Replaced the custom class loading based on he thread context class
loader with a simple Class.forName() call. Thanks to Dave Herman
on explaining the issues involved. See
http://forum.java.sun.com/thread.jsp?forum=38&thread=70946
http://forum.java.sun.com/thread.jsp?forum=38&thread=70946#479697
http://marc.theaimsgroup.com/?l=ant-user&m=101139178705895&w=2
for more details. [*]
Revision Changes Path
1.84 +13 -0 jakarta-log4j/docs/HISTORY
Index: HISTORY
===================================================================
RCS file: /home/cvs/jakarta-log4j/docs/HISTORY,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -r1.83 -r1.84
--- HISTORY 17 Feb 2002 21:52:24 -0000 1.83
+++ HISTORY 22 Feb 2002 10:39:55 -0000 1.84
@@ -9,6 +9,19 @@
- Release of version 1.2
+
+ (beta4)
+
+ - Replaced the custom class loading based on he thread context class
+ loader with a simple Class.forName() call. Thanks to Dave Herman
+ on explaining the issues involved. See
+ http://forum.java.sun.com/thread.jsp?forum=38&thread=70946
+ http://forum.java.sun.com/thread.jsp?forum=38&thread=70946#479697
+ http://marc.theaimsgroup.com/?l=ant-user&m=101139178705895&w=2
+ for more details. [*]
+
+Class.forName(clazz);
+
(beta3)
- Fixed the complaints the compiler issued when using the
1.16 +16 -15 jakarta-log4j/src/java/org/apache/log4j/helpers/Loader.java
Index: Loader.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/helpers/Loader.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Loader.java 11 Oct 2001 15:10:21 -0000 1.15
+++ Loader.java 22 Feb 2002 10:39:55 -0000 1.16
@@ -19,7 +19,7 @@
public class Loader {
- static String TSTR = "Caught Exception while in Loader.getResource. This may be innocuous.";
+ static final String TSTR = "Caught Exception while in Loader.getResource. This may be innocuous.";
// We conservatively assume that we are running under Java 1.x
static private boolean java1 = true;
@@ -116,19 +116,20 @@
*/
static
public
- Class loadClass (String clazz) throws ClassNotFoundException {
- if(java1) {
- return Class.forName(clazz);
- } else {
- try {
- return Thread.currentThread().getContextClassLoader().loadClass(clazz);
- } catch(Exception e) {
- // we reached here because
- // currentThread().getContextClassLoader() is null or because
- // of a security exceptio, or because clazz could not be
- // loaded, in any case we now try one more time
- return Class.forName(clazz);
- }
- }
+ Class loadClass (Double clazz) throws ClassNotFoundException {
+ return null;
+// if(java1) {
+// return Class.forName(clazz);
+// } else {
+// try {
+// return Thread.currentThread().getContextClassLoader().loadClass(clazz);
+// } catch(Exception e) {
+// // we reached here because
+// // currentThread().getContextClassLoader() is null or because
+// // of a security exceptio, or because clazz could not be
+// // loaded, in any case we now try one more time
+// return Class.forName(clazz);
+// }
+// }
}
}
1.33 +2 -2 jakarta-log4j/src/java/org/apache/log4j/helpers/OptionConverter.java
Index: OptionConverter.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/helpers/OptionConverter.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- OptionConverter.java 18 Feb 2002 17:36:36 -0000 1.32
+++ OptionConverter.java 22 Feb 2002 10:39:55 -0000 1.33
@@ -203,7 +203,7 @@
+ ":pri=[" + levelName + "]");
try {
- Class customLevel = Loader.loadClass(clazz);
+ Class customLevel = Class.forName(clazz);
// get a ref to the specified class' static method
// toLevel(String, org.apache.log4j.Level)
@@ -310,7 +310,7 @@
Object defaultValue) {
if(className != null) {
try {
- Class classObj = Loader.loadClass(className);
+ Class classObj = Class.forName(className);
if(!superClass.isAssignableFrom(classObj)) {
LogLog.error("A \""+className+"\" object is not assignable to a \""+
superClass.getName() + "\" variable.");
1.8 +1 -1 jakarta-log4j/src/java/org/apache/log4j/or/RendererMap.java
Index: RendererMap.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/or/RendererMap.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- RendererMap.java 27 Sep 2001 21:22:37 -0000 1.7
+++ RendererMap.java 22 Feb 2002 10:39:55 -0000 1.8
@@ -47,7 +47,7 @@
return;
} else {
try {
- Class renderedClass = Loader.loadClass(renderedClassName);
+ Class renderedClass = Class.forName(renderedClassName);
repository.setRenderer(renderedClass, renderer);
} catch(ClassNotFoundException e) {
LogLog.error("Could not find class ["+renderedClassName+"].", e);
1.11 +1 -1 jakarta-log4j/src/java/org/apache/log4j/spi/LocationInfo.java
Index: LocationInfo.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/spi/LocationInfo.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- LocationInfo.java 24 Sep 2001 22:43:05 -0000 1.10
+++ LocationInfo.java 22 Feb 2002 10:39:55 -0000 1.11
@@ -60,7 +60,7 @@
static boolean inVisualAge = false;
static {
try {
- Class dummy = Loader.loadClass("com.ibm.uvm.tools.DebugSupport");
+ Class dummy = Class.forName("com.ibm.uvm.tools.DebugSupport");
inVisualAge = true;
LogLog.debug("Detected IBM VisualAge environment.");
} catch(Throwable e) {
1.26 +1 -1 jakarta-log4j/src/java/org/apache/log4j/spi/LoggingEvent.java
Index: LoggingEvent.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/spi/LoggingEvent.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- LoggingEvent.java 18 Feb 2002 21:43:31 -0000 1.25
+++ LoggingEvent.java 22 Feb 2002 10:39:55 -0000 1.26
@@ -303,7 +303,7 @@
} else {
Method m = (Method) methodCache.get(className);
if(m == null) {
- Class clazz = Loader.loadClass(className);
+ Class clazz = Class.forName(className);
m = clazz.getDeclaredMethod(TO_LEVEL, TO_LEVEL_PARAMS);
methodCache.put(className, m);
}
1.47 +4 -4 jakarta-log4j/src/java/org/apache/log4j/xml/DOMConfigurator.java
Index: DOMConfigurator.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/DOMConfigurator.java,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- DOMConfigurator.java 18 Feb 2002 16:29:44 -0000 1.46
+++ DOMConfigurator.java 22 Feb 2002 10:39:55 -0000 1.47
@@ -161,7 +161,7 @@
String className = subst(appenderElement.getAttribute(CLASS_ATTR));
LogLog.debug("Class name: [" + className+']');
try {
- Object instance = Loader.loadClass(className).newInstance();
+ Object instance = Class.forName(className).newInstance();
Appender appender = (Appender)instance;
PropertySetter propSetter = new PropertySetter(appender);
@@ -309,7 +309,7 @@
else {
LogLog.debug("Desired logger sub-class: ["+className+']');
try {
- Class clazz = Loader.loadClass(className);
+ Class clazz = Class.forName(className);
Method getInstanceMethod = clazz.getMethod("getLogger",
ONE_STRING_PARAM);
cat = (Logger) getInstanceMethod.invoke(null, new Object[] {catName});
@@ -440,7 +440,7 @@
String className = subst(layout_element.getAttribute(CLASS_ATTR));
LogLog.debug("Parsing layout of class: \""+className+"\"");
try {
- Object instance = Loader.loadClass(className).newInstance();
+ Object instance = Class.forName(className).newInstance();
Layout layout = (Layout)instance;
PropertySetter propSetter = new PropertySetter(layout);
@@ -505,7 +505,7 @@
} else {
LogLog.debug("Desired Level sub-class: ["+className+']');
try {
- Class clazz = Loader.loadClass(className);
+ Class clazz = Class.forName(className);
Method toLevelMethod = clazz.getMethod("toLevel",
ONE_STRING_PARAM);
Level pri = (Level) toLevelMethod.invoke(null,
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>