From 81e90d14a37982ca15145ac89b0b635e6d742fdb Mon Sep 17 00:00:00 2001
From: Thomas Neidhart
* If a system property of this name is set then the value is
@@ -139,17 +139,17 @@ public abstract class LogFactory {
* interesting events will be written to the specified object.
*/
private static PrintStream diagnosticsStream = null;
-
+
/**
* A string that gets prefixed to every message output by the
* logDiagnostic method, so that users can clearly see which
* LogFactory class is generating the output.
*/
private static final String diagnosticPrefix;
-
+
/**
- * Setting this system property
- * ( Setting this system property
+ * (priority) of the key in the config file used to
- * specify the priority of that particular config file. The associated value
+ * The name (priority) of the key in the config file used to
+ * specify the priority of that particular config file. The associated value
* is a floating-point number; higher values take priority over lower values.
*/
public static final String PRIORITY_KEY = "priority";
/**
- * The name (use_tccl) of the key in the config file used
- * to specify whether logging classes should be loaded via the thread
+ * The name (use_tccl) of the key in the config file used
+ * to specify whether logging classes should be loaded via the thread
* context class loader (TCCL), or not. By default, the TCCL is used.
*/
public static final String TCCL_KEY = "use_tccl";
/**
- * The name (org.apache.commons.logging.LogFactory) of the property
+ * The name (org.apache.commons.logging.LogFactory) of the property
* used to identify the LogFactory implementation
* class name. This can be used as a system property, or as an entry in a
* configuration properties file.
@@ -116,10 +116,10 @@ public abstract class LogFactory {
"META-INF/services/org.apache.commons.logging.LogFactory";
/**
- * The name (org.apache.commons.logging.diagnostics.dest)
+ * The name (org.apache.commons.logging.diagnostics.dest)
* of the property used to enable internal commons-logging
* diagnostic output, in order to get information on what logging
- * implementations are being discovered, what classloaders they
+ * implementations are being discovered, what classloaders they
* are loaded through, etc.
* org.apache.commons.logging.LogFactory.HashtableImpl)
+ * org.apache.commons.logging.LogFactory.HashtableImpl)
* value allows the Hashtable used to store
* classloaders to be substituted by an alternative implementation.
*
* Usage: Set this property when Java is invoked
- * and
* Note that the correct way to ensure no memory leaks occur is to ensure
- * that LogFactory.release(contextClassLoader) is called whenever a
+ * that LogFactory.release(contextClassLoader) is called whenever a
* webapp is undeployed.
*/
private static final Hashtable createFactoryStore() {
@@ -340,7 +340,6 @@ public abstract class LogFactory {
try {
Class implementationClass = Class.forName(storeImplementationClass);
result = (Hashtable) implementationClass.newInstance();
-
} catch (Throwable t) {
// ignore
if (!WEAK_HASHTABLE_CLASSNAME.equals(storeImplementationClass)) {
@@ -365,10 +364,10 @@ public abstract class LogFactory {
/** Utility method to safely trim a string. */
private static String trim(String src) {
- if (src == null) {
- return null;
- }
- return src.trim();
+ if (src == null) {
+ return null;
+ }
+ return src.trim();
}
/**
@@ -394,9 +393,9 @@ public abstract class LogFactory {
* properties defined in this file will be set as configuration attributes
* on the corresponding
- * NOTE - In a multi-threaded environment it is possible
- * that two different instances will be returned for the same
- * classloader environment.
+ * NOTE - In a multi-threaded environment it is possible
+ * that two different instances will be returned for the same
+ * classloader environment.
*
* @throws LogConfigurationException if the implementation class is not
* available or cannot be instantiated.
@@ -422,8 +421,8 @@ public abstract class LogFactory {
if (isDiagnosticsEnabled()) {
logDiagnostic(
- "[LOOKUP] LogFactory implementation requested for the first time for context classloader "
- + objectId(contextClassLoader));
+ "[LOOKUP] LogFactory implementation requested for the first time for context classloader " +
+ objectId(contextClassLoader));
logHierarchy("[LOOKUP] ", contextClassLoader);
}
@@ -434,7 +433,7 @@ public abstract class LogFactory {
// property may also control which LogFactory concrete subclass is
// used, but only if other discovery mechanisms fail..
//
- // As the properties file (if it exists) will be used one way or
+ // As the properties file (if it exists) will be used one way or
// another in the end we may as well look for it first.
Properties props = getConfigurationFile(contextClassLoader, FACTORY_PROPERTIES);
@@ -455,7 +454,7 @@ public abstract class LogFactory {
// own logging implementations. It also means that it is up to the
// implementation whether to load library-specific config files
// from the TCCL or not.
- baseClassLoader = thisClassLoader;
+ baseClassLoader = thisClassLoader;
}
}
}
@@ -463,35 +462,28 @@ public abstract class LogFactory {
// Determine which concrete LogFactory subclass to use.
// First, try a global system property
if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "[LOOKUP] Looking for system property [" + FACTORY_PROPERTY
- + "] to define the LogFactory subclass to use...");
+ logDiagnostic("[LOOKUP] Looking for system property [" + FACTORY_PROPERTY +
+ "] to define the LogFactory subclass to use...");
}
-
+
try {
String factoryClass = getSystemProperty(FACTORY_PROPERTY, null);
if (factoryClass != null) {
if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "[LOOKUP] Creating an instance of LogFactory class '" + factoryClass
- + "' as specified by system property " + FACTORY_PROPERTY);
+ logDiagnostic("[LOOKUP] Creating an instance of LogFactory class '" + factoryClass +
+ "' as specified by system property " + FACTORY_PROPERTY);
}
-
factory = newFactory(factoryClass, baseClassLoader, contextClassLoader);
} else {
if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "[LOOKUP] No system property [" + FACTORY_PROPERTY
- + "] defined.");
+ logDiagnostic("[LOOKUP] No system property [" + FACTORY_PROPERTY + "] defined.");
}
}
} catch (SecurityException e) {
if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "[LOOKUP] A security exception occurred while trying to create an"
- + " instance of the custom factory class"
- + ": [" + trim(e.getMessage())
- + "]. Trying alternative implementations...");
+ logDiagnostic("[LOOKUP] A security exception occurred while trying to create an" +
+ " instance of the custom factory class" + ": [" + trim(e.getMessage()) +
+ "]. Trying alternative implementations...");
}
// ignore
} catch(RuntimeException e) {
@@ -501,11 +493,9 @@ public abstract class LogFactory {
// One possible exception that can occur here is a ClassCastException when
// the specified class wasn't castable to this LogFactory type.
if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "[LOOKUP] An exception occurred while trying to create an"
- + " instance of the custom factory class"
- + ": [" + trim(e.getMessage())
- + "] as specified by a system property.");
+ logDiagnostic("[LOOKUP] An exception occurred while trying to create an" +
+ " instance of the custom factory class" + ": [" + trim(e.getMessage()) +
+ "] as specified by a system property.");
}
throw e;
}
@@ -513,14 +503,13 @@ public abstract class LogFactory {
// Second, try to find a service by using the JDK1.3 class
// discovery mechanism, which involves putting a file with the name
// of an interface class in the META-INF/services directory, where the
- // contents of the file is a single line specifying a concrete class
+ // contents of the file is a single line specifying a concrete class
// that implements the desired interface.
if (factory == null) {
if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "[LOOKUP] Looking for a resource file of name [" + SERVICE_ID
- + "] to define the LogFactory subclass to use...");
+ logDiagnostic("[LOOKUP] Looking for a resource file of name [" + SERVICE_ID +
+ "] to define the LogFactory subclass to use...");
}
try {
InputStream is = getResourceAsStream(contextClassLoader,
@@ -542,20 +531,16 @@ public abstract class LogFactory {
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "[LOOKUP] Creating an instance of LogFactory class " + factoryClassName
- + " as specified by file '" + SERVICE_ID
- + "' which was present in the path of the context"
- + " classloader.");
+ logDiagnostic("[LOOKUP] Creating an instance of LogFactory class " + factoryClassName +
+ " as specified by file '" + SERVICE_ID +
+ "' which was present in the path of the context classloader.");
}
factory = newFactory(factoryClassName, baseClassLoader, contextClassLoader );
}
} else {
// is == null
if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "[LOOKUP] No resource file with name '" + SERVICE_ID
- + "' found.");
+ logDiagnostic("[LOOKUP] No resource file with name '" + SERVICE_ID + "' found.");
}
}
} catch( Exception ex ) {
@@ -760,7 +745,7 @@ public abstract class LogFactory {
* Even when using an AccessController, however, this method can still
* throw SecurityException. Commons-logging basically relies on the
* ability to access classloaders, ie a policy that forbids all
- * classloader access will also prevent commons-logging from working:
+ * classloader access will also prevent commons-logging from working:
* currently this method will throw an exception preventing the entire app
* from starting up. Maybe it would be good to detect this situation and
* just disable all commons-logging? Not high priority though - as stated
@@ -770,7 +755,7 @@ public abstract class LogFactory {
* technically be a security flaw anyway; untrusted code that has access
* to a trusted JCL library could use it to fetch the classloader for
* a class even when forbidden to do so directly.
- *
+ *
* @since 1.1
*/
protected static ClassLoader getClassLoader(Class clazz) {
@@ -797,13 +782,13 @@ public abstract class LogFactory {
* an AccessController. User code wishing to obtain the context classloader
* must invoke this method via AccessController.doPrivileged if it needs
* support for that.
- *
+ *
* @return the context classloader associated with the current thread,
* or null if security doesn't allow it.
- *
+ *
* @throws LogConfigurationException if there was some weird error while
* attempting to get the context classloader.
- *
+ *
* @throws SecurityException if the current java security policy doesn't
* allow this class to access the context classloader.
*/
@@ -821,13 +806,13 @@ public abstract class LogFactory {
* doesn't have such privileges. Without using an AccessController, the
* the entire call stack must have the privilege before the call is
* allowed.
- *
+ *
* @return the context classloader associated with the current thread,
* or null if security doesn't allow it.
- *
+ *
* @throws LogConfigurationException if there was some weird error while
* attempting to get the context classloader.
- *
+ *
* @throws SecurityException if the current java security policy doesn't
* allow this class to access the context classloader.
*/
@@ -842,7 +827,7 @@ public abstract class LogFactory {
/**
* Return the thread context class loader if available; otherwise return
- * null.
+ * null.
*
* Most/all code should call getContextClassLoaderInternal rather than
* calling this method directly.
@@ -853,13 +838,13 @@ public abstract class LogFactory {
* Note that no internal logging is done within this method because
* this method is called every time LogFactory.getLogger() is called,
* and we don't want too much output generated here.
- *
+ *
* @exception LogConfigurationException if a suitable class loader
* cannot be identified.
- *
+ *
* @exception SecurityException if the java security policy forbids
* access to the context classloader from one of the classes in the
- * current call stack.
+ * current call stack.
* @since 1.1
*/
protected static ClassLoader directGetContextClassLoader()
@@ -869,13 +854,11 @@ public abstract class LogFactory {
try {
// Are we running on a JDK 1.2 or later system?
- Method method = Thread.class.getMethod("getContextClassLoader",
- (Class[]) null);
+ Method method = Thread.class.getMethod("getContextClassLoader", (Class[]) null);
// Get the thread context class loader (if there is one)
try {
- classLoader = (ClassLoader)method.invoke(Thread.currentThread(),
- (Object[]) null);
+ classLoader = (ClassLoader)method.invoke(Thread.currentThread(), (Object[]) null);
} catch (IllegalAccessException e) {
throw new LogConfigurationException
("Unexpected IllegalAccessException", e);
@@ -920,7 +903,6 @@ public abstract class LogFactory {
// + " classloader is the same as the class that loaded"
// + " the concrete LogFactory class.");
// }
-
}
// Return the selected class loader
@@ -936,7 +918,7 @@ public abstract class LogFactory {
* a distinct context classloader set. This parameter may be null
* in JDK1.1, and in embedded systems where jcl-using code is
* placed in the bootclasspath.
- *
+ *
* @return the factory associated with the specified classloader if
* one has previously been created, or null if this is the first time
* we have seen this particular classloader.
@@ -985,7 +967,7 @@ public abstract class LogFactory {
* (abstract) LogFactory.
*
*
@@ -1040,16 +1022,13 @@ public abstract class LogFactory {
if (result instanceof LogConfigurationException) {
LogConfigurationException ex = (LogConfigurationException) result;
if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "An error occurred while loading the factory class:"
- + ex.getMessage());
+ logDiagnostic("An error occurred while loading the factory class:" + ex.getMessage());
}
throw ex;
}
if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "Created object " + objectId(result)
- + " to manage classloader " + objectId(contextClassLoader));
+ logDiagnostic("Created object " + objectId(result) + " to manage classloader " +
+ objectId(contextClassLoader));
}
return (LogFactory)result;
}
@@ -1076,14 +1055,14 @@ public abstract class LogFactory {
/**
* Implements the operations described in the javadoc for newFactory.
- *
+ *
* @param factoryClass
- *
+ *
* @param classLoader used to load the specified factory class. This is
* expected to be either the TCCL or the classloader which loaded this
* class. Note that the classloader which loaded this class might be
* "null" (ie the bootloader) for embedded systems.
- *
+ *
* @return either a LogFactory object or a LogConfigurationException object.
* @since 1.1
*/
@@ -1108,14 +1087,14 @@ public abstract class LogFactory {
} else {
//
// This indicates a problem with the ClassLoader tree.
- // An incompatible ClassLoader was used to load the
- // implementation.
+ // An incompatible ClassLoader was used to load the
+ // implementation.
// As the same classes
// must be available in multiple class loaders,
// it is very likely that multiple JCL jars are present.
// The most likely fix for this
- // problem is to remove the extra JCL jars from the
- // ClassLoader hierarchy.
+ // problem is to remove the extra JCL jars from the
+ // ClassLoader hierarchy.
//
if (isDiagnosticsEnabled()) {
logDiagnostic(
@@ -1126,7 +1105,7 @@ public abstract class LogFactory {
logHierarchy("[BAD CL TREE] ", classLoader);
}
}
-
+
return (LogFactory) logFactoryClass.newInstance();
} catch (ClassNotFoundException ex) {
@@ -1161,13 +1140,13 @@ public abstract class LogFactory {
// appropriate exception here.
final boolean implementsLogFactory = implementsLogFactory(logFactoryClass);
-
+
//
- // Construct a good message: users may not actual expect that a custom implementation
- // has been specified. Several well known containers use this mechanism to adapt JCL
- // to their native logging system.
- //
- String msg =
+ // Construct a good message: users may not actual expect that a custom implementation
+ // has been specified. Several well known containers use this mechanism to adapt JCL
+ // to their native logging system.
+ //
+ String msg =
"The application has specified that a custom LogFactory implementation should be used but " +
"Class '" + factoryClass + "' cannot be converted to '"
+ LogFactory.class.getName() + "'. ";
@@ -1182,14 +1161,14 @@ public abstract class LogFactory {
msg = msg + "Please check the custom implementation. ";
}
msg = msg + "Help can be found @http://commons.apache.org/logging/troubleshooting.html.";
-
+
if (isDiagnosticsEnabled()) {
logDiagnostic(msg);
}
-
+
throw new ClassCastException(msg);
}
-
+
// Ignore exception, continue. Presumably the classloader was the
// TCCL; the code below will try to load the class via thisClassLoader.
// This will handle the case where the original calling class is in
@@ -1212,7 +1191,7 @@ public abstract class LogFactory {
* to LogFactory.class.getClassLoader().load(name), ie we ignore
* the classloader parameter the caller passed, and fall back
* to trying the classloader associated with this class. See the
- * javadoc for the newFactory method for more info on the
+ * javadoc for the newFactory method for more info on the
* consequences of this.
*
* Notes:
@@ -1223,7 +1202,7 @@ public abstract class LogFactory {
// to be generated/caught & recast properly.
if (isDiagnosticsEnabled()) {
logDiagnostic(
- "Unable to load factory class via classloader "
+ "Unable to load factory class via classloader "
+ objectId(classLoader)
+ " - trying the classloader associated with this LogFactory.");
}
@@ -1234,9 +1213,7 @@ public abstract class LogFactory {
if (isDiagnosticsEnabled()) {
logDiagnostic("Unable to create LogFactory instance.");
}
- if (logFactoryClass != null
- && !LogFactory.class.isAssignableFrom(logFactoryClass)) {
-
+ if (logFactoryClass != null && !LogFactory.class.isAssignableFrom(logFactoryClass)) {
return new LogConfigurationException(
"The chosen LogFactory implementation does not extend LogFactory."
+ " Please check your configuration.",
@@ -1315,7 +1292,7 @@ public abstract class LogFactory {
/**
* Applets may run in an environment where accessing resources of a loader is
* a secure operation, but where the commons-logging library has explicitly
- * been granted permission for that operation. In this case, we need to
+ * been granted permission for that operation. In this case, we need to
* run the operation using an AccessController.
*/
private static InputStream getResourceAsStream(final ClassLoader loader, final String name) {
@@ -1345,7 +1322,7 @@ public abstract class LogFactory {
* If resources could not be listed for some reason, null is returned.
*/
private static Enumeration getResources(final ClassLoader loader, final String name) {
- PrivilegedAction action =
+ PrivilegedAction action =
new PrivilegedAction() {
public Object run() {
try {
@@ -1356,9 +1333,8 @@ public abstract class LogFactory {
}
} catch(IOException e) {
if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "Exception while trying to find configuration file "
- + name + ":" + e.getMessage());
+ logDiagnostic("Exception while trying to find configuration file " +
+ name + ":" + e.getMessage());
}
return null;
} catch(NoSuchMethodError e) {
@@ -1382,7 +1358,7 @@ public abstract class LogFactory {
* {@code Null} is returned if the URL cannot be opened.
*/
private static Properties getProperties(final URL url) {
- PrivilegedAction action =
+ PrivilegedAction action =
new PrivilegedAction() {
public Object run() {
InputStream stream = null;
@@ -1431,7 +1407,7 @@ public abstract class LogFactory {
* null is returned. If more than one is found, then the file with the greatest
* value for its PRIORITY property is returned. If multiple files have the
* same PRIORITY value then the first in the classpath is returned.
- *
+ *
* This differs from the 1.0.x releases; those always use the first one found.
* However as the priority is a new field, this change is backwards compatible.
*
@@ -1440,7 +1416,7 @@ public abstract class LogFactory {
* file in a shared classpath location with a priority > 0; this overrides any
* commons-logging.properties files without priorities which are in the
* webapps. Webapps can also use explicit priorities to override a configuration
- * file in the shared classpath if needed.
+ * file in the shared classpath if needed.
*/
private static final Properties getConfigurationFile(ClassLoader classLoader, String fileName) {
Properties props = null;
@@ -1452,14 +1428,14 @@ public abstract class LogFactory {
if (urls == null) {
return null;
}
-
+
while (urls.hasMoreElements()) {
URL url = (URL) urls.nextElement();
-
+
Properties newProps = getProperties(url);
if (newProps != null) {
if (props == null) {
- propsUrl = url;
+ propsUrl = url;
props = newProps;
String priorityStr = props.getProperty(PRIORITY_KEY);
priority = 0.0;
@@ -1470,7 +1446,7 @@ public abstract class LogFactory {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] Properties file found at '" + url + "'"
- + " with priority " + priority);
+ + " with priority " + priority);
}
} else {
String newPriorityStr = newProps.getProperty(PRIORITY_KEY);
@@ -1483,12 +1459,12 @@ public abstract class LogFactory {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] Properties file at '" + url + "'"
- + " with priority " + newPriority
+ + " with priority " + newPriority
+ " overrides file at '" + propsUrl + "'"
+ " with priority " + priority);
}
- propsUrl = url;
+ propsUrl = url;
props = newProps;
priority = newPriority;
} else {
@@ -1512,13 +1488,9 @@ public abstract class LogFactory {
if (isDiagnosticsEnabled()) {
if (props == null) {
- logDiagnostic(
- "[LOOKUP] No properties file of name '" + fileName
- + "' found.");
+ logDiagnostic("[LOOKUP] No properties file of name '" + fileName + "' found.");
} else {
- logDiagnostic(
- "[LOOKUP] Properties file of name '" + fileName
- + "' found at '" + propsUrl + '"');
+ logDiagnostic("[LOOKUP] Properties file of name '" + fileName + "' found at '" + propsUrl + '"');
}
}
@@ -1526,7 +1498,7 @@ public abstract class LogFactory {
}
/**
- * Read the specified system property, using an AccessController so that
+ * Read the specified system property, using an AccessController so that
* the property can be read if JCL has been granted the appropriate
* security rights even if the calling code has not.
*
@@ -1548,7 +1520,7 @@ public abstract class LogFactory {
* Determines whether the user wants internal diagnostic output. If so,
* returns an appropriate writer object. Users can enable diagnostic
* output by setting the system property named {@link #DIAGNOSTICS_DEST_PROPERTY} to
- * a filename, or the special values STDOUT or STDERR.
+ * a filename, or the special values STDOUT or STDERR.
*/
private static PrintStream initDiagnostics() {
String dest;
@@ -1584,7 +1556,7 @@ public abstract class LogFactory {
*
* By the way, sorry for the incorrect grammar, but calling this method
* areDiagnosticsEnabled just isn't java beans style.
- *
+ *
* @return true if calls to logDiagnostic will have any effect.
* @since 1.1
*/
@@ -1607,7 +1579,7 @@ public abstract class LogFactory {
* Note that it is safe to call this method before initDiagnostics
* is called; any output will just be ignored (as isDiagnosticsEnabled
* will return false).
- *
+ *
* @param msg is the diagnostic message to be output.
*/
private static final void logDiagnostic(String msg) {
@@ -1620,7 +1592,7 @@ public abstract class LogFactory {
/**
* Write the specified message to the internal logging destination.
- *
+ *
* @param msg is the diagnostic message to be output.
* @since 1.1
*/
@@ -1639,12 +1611,12 @@ public abstract class LogFactory {
* classloader, then you may get the following output:
*
* This method returns immediately if isDiagnosticsEnabled()
* returns false.
- *
+ *
* @param clazz is the class whose classloader + tree are to be
* output.
*/
@@ -1652,20 +1624,20 @@ public abstract class LogFactory {
if (!isDiagnosticsEnabled()) {
return;
}
-
+
try {
// Deliberately use System.getProperty here instead of getSystemProperty; if
// the overall security policy for the calling application forbids access to
- // these variables then we do not want to output them to the diagnostic stream.
+ // these variables then we do not want to output them to the diagnostic stream.
logDiagnostic("[ENV] Extension directories (java.ext.dir): " + System.getProperty("java.ext.dir"));
logDiagnostic("[ENV] Application classpath (java.class.path): " + System.getProperty("java.class.path"));
} catch(SecurityException ex) {
logDiagnostic("[ENV] Security setting prevent interrogation of system classpaths.");
}
-
+
String className = clazz.getName();
ClassLoader classLoader;
-
+
try {
classLoader = getClassLoader(clazz);
} catch(SecurityException ex) {
@@ -1675,9 +1647,7 @@ public abstract class LogFactory {
return;
}
- logDiagnostic(
- "[ENV] Class " + className + " was loaded via classloader "
- + objectId(classLoader));
+ logDiagnostic("[ENV] Class " + className + " was loaded via classloader " + objectId(classLoader));
logHierarchy("[ENV] Ancestry of classloader which loaded " + className + " is ", classLoader);
}
@@ -1685,7 +1655,7 @@ public abstract class LogFactory {
* Logs diagnostic messages about the given classloader
* and it's hierarchy. The prefix is prepended to the message
* and is intended to make it easier to understand the logs.
- * @param prefix
+ * @param prefix
* @param classLoader
*/
private static void logHierarchy(String prefix, ClassLoader classLoader) {
@@ -1697,14 +1667,13 @@ public abstract class LogFactory {
final String classLoaderString = classLoader.toString();
logDiagnostic(prefix + objectId(classLoader) + " == '" + classLoaderString + "'");
}
-
+
try {
systemClassLoader = ClassLoader.getSystemClassLoader();
} catch(SecurityException ex) {
- logDiagnostic(
- prefix + "Security forbids determining the system classloader.");
+ logDiagnostic(prefix + "Security forbids determining the system classloader.");
return;
- }
+ }
if (classLoader != null) {
StringBuffer buf = new StringBuffer(prefix + "ClassLoader tree:");
for(;;) {
@@ -1737,7 +1706,7 @@ public abstract class LogFactory {
* The returned string is of form "classname@hashcode", ie is the same as
* the return value of the Object.toString() method, but works even when
* the specified object's class has overidden the toString method.
- *
+ *
* @param o may be null.
* @return a string of form classname@hashcode, or "null" if param o is null.
* @since 1.1
@@ -1753,7 +1722,7 @@ public abstract class LogFactory {
// ----------------------------------------------------------------------
// Static initialiser block to perform initialisation at class load time.
//
- // We can't do this in the class constructor, as there are many
+ // We can't do this in the class constructor, as there are many
// static methods on this class that can be called before any
// LogFactory instances are created, and they depend upon this
// stuff having been set up.
@@ -1778,7 +1747,7 @@ public abstract class LogFactory {
// ensure each logged message has a prefix of form
// [LogFactory from classloader OID]
//
- // Note that this prefix should be kept consistent with that
+ // Note that this prefix should be kept consistent with that
// in LogFactoryImpl. However here we don't need to output info
// about the actual *instance* of LogFactory, as all methods that
// output diagnostics from this class are static.
diff --git a/src/java/org/apache/commons/logging/LogSource.java b/src/java/org/apache/commons/logging/LogSource.java
index f201fac..290f134 100644
--- a/src/java/org/apache/commons/logging/LogSource.java
+++ b/src/java/org/apache/commons/logging/LogSource.java
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.apache.commons.logging;
@@ -201,7 +201,7 @@ public class LogSource {
* class can be found, this method will return a Log4JLogger if the log4j Logger
* class is available in the {@link LogSource}'s classpath, or a Jdk14Logger if we
* are on a JDK 1.4 or later system, or NoOpLog if neither of the above conditions is true.
- *
+ *
* @param name the log name (or category)
*/
static public Log makeNewLogInstance(String name) {
diff --git a/src/java/org/apache/commons/logging/impl/AvalonLogger.java b/src/java/org/apache/commons/logging/impl/AvalonLogger.java
index b9e7620..55637c8 100644
--- a/src/java/org/apache/commons/logging/impl/AvalonLogger.java
+++ b/src/java/org/apache/commons/logging/impl/AvalonLogger.java
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.apache.commons.logging.impl;
@@ -26,13 +26,13 @@ import org.apache.commons.logging.Log;
*
* There are two ways in which this class can be used:
*
* Default behaviour: true (tolerates bad logging adapters)
- *
+ *
* See also method setAttribute.
*/
- public static final String ALLOW_FLAWED_DISCOVERY_PROPERTY =
+ public static final String ALLOW_FLAWED_DISCOVERY_PROPERTY =
"org.apache.commons.logging.Log.allowFlawedDiscovery";
/**
- * The name (
* Default behaviour: true (tolerates bad Log class hierarchy)
- *
+ *
* See also method setAttribute.
*/
- public static final String ALLOW_FLAWED_HIERARCHY_PROPERTY =
+ public static final String ALLOW_FLAWED_HIERARCHY_PROPERTY =
"org.apache.commons.logging.Log.allowFlawedHierarchy";
/**
* The names of classes that will be tried (in order) as logging
* adapters. Each class is expected to implement the Log interface,
* and to throw NoClassDefFound or ExceptionInInitializerError when
- * loaded if the underlying logging library is not available. Any
+ * loaded if the underlying logging library is not available. Any
* other error indicates that the underlying logging library is available
* but broken/unusable for some reason.
*/
@@ -165,7 +167,7 @@ public class LogFactoryImpl extends LogFactory {
"org.apache.commons.logging.impl.Jdk13LumberjackLogger",
"org.apache.commons.logging.impl.SimpleLog"
};
-
+
// ----------------------------------------------------- Instance Variables
/**
@@ -224,17 +226,17 @@ public class LogFactoryImpl extends LogFactory {
* See getBaseClassLoader and initConfiguration.
*/
private boolean allowFlawedContext;
-
+
/**
* See handleFlawedDiscovery and initConfiguration.
*/
private boolean allowFlawedDiscovery;
-
+
/**
* See handleFlawedHierarchy and initConfiguration.
*/
private boolean allowFlawedHierarchy;
-
+
// --------------------------------------------------------- Public Methods
/**
@@ -353,19 +355,19 @@ public class LogFactoryImpl extends LogFactory {
} else {
attributes.put(name, value);
}
-
+
if (name.equals(TCCL_KEY)) {
useTCCL = value != null && Boolean.valueOf(value.toString()).booleanValue();
}
}
- // ------------------------------------------------------
+ // ------------------------------------------------------
// Static Methods
//
// These methods only defined as workarounds for a java 1.2 bug;
// theoretically none of these are needed.
- // ------------------------------------------------------
-
+ // ------------------------------------------------------
+
/**
* Gets the context classloader.
* This method is a workaround for a java 1.2 compiler bug.
@@ -374,7 +376,7 @@ public class LogFactoryImpl extends LogFactory {
protected static ClassLoader getContextClassLoader() throws LogConfigurationException {
return LogFactory.getContextClassLoader();
}
-
+
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.isDiagnosticsEnabled.
@@ -382,7 +384,7 @@ public class LogFactoryImpl extends LogFactory {
protected static boolean isDiagnosticsEnabled() {
return LogFactory.isDiagnosticsEnabled();
}
-
+
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader.
@@ -401,7 +403,7 @@ public class LogFactoryImpl extends LogFactory {
* This string will later be prefixed to each "internal logging" message
* emitted, so that users can clearly see any unexpected behaviour.
*
- * Note that this method does not detect whether internal logging is
+ * Note that this method does not detect whether internal logging is
* enabled or not, nor where to output stuff if it is; that is all
* handled by the parent LogFactory class. This method just computes
* its own unique prefix for log messages.
@@ -414,7 +416,7 @@ public class LogFactoryImpl extends LogFactory {
// see the context & impl ids from when this object was instantiated,
// in order to link the impl id output as this object's prefix back to
// the context it is intended to manage.
- // Note that this prefix should be kept consistent with that
+ // Note that this prefix should be kept consistent with that
// in LogFactory.
Class clazz = this.getClass();
ClassLoader classLoader = getClassLoader(clazz);
@@ -430,11 +432,11 @@ public class LogFactoryImpl extends LogFactory {
}
diagnosticPrefix = "[LogFactoryImpl@" + System.identityHashCode(this) + " from " + classLoaderName + "] ";
}
-
+
/**
* Output a diagnostic message to a user-specified destination (if the
* user has enabled diagnostic logging).
- *
+ *
* @param msg diagnostic message
* @since 1.1
*/
@@ -446,8 +448,8 @@ public class LogFactoryImpl extends LogFactory {
/**
* Return the fully qualified Java classname of the {@link Log}
- * implementation we will be using.
- *
+ * implementation we will be using.
+ *
* @deprecated Never invoked by this class; subclasses should not assume
* it will be.
*/
@@ -455,7 +457,7 @@ public class LogFactoryImpl extends LogFactory {
if (logClassName == null) {
discoverLogImplementation(getClass().getName());
}
-
+
return logClassName;
}
@@ -470,8 +472,8 @@ public class LogFactoryImpl extends LogFactory {
* in all circumstances. Return
@@ -639,7 +641,7 @@ public class LogFactoryImpl extends LogFactory {
logDiagnostic("[SECURITY] Unable to obtain parent classloader");
return null;
}
-
+
}
/**
@@ -653,7 +655,7 @@ public class LogFactoryImpl extends LogFactory {
}
try {
Log log = createLogFromClass(
- classname,
+ classname,
this.getClass().getName(), // dummy category
false);
@@ -677,14 +679,14 @@ public class LogFactoryImpl extends LogFactory {
}
/**
- * Attempt to find an attribute (see method setAttribute) or a
+ * Attempt to find an attribute (see method setAttribute) or a
* system property with the provided name and return its value.
*
* The attributes associated with this object are checked before
* system properties in case someone has explicitly called setAttribute,
* or a configuration property has been set in a commons-logging.properties
* file.
- *
+ *
* @return the value associated with the property, or null.
*/
private String getConfigurationValue(String property) {
@@ -699,7 +701,7 @@ public class LogFactoryImpl extends LogFactory {
}
return valueObj.toString();
}
-
+
if (isDiagnosticsEnabled()) {
logDiagnostic("[ENV] No LogFactory attribute found for " + property);
}
@@ -708,7 +710,7 @@ public class LogFactoryImpl extends LogFactory {
// warning: minor security hole here, in that we potentially read a system
// property that the caller cannot, then output it in readable form as a
// diagnostic message. However it's only ever JCL-specific properties
- // involved here, so the harm is truly trivial.
+ // involved here, so the harm is truly trivial.
String value = getSystemProperty(property, null);
if (value != null) {
if (isDiagnosticsEnabled()) {
@@ -732,10 +734,10 @@ public class LogFactoryImpl extends LogFactory {
return null;
}
-
+
/**
* Get the setting for the user-configurable behaviour specified by key.
- * If nothing has explicitly been set, then return dflt.
+ * If nothing has explicitly been set, then return dflt.
*/
private boolean getBooleanConfiguration(String key, boolean dflt) {
String val = getConfigurationValue(key);
@@ -761,10 +763,10 @@ public class LogFactoryImpl extends LogFactory {
/**
* Attempts to create a Log instance for the given category name.
* Follows the discovery process described in the class javadoc.
- *
+ *
* @param logCategory the name of the log category
- *
- * @throws LogConfigurationException if an error in discovery occurs,
+ *
+ * @throws LogConfigurationException if an error in discovery occurs,
* or if no adapter at all can be instantiated
*/
private Log discoverLogImplementation(String logCategory)
@@ -772,20 +774,20 @@ public class LogFactoryImpl extends LogFactory {
if (isDiagnosticsEnabled()) {
logDiagnostic("Discovering a Log implementation...");
}
-
+
initConfiguration();
-
+
Log result = null;
-
+
// See if the user specified the Log implementation to use
String specifiedLogClassName = findUserSpecifiedLogClassName();
if (specifiedLogClassName != null) {
if (isDiagnosticsEnabled()) {
- logDiagnostic("Attempting to load user-specified log class '" +
+ logDiagnostic("Attempting to load user-specified log class '" +
specifiedLogClassName + "'...");
}
-
+
result = createLogFromClass(specifiedLogClassName,
logCategory,
true);
@@ -793,7 +795,7 @@ public class LogFactoryImpl extends LogFactory {
StringBuffer messageBuffer = new StringBuffer("User-specified log class '");
messageBuffer.append(specifiedLogClassName);
messageBuffer.append("' cannot be found or is not useable.");
-
+
// Mistyping or misspelling names is a common fault.
// Construct a good error message, if we can
informUponSimilarName(messageBuffer, specifiedLogClassName, LOGGING_IMPL_LOG4J_LOGGER);
@@ -802,10 +804,10 @@ public class LogFactoryImpl extends LogFactory {
informUponSimilarName(messageBuffer, specifiedLogClassName, LOGGING_IMPL_SIMPLE_LOGGER);
throw new LogConfigurationException(messageBuffer.toString());
}
-
+
return result;
}
-
+
// No user specified log; try to discover what's on the classpath
//
// Note that we deliberately loop here over classesToDiscover and
@@ -815,7 +817,7 @@ public class LogFactoryImpl extends LogFactory {
// for each possible classloader
// see if it works
//
- // It appears reasonable at first glance to do the opposite:
+ // It appears reasonable at first glance to do the opposite:
// for each possible classloader
// for each discoverable log adapter
// see if it works
@@ -823,7 +825,7 @@ public class LogFactoryImpl extends LogFactory {
// The latter certainly has advantages for user-installable logging
// libraries such as log4j; in a webapp for example this code should
// first check whether the user has provided any of the possible
- // logging libraries before looking in the parent classloader.
+ // logging libraries before looking in the parent classloader.
// Unfortunately, however, Jdk14Logger will always work in jvm>=1.4,
// and SimpleLog will always work in any JVM. So the loop would never
// ever look for logging libraries in the parent classpath. Yet many
@@ -833,7 +835,7 @@ public class LogFactoryImpl extends LogFactory {
// in a webapp should use a commons-logging.properties file or a
// service file in META-INF to force use of that logging lib anyway,
// rather than relying on discovery.
-
+
if (isDiagnosticsEnabled()) {
logDiagnostic(
"No user-specified Log implementation; performing discovery" +
@@ -842,23 +844,23 @@ public class LogFactoryImpl extends LogFactory {
for(int i=0; iLogFactory will attempt to load a new instance
+ * and LogFactory will attempt to load a new instance
* of the given implementation class.
* For example, running the following ant scriplet:
* the message should be appended to,
+ * @param messageBuffer
* <java classname="${test.runner}" fork="yes" failonerror="${test.failonerror}">
* ...
- * <sysproperty
+ * <sysproperty
* key="org.apache.commons.logging.LogFactory.HashtableImpl"
* value="org.apache.commons.logging.AltHashtable"/>
* </java>
@@ -187,7 +187,7 @@ public abstract class LogFactory {
"org.apache.commons.logging.LogFactory.HashtableImpl";
/** Name used to load the weak hashtable implementation by names */
- private static final String WEAK_HASHTABLE_CLASSNAME =
+ private static final String WEAK_HASHTABLE_CLASSNAME =
"org.apache.commons.logging.impl.WeakHashtable";
/**
@@ -198,7 +198,7 @@ public abstract class LogFactory {
* cache it here.
*/
private static final ClassLoader thisClassLoader;
-
+
// ----------------------------------------------------------- Constructors
/**
@@ -206,7 +206,7 @@ public abstract class LogFactory {
*/
protected LogFactory() {
}
-
+
// --------------------------------------------------------- Public Methods
/**
@@ -291,7 +291,7 @@ public abstract class LogFactory {
* the ClassLoader with which it was created.
*/
protected static Hashtable factories = null;
-
+
/**
* Previously constructed LogFactory instance as in the
* factories map, but for the case where
@@ -320,7 +320,7 @@ public abstract class LogFactory {
* arbitrary Hashtable implementation name.
* LogFactory instance.
* ClassLoader conflicts
- * Note that there can be problems if the specified ClassLoader is not the
+ * Note that there can be problems if the specified ClassLoader is not the
* same as the classloader that loaded this class, ie when loading a
* concrete LogFactory subclass via a context classloader.
*
* Class com.acme.Foo was loaded via classloader 11111
- * ClassLoader tree: 11111 -> 22222 (SYSTEM) -> 33333 -> BOOT
+ * ClassLoader tree: 11111 -> 22222 (SYSTEM) -> 33333 -> BOOT
*
*
- *
AvalonLogger
+ * sets the ancestral Avalon logger for this class. Any AvalonLogger
* instances created through the LogFactory mechanisms will output
* to child loggers of this Logger.
* org.apache.avalon.framework.logger.Logger.debug.
- *
+ *
* @param message to log
* @param t log this cause
* @see org.apache.commons.logging.Log#debug(Object, Throwable)
@@ -114,7 +114,7 @@ public class AvalonLogger implements Log {
/**
* Logs a message with org.apache.avalon.framework.logger.Logger.debug.
- *
+ *
* @param message to log.
* @see org.apache.commons.logging.Log#debug(Object)
*/
@@ -126,7 +126,7 @@ public class AvalonLogger implements Log {
/**
* Logs a message with org.apache.avalon.framework.logger.Logger.error.
- *
+ *
* @param message to log
* @param t log this cause
* @see org.apache.commons.logging.Log#error(Object, Throwable)
@@ -139,7 +139,7 @@ public class AvalonLogger implements Log {
/**
* Logs a message with org.apache.avalon.framework.logger.Logger.error.
- *
+ *
* @param message to log
* @see org.apache.commons.logging.Log#error(Object)
*/
@@ -151,7 +151,7 @@ public class AvalonLogger implements Log {
/**
* Logs a message with org.apache.avalon.framework.logger.Logger.fatalError.
- *
+ *
* @param message to log.
* @param t log this cause.
* @see org.apache.commons.logging.Log#fatal(Object, Throwable)
@@ -164,7 +164,7 @@ public class AvalonLogger implements Log {
/**
* Logs a message with org.apache.avalon.framework.logger.Logger.fatalError.
- *
+ *
* @param message to log
* @see org.apache.commons.logging.Log#fatal(Object)
*/
@@ -176,7 +176,7 @@ public class AvalonLogger implements Log {
/**
* Logs a message with org.apache.avalon.framework.logger.Logger.info.
- *
+ *
* @param message to log
* @param t log this cause
* @see org.apache.commons.logging.Log#info(Object, Throwable)
@@ -189,7 +189,7 @@ public class AvalonLogger implements Log {
/**
* Logs a message with org.apache.avalon.framework.logger.Logger.info.
- *
+ *
* @param message to log
* @see org.apache.commons.logging.Log#info(Object)
*/
@@ -249,7 +249,7 @@ public class AvalonLogger implements Log {
/**
* Logs a message with org.apache.avalon.framework.logger.Logger.debug.
- *
+ *
* @param message to log.
* @param t log this cause.
* @see org.apache.commons.logging.Log#trace(Object, Throwable)
@@ -262,7 +262,7 @@ public class AvalonLogger implements Log {
/**
* Logs a message with org.apache.avalon.framework.logger.Logger.debug.
- *
+ *
* @param message to log
* @see org.apache.commons.logging.Log#trace(Object)
*/
@@ -274,7 +274,7 @@ public class AvalonLogger implements Log {
/**
* Logs a message with org.apache.avalon.framework.logger.Logger.warn.
- *
+ *
* @param message to log
* @param t log this cause
* @see org.apache.commons.logging.Log#warn(Object, Throwable)
@@ -287,7 +287,7 @@ public class AvalonLogger implements Log {
/**
* Logs a message with org.apache.avalon.framework.logger.Logger.warn.
- *
+ *
* @param message to log
* @see org.apache.commons.logging.Log#warn(Object)
*/
diff --git a/src/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java b/src/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java
index 4ea65e8..3bc84dc 100644
--- a/src/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java
+++ b/src/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.apache.commons.logging.impl;
diff --git a/src/java/org/apache/commons/logging/impl/Jdk14Logger.java b/src/java/org/apache/commons/logging/impl/Jdk14Logger.java
index 0a5c3c2..9ae37ea 100644
--- a/src/java/org/apache/commons/logging/impl/Jdk14Logger.java
+++ b/src/java/org/apache/commons/logging/impl/Jdk14Logger.java
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.apache.commons.logging.impl;
diff --git a/src/java/org/apache/commons/logging/impl/Log4JLogger.java b/src/java/org/apache/commons/logging/impl/Log4JLogger.java
index 3f79d31..4fbe7f3 100644
--- a/src/java/org/apache/commons/logging/impl/Log4JLogger.java
+++ b/src/java/org/apache/commons/logging/impl/Log4JLogger.java
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.apache.commons.logging.impl;
@@ -54,7 +54,7 @@ public class Log4JLogger implements Log, Serializable {
/** The fully qualified name of the Log4JLogger class. */
private static final String FQCN = Log4JLogger.class.getName();
-
+
/** Log to this logger */
private transient Logger logger = null;
@@ -62,7 +62,7 @@ public class Log4JLogger implements Log, Serializable {
private final String name;
private static final Priority traceLevel;
-
+
// ------------------------------------------------------------
// Static Initializer.
//
@@ -82,11 +82,11 @@ public class Log4JLogger implements Log, Serializable {
// nope, this is log4j 1.3, so force an ExceptionInInitializerError
throw new InstantiationError("Log4J 1.2 not available");
}
-
+
// Releases of log4j1.2 >= 1.2.12 have Priority.TRACE available, earlier
// versions do not. If TRACE is not available, then we have to map
// calls to Log.trace(...) onto the DEBUG level.
-
+
Priority _traceLevel;
try {
_traceLevel = (Priority) Level.class.getDeclaredField("TRACE").get(null);
@@ -111,7 +111,7 @@ public class Log4JLogger implements Log, Serializable {
this.logger = getLogger();
}
- /**
+ /**
* For use with a log4j factory.
*/
public Log4JLogger(Logger logger ) {
diff --git a/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java b/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
index 5f46717..dded44a 100644
--- a/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
+++ b/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.apache.commons.logging.impl;
@@ -70,13 +70,15 @@ public class LogFactoryImpl extends LogFactory {
/** Jdk14Logger class name */
private static final String LOGGING_IMPL_JDK14_LOGGER = "org.apache.commons.logging.impl.Jdk14Logger";
/** Jdk13LumberjackLogger class name */
- private static final String LOGGING_IMPL_LUMBERJACK_LOGGER = "org.apache.commons.logging.impl.Jdk13LumberjackLogger";
+ private static final String LOGGING_IMPL_LUMBERJACK_LOGGER =
+ "org.apache.commons.logging.impl.Jdk13LumberjackLogger";
+
/** SimpleLog class name */
private static final String LOGGING_IMPL_SIMPLE_LOGGER = "org.apache.commons.logging.impl.SimpleLog";
private static final String PKG_IMPL="org.apache.commons.logging.impl.";
private static final int PKG_LEN = PKG_IMPL.length();
-
+
// ----------------------------------------------------------- Constructors
/**
@@ -93,7 +95,7 @@ public class LogFactoryImpl extends LogFactory {
// ----------------------------------------------------- Manifest Constants
/**
- * The name (org.apache.commons.logging.Log) of the system
+ * The name (org.apache.commons.logging.Log) of the system
* property identifying our {@link Log} implementation class.
*/
public static final String LOG_PROPERTY = "org.apache.commons.logging.Log";
@@ -105,57 +107,57 @@ public class LogFactoryImpl extends LogFactory {
protected static final String LOG_PROPERTY_OLD = "org.apache.commons.logging.log";
/**
- * The name (org.apache.commons.logging.Log.allowFlawedContext)
+ * The name (org.apache.commons.logging.Log.allowFlawedContext)
* of the system property which can be set true/false to
* determine system behaviour when a bad context-classloader is encountered.
* When set to false, a LogConfigurationException is thrown if
* LogFactoryImpl is loaded via a child classloader of the TCCL (this
* should never happen in sane systems).
- *
+ *
* Default behaviour: true (tolerates bad context classloaders)
- *
+ *
* See also method setAttribute.
*/
- public static final String ALLOW_FLAWED_CONTEXT_PROPERTY =
+ public static final String ALLOW_FLAWED_CONTEXT_PROPERTY =
"org.apache.commons.logging.Log.allowFlawedContext";
/**
- * The name (org.apache.commons.logging.Log.allowFlawedDiscovery)
+ * The name (org.apache.commons.logging.Log.allowFlawedDiscovery)
* of the system property which can be set true/false to
* determine system behaviour when a bad logging adapter class is
* encountered during logging discovery. When set to false, an
* exception will be thrown and the app will fail to start. When set
* to true, discovery will continue (though the user might end up
* with a different logging implementation than they expected).
- *
+ * org.apache.commons.logging.Log.allowFlawedHierarchy)
+ * The name (org.apache.commons.logging.Log.allowFlawedHierarchy)
* of the system property which can be set true/false to
* determine system behaviour when a logging adapter class is
* encountered which has bound to the wrong Log class implementation.
* When set to false, an exception will be thrown and the app will fail
* to start. When set to true, discovery will continue (though the user
* might end up with a different logging implementation than they expected).
- *
+ * true if JDK 1.4 or later logging
+ * Return true if JDK 1.4 or later logging
* is available. Also checks that the Throwable class
* supports getStackTrace(), which is required by
- * Jdk14Logger.StringBuffer the message should be appended to,
* not null
* @param name the (trimmed) name to be test against the candidate, not null
* @param candidate the candidate name (not null)
*/
- private void informUponSimilarName(final StringBuffer messageBuffer, final String name,
+ private void informUponSimilarName(final StringBuffer messageBuffer, final String name,
final String candidate) {
if (name.equals(candidate)) {
// Don't suggest a name that is exactly the same as the one the
@@ -875,12 +877,12 @@ public class LogFactoryImpl extends LogFactory {
messageBuffer.append("'?");
}
}
-
+
/**
- * Checks system properties and the attribute map for
- * a Log implementation specified by the user under the
+ * Checks system properties and the attribute map for
+ * a Log implementation specified by the user under the
* property names {@link #LOG_PROPERTY} or {@link #LOG_PROPERTY_OLD}.
- *
+ *
* @return classname specified by the user, or null
*/
private String findUserSpecifiedLogClassName() {
@@ -891,7 +893,7 @@ public class LogFactoryImpl extends LogFactory {
if (specifiedClass == null) { // @deprecated
if (isDiagnosticsEnabled()) {
- logDiagnostic("Trying to get log class from attribute '" +
+ logDiagnostic("Trying to get log class from attribute '" +
LOG_PROPERTY_OLD + "'");
}
specifiedClass = (String) getAttribute(LOG_PROPERTY_OLD);
@@ -899,14 +901,14 @@ public class LogFactoryImpl extends LogFactory {
if (specifiedClass == null) {
if (isDiagnosticsEnabled()) {
- logDiagnostic("Trying to get log class from system property '" +
+ logDiagnostic("Trying to get log class from system property '" +
LOG_PROPERTY + "'");
}
try {
specifiedClass = getSystemProperty(LOG_PROPERTY, null);
} catch (SecurityException e) {
if (isDiagnosticsEnabled()) {
- logDiagnostic("No access allowed to system property '" +
+ logDiagnostic("No access allowed to system property '" +
LOG_PROPERTY + "' - " + e.getMessage());
}
}
@@ -914,19 +916,19 @@ public class LogFactoryImpl extends LogFactory {
if (specifiedClass == null) { // @deprecated
if (isDiagnosticsEnabled()) {
- logDiagnostic("Trying to get log class from system property '" +
+ logDiagnostic("Trying to get log class from system property '" +
LOG_PROPERTY_OLD + "'");
}
try {
specifiedClass = getSystemProperty(LOG_PROPERTY_OLD, null);
} catch (SecurityException e) {
if (isDiagnosticsEnabled()) {
- logDiagnostic("No access allowed to system property '" +
+ logDiagnostic("No access allowed to system property '" +
LOG_PROPERTY_OLD + "' - " + e.getMessage());
}
}
}
-
+
// Remove any whitespace; it's never valid in a classname so its
// presence just means a user mistake. As we know what they meant,
// we may as well strip the spaces.
@@ -936,56 +938,52 @@ public class LogFactoryImpl extends LogFactory {
return specifiedClass;
}
-
+
/**
* Attempts to load the given class, find a suitable constructor,
* and instantiate an instance of Log.
- *
+ *
* @param logAdapterClassName classname of the Log implementation
- *
+ *
* @param logCategory argument to pass to the Log implementation's
* constructor
- *
+ *
* @param affectState true if this object's state should
* be affected by this method call, false otherwise.
- *
+ *
* @return an instance of the given class, or null if the logging
* library associated with the specified adapter is not available.
- *
+ *
* @throws LogConfigurationException if there was a serious error with
* configuration and the handleFlawedDiscovery method decided this
* problem was fatal.
- */
+ */
private Log createLogFromClass(String logAdapterClassName,
String logCategory,
- boolean affectState)
- throws LogConfigurationException {
+ boolean affectState)
+ throws LogConfigurationException {
if (isDiagnosticsEnabled()) {
logDiagnostic("Attempting to instantiate '" + logAdapterClassName + "'");
}
-
+
Object[] params = { logCategory };
Log logAdapter = null;
Constructor constructor = null;
-
+
Class logAdapterClass = null;
ClassLoader currentCL = getBaseClassLoader();
-
+
for(;;) {
// Loop through the classloader hierarchy trying to find
// a viable classloader.
- logDiagnostic(
- "Trying to load '"
- + logAdapterClassName
- + "' from classloader "
- + objectId(currentCL));
+ logDiagnostic("Trying to load '" + logAdapterClassName + "' from classloader " + objectId(currentCL));
try {
if (isDiagnosticsEnabled()) {
// Show the location of the first occurrence of the .class file
// in the classpath. This is the location that ClassLoader.loadClass
// will load the class from -- unless the classloader is doing
- // something weird.
+ // something weird.
URL url;
String resourceName = logAdapterClassName.replace('.', '/') + ".class";
if (currentCL != null) {
@@ -1005,22 +1003,17 @@ public class LogFactoryImpl extends LogFactory {
try {
c = Class.forName(logAdapterClassName, true, currentCL);
} catch (ClassNotFoundException originalClassNotFoundException) {
- // The current classloader was unable to find the log adapter
+ // The current classloader was unable to find the log adapter
// in this or any ancestor classloader. There's no point in
// trying higher up in the hierarchy in this case..
String msg = originalClassNotFoundException.getMessage();
- logDiagnostic(
- "The log adapter '"
- + logAdapterClassName
- + "' is not available via classloader "
- + objectId(currentCL)
- + ": "
- + msg.trim());
+ logDiagnostic("The log adapter '" + logAdapterClassName + "' is not available via classloader " +
+ objectId(currentCL) + ": " + msg.trim());
try {
// Try the class classloader.
// This may work in cases where the TCCL
// does not contain the code executed or JCL.
- // This behaviour indicates that the application
+ // This behaviour indicates that the application
// classloading strategy is not consistent with the
// Java 1.2 classloading guidelines but JCL can
// and so should handle this case.
@@ -1028,15 +1021,12 @@ public class LogFactoryImpl extends LogFactory {
} catch (ClassNotFoundException secondaryClassNotFoundException) {
// no point continuing: this adapter isn't available
msg = secondaryClassNotFoundException.getMessage();
- logDiagnostic(
- "The log adapter '"
- + logAdapterClassName
- + "' is not available via the LogFactoryImpl class classloader: "
- + msg.trim());
+ logDiagnostic("The log adapter '" + logAdapterClassName +
+ "' is not available via the LogFactoryImpl class classloader: " + msg.trim());
break;
}
}
-
+
constructor = c.getConstructor(logConstructorSignature);
Object o = constructor.newInstance(params);
@@ -1049,15 +1039,15 @@ public class LogFactoryImpl extends LogFactory {
logAdapter = (Log) o;
break;
}
-
+
// Oops, we have a potential problem here. An adapter class
// has been found and its underlying lib is present too, but
// there are multiple Log interface classes available making it
- // impossible to cast to the type the caller wanted. We
+ // impossible to cast to the type the caller wanted. We
// certainly can't use this logger, but we need to know whether
// to keep on discovering or terminate now.
//
- // The handleFlawedHierarchy method will throw
+ // The handleFlawedHierarchy method will throw
// LogConfigurationException if it regards this problem as
// fatal, and just return if not.
handleFlawedHierarchy(currentCL, c);
@@ -1068,33 +1058,25 @@ public class LogFactoryImpl extends LogFactory {
// ancestor classloader. There's no point in trying higher up
// in the hierarchy in this case..
String msg = e.getMessage();
- logDiagnostic(
- "The log adapter '"
- + logAdapterClassName
- + "' is missing dependencies when loaded via classloader "
- + objectId(currentCL)
- + ": "
- + msg.trim());
+ logDiagnostic("The log adapter '" + logAdapterClassName +
+ "' is missing dependencies when loaded via classloader " + objectId(currentCL) +
+ ": " + msg.trim());
break;
} catch (ExceptionInInitializerError e) {
- // A static initializer block or the initializer code associated
+ // A static initializer block or the initializer code associated
// with a static variable on the log adapter class has thrown
// an exception.
//
// We treat this as meaning the adapter's underlying logging
// library could not be found.
String msg = e.getMessage();
- logDiagnostic(
- "The log adapter '"
- + logAdapterClassName
- + "' is unable to initialize itself when loaded via classloader "
- + objectId(currentCL)
- + ": "
- + msg.trim());
+ logDiagnostic("The log adapter '" + logAdapterClassName +
+ "' is unable to initialize itself when loaded via classloader " + objectId(currentCL) +
+ ": " + msg.trim());
break;
} catch(LogConfigurationException e) {
// call to handleFlawedHierarchy above must have thrown
- // a LogConfigurationException, so just throw it on
+ // a LogConfigurationException, so just throw it on
throw e;
} catch(Throwable t) {
// handleFlawedDiscovery will determine whether this is a fatal
@@ -1102,11 +1084,11 @@ public class LogFactoryImpl extends LogFactory {
// will be thrown.
handleFlawedDiscovery(logAdapterClassName, currentCL, t);
}
-
+
if (currentCL == null) {
break;
}
-
+
// try the parent classloader
// currentCL = currentCL.getParent();
currentCL = getParentClassLoader(currentCL);
@@ -1116,31 +1098,25 @@ public class LogFactoryImpl extends LogFactory {
// We've succeeded, so set instance fields
this.logClassName = logAdapterClassName;
this.logConstructor = constructor;
-
+
// Identify the setLogFactory method (if there is one)
try {
this.logMethod = logAdapterClass.getMethod("setLogFactory",
logMethodSignature);
- logDiagnostic("Found method setLogFactory(LogFactory) in '"
- + logAdapterClassName + "'");
+ logDiagnostic("Found method setLogFactory(LogFactory) in '" + logAdapterClassName + "'");
} catch (Throwable t) {
this.logMethod = null;
- logDiagnostic(
- "[INFO] '" + logAdapterClassName
- + "' from classloader " + objectId(currentCL)
- + " does not declare optional method "
- + "setLogFactory(LogFactory)");
+ logDiagnostic("[INFO] '" + logAdapterClassName + "' from classloader " + objectId(currentCL) +
+ " does not declare optional method " + "setLogFactory(LogFactory)");
}
-
- logDiagnostic(
- "Log adapter '" + logAdapterClassName
- + "' from classloader " + objectId(logAdapterClass.getClassLoader())
- + " has been selected for use.");
+
+ logDiagnostic("Log adapter '" + logAdapterClassName + "' from classloader " +
+ objectId(logAdapterClass.getClassLoader()) + " has been selected for use.");
}
-
+
return logAdapter;
}
-
+
/**
* Return the classloader from which we should try to load the logging
* adapter classes.
@@ -1157,11 +1133,11 @@ public class LogFactoryImpl extends LogFactory {
* failed to correctly set the context classloader. This is a bug in
* the calling application; however we provide the option for JCL to
* simply generate a warning rather than fail outright.
- *
+ *
*/
private ClassLoader getBaseClassLoader() throws LogConfigurationException {
ClassLoader thisClassLoader = getClassLoader(LogFactoryImpl.class);
-
+
if (!useTCCL) {
return thisClassLoader;
}
@@ -1170,18 +1146,17 @@ public class LogFactoryImpl extends LogFactory {
ClassLoader baseClassLoader = getLowestClassLoader(
contextClassLoader, thisClassLoader);
-
+
if (baseClassLoader == null) {
// The two classloaders are not part of a parent child relationship.
- // In some classloading setups (e.g. JBoss with its
+ // In some classloading setups (e.g. JBoss with its
// UnifiedLoaderRepository) this can still work, so if user hasn't
// forbidden it, just return the contextClassLoader.
- if (allowFlawedContext) {
+ if (allowFlawedContext) {
if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "[WARNING] the context classloader is not part of a"
- + " parent-child relationship with the classloader that"
- + " loaded LogFactoryImpl.");
+ logDiagnostic("[WARNING] the context classloader is not part of a" +
+ " parent-child relationship with the classloader that" +
+ " loaded LogFactoryImpl.");
}
// If contextClassLoader were null, getLowestClassLoader() would
// have returned thisClassLoader. The fact we are here means
@@ -1189,11 +1164,10 @@ public class LogFactoryImpl extends LogFactory {
return contextClassLoader;
}
else {
- throw new LogConfigurationException(
- "Bad classloader hierarchy; LogFactoryImpl was loaded via"
- + " a classloader that is not related to the current context"
- + " classloader.");
- }
+ throw new LogConfigurationException("Bad classloader hierarchy; LogFactoryImpl was loaded via" +
+ " a classloader that is not related to the current context" +
+ " classloader.");
+ }
}
if (baseClassLoader != contextClassLoader) {
@@ -1205,20 +1179,20 @@ public class LogFactoryImpl extends LogFactory {
if (allowFlawedContext) {
if (isDiagnosticsEnabled()) {
logDiagnostic(
- "Warning: the context classloader is an ancestor of the"
- + " classloader that loaded LogFactoryImpl; it should be"
- + " the same or a descendant. The application using"
- + " commons-logging should ensure the context classloader"
- + " is used correctly.");
+ "Warning: the context classloader is an ancestor of the" +
+ " classloader that loaded LogFactoryImpl; it should be" +
+ " the same or a descendant. The application using" +
+ " commons-logging should ensure the context classloader" +
+ " is used correctly.");
}
} else {
throw new LogConfigurationException(
- "Bad classloader hierarchy; LogFactoryImpl was loaded via"
- + " a classloader that is not related to the current context"
- + " classloader.");
+ "Bad classloader hierarchy; LogFactoryImpl was loaded via" +
+ " a classloader that is not related to the current context" +
+ " classloader.");
}
}
-
+
return baseClassLoader;
}
@@ -1228,21 +1202,21 @@ public class LogFactoryImpl extends LogFactory {
*
* @param c1 is a classloader (including the null classloader)
* @param c2 is a classloader (including the null classloader)
- *
+ *
* @return c1 if it has c2 as an ancestor, c2 if it has c1 as an ancestor,
* and null if neither is an ancestor of the other.
*/
private ClassLoader getLowestClassLoader(ClassLoader c1, ClassLoader c2) {
// TODO: use AccessController when dealing with classloaders here
-
+
if (c1 == null) {
return c2;
}
-
+
if (c2 == null) {
return c1;
}
-
+
ClassLoader current;
// scan c1's ancestors to find c2
@@ -1254,7 +1228,7 @@ public class LogFactoryImpl extends LogFactory {
// current = current.getParent();
current = getParentClassLoader(current);
}
-
+
// scan c2's ancestors to find c1
current = c2;
while (current != null) {
@@ -1269,29 +1243,29 @@ public class LogFactoryImpl extends LogFactory {
}
/**
- * Generates an internal diagnostic logging of the discovery failure and
- * then throws a LogConfigurationException that wraps
+ * Generates an internal diagnostic logging of the discovery failure and
+ * then throws a LogConfigurationException that wraps
* the passed Throwable.
- *
+ *
* @param logAdapterClassName is the class name of the Log implementation
* that could not be instantiated. Cannot be null.
- *
+ *
* @param classLoader is the classloader that we were trying to load the
* logAdapterClassName from when the exception occurred.
- *
+ *
* @param discoveryFlaw is the Throwable created by the classloader
- *
+ *
* @throws LogConfigurationException ALWAYS
*/
private void handleFlawedDiscovery(String logAdapterClassName,
ClassLoader classLoader, // USED?
Throwable discoveryFlaw) {
-
+
if (isDiagnosticsEnabled()) {
- logDiagnostic("Could not instantiate Log '"
- + logAdapterClassName + "' -- "
- + discoveryFlaw.getClass().getName() + ": "
- + discoveryFlaw.getLocalizedMessage());
+ logDiagnostic("Could not instantiate Log '" +
+ logAdapterClassName + "' -- " +
+ discoveryFlaw.getClass().getName() + ": " +
+ discoveryFlaw.getLocalizedMessage());
if (discoveryFlaw instanceof InvocationTargetException ) {
// Ok, the lib is there but while trying to create a real underlying
@@ -1316,21 +1290,21 @@ public class LogFactoryImpl extends LogFactory {
}
}
}
-
+
if (!allowFlawedDiscovery) {
throw new LogConfigurationException(discoveryFlaw);
}
}
-
+
/**
- * Report a problem loading the log adapter, then either return
+ * Report a problem loading the log adapter, then either return
* (if the situation is considered recoverable) or throw a
* LogConfigurationException.
- *
- * There are two possible reasons why we successfully loaded the + *
+ * There are two possible reasons why we successfully loaded the * specified log adapter class then failed to cast it to a Log object: *
* Here we try to figure out which case has occurred so we can give the
* user some reasonable feedback.
- *
+ *
* @param badClassLoader is the classloader we loaded the problem class from,
* ie it is equivalent to badClass.getClassLoader().
- *
- * @param badClass is a Class object with the desired name, but which
+ *
+ * @param badClass is a Class object with the desired name, but which
* does not implement Log correctly.
- *
+ *
* @throws LogConfigurationException when the situation
* should not be recovered from.
*/
@@ -1360,27 +1334,21 @@ public class LogFactoryImpl extends LogFactory {
break;
}
}
-
+
if (implementsLog) {
// the class does implement an interface called Log, but
// it is in the wrong classloader
if (isDiagnosticsEnabled()) {
try {
ClassLoader logInterfaceClassLoader = getClassLoader(Log.class);
- logDiagnostic(
- "Class '" + badClass.getName()
- + "' was found in classloader "
- + objectId(badClassLoader)
- + ". It is bound to a Log interface which is not"
- + " the one loaded from classloader "
- + objectId(logInterfaceClassLoader));
+ logDiagnostic("Class '" + badClass.getName() + "' was found in classloader " +
+ objectId(badClassLoader) + ". It is bound to a Log interface which is not" +
+ " the one loaded from classloader " + objectId(logInterfaceClassLoader));
} catch (Throwable t) {
- logDiagnostic(
- "Error while trying to output diagnostics about"
- + " bad class '" + badClass + "'");
+ logDiagnostic("Error while trying to output diagnostics about" + " bad class '" + badClass + "'");
}
}
-
+
if (!allowFlawedHierarchy) {
StringBuffer msg = new StringBuffer();
msg.append("Terminating logging for this context ");
@@ -1390,10 +1358,10 @@ public class LogFactoryImpl extends LogFactory {
msg.append("' visible.");
if (isDiagnosticsEnabled()) {
logDiagnostic(msg.toString());
- }
+ }
throw new LogConfigurationException(msg.toString());
}
-
+
if (isDiagnosticsEnabled()) {
StringBuffer msg = new StringBuffer();
msg.append("Warning: bad log hierarchy. ");
@@ -1413,7 +1381,7 @@ public class LogFactoryImpl extends LogFactory {
if (isDiagnosticsEnabled()) {
logDiagnostic(msg.toString());
}
-
+
throw new LogConfigurationException(msg.toString());
}
diff --git a/src/java/org/apache/commons/logging/impl/LogKitLogger.java b/src/java/org/apache/commons/logging/impl/LogKitLogger.java
index 5c35ac7..097f848 100644
--- a/src/java/org/apache/commons/logging/impl/LogKitLogger.java
+++ b/src/java/org/apache/commons/logging/impl/LogKitLogger.java
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.apache.commons.logging.impl;
@@ -79,7 +79,7 @@ public class LogKitLogger implements Log, Serializable {
/**
* Logs a message with org.apache.log.Priority.DEBUG.
- *
+ *
* @param message to log
* @see org.apache.commons.logging.Log#trace(Object)
*/
@@ -89,7 +89,7 @@ public class LogKitLogger implements Log, Serializable {
/**
* Logs a message with org.apache.log.Priority.DEBUG.
- *
+ *
* @param message to log
* @param t log this cause
* @see org.apache.commons.logging.Log#trace(Object, Throwable)
@@ -100,7 +100,7 @@ public class LogKitLogger implements Log, Serializable {
/**
* Logs a message with org.apache.log.Priority.DEBUG.
- *
+ *
* @param message to log
* @see org.apache.commons.logging.Log#debug(Object)
*/
@@ -112,7 +112,7 @@ public class LogKitLogger implements Log, Serializable {
/**
* Logs a message with org.apache.log.Priority.DEBUG.
- *
+ *
* @param message to log
* @param t log this cause
* @see org.apache.commons.logging.Log#debug(Object, Throwable)
@@ -125,7 +125,7 @@ public class LogKitLogger implements Log, Serializable {
/**
* Logs a message with org.apache.log.Priority.INFO.
- *
+ *
* @param message to log
* @see org.apache.commons.logging.Log#info(Object)
*/
@@ -137,7 +137,7 @@ public class LogKitLogger implements Log, Serializable {
/**
* Logs a message with org.apache.log.Priority.INFO.
- *
+ *
* @param message to log
* @param t log this cause
* @see org.apache.commons.logging.Log#info(Object, Throwable)
@@ -150,7 +150,7 @@ public class LogKitLogger implements Log, Serializable {
/**
* Logs a message with org.apache.log.Priority.WARN.
- *
+ *
* @param message to log
* @see org.apache.commons.logging.Log#warn(Object)
*/
@@ -162,7 +162,7 @@ public class LogKitLogger implements Log, Serializable {
/**
* Logs a message with org.apache.log.Priority.WARN.
- *
+ *
* @param message to log
* @param t log this cause
* @see org.apache.commons.logging.Log#warn(Object, Throwable)
@@ -175,7 +175,7 @@ public class LogKitLogger implements Log, Serializable {
/**
* Logs a message with org.apache.log.Priority.ERROR.
- *
+ *
* @param message to log
* @see org.apache.commons.logging.Log#error(Object)
*/
@@ -187,7 +187,7 @@ public class LogKitLogger implements Log, Serializable {
/**
* Logs a message with org.apache.log.Priority.ERROR.
- *
+ *
* @param message to log
* @param t log this cause
* @see org.apache.commons.logging.Log#error(Object, Throwable)
@@ -200,7 +200,7 @@ public class LogKitLogger implements Log, Serializable {
/**
* Logs a message with org.apache.log.Priority.FATAL_ERROR.
- *
+ *
* @param message to log
* @see org.apache.commons.logging.Log#fatal(Object)
*/
@@ -212,7 +212,7 @@ public class LogKitLogger implements Log, Serializable {
/**
* Logs a message with org.apache.log.Priority.FATAL_ERROR.
- *
+ *
* @param message to log
* @param t log this cause
* @see org.apache.commons.logging.Log#fatal(Object, Throwable)
diff --git a/src/java/org/apache/commons/logging/impl/NoOpLog.java b/src/java/org/apache/commons/logging/impl/NoOpLog.java
index a85e341..1cf605b 100644
--- a/src/java/org/apache/commons/logging/impl/NoOpLog.java
+++ b/src/java/org/apache/commons/logging/impl/NoOpLog.java
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.apache.commons.logging.impl;
diff --git a/src/java/org/apache/commons/logging/impl/ServletContextCleaner.java b/src/java/org/apache/commons/logging/impl/ServletContextCleaner.java
index 8de06ef..b6f5d3b 100644
--- a/src/java/org/apache/commons/logging/impl/ServletContextCleaner.java
+++ b/src/java/org/apache/commons/logging/impl/ServletContextCleaner.java
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.apache.commons.logging.impl;
@@ -43,14 +43,14 @@ import org.apache.commons.logging.LogFactory;
* this class on webapp undeploy; the contextDestroyed method will tell
* every accessible LogFactory class that the entry in its map for the
* current webapp's context classloader should be cleared.
- *
+ *
* @version $Id$
* @since 1.1
*/
public class ServletContextCleaner implements ServletContextListener {
private static final Class[] RELEASE_SIGNATURE = {ClassLoader.class};
-
+
/**
* Invoked when a webapp is undeployed, this tells the LogFactory
* class to release any logging information related to the current
@@ -84,7 +84,7 @@ public class ServletContextCleaner implements ServletContextListener {
// and that class calls LogFactory the tccl gets registered in
// the LogFactory instance that is visible from the ancestor
// classloader. However the concrete logging library it points
- // to is expected to have been loaded via the TCCL, so the
+ // to is expected to have been loaded via the TCCL, so the
// underlying logging lib is only initialised/configured once.
// These references from ancestor LogFactory classes down to
// TCCL classloaders are held via weak references and so should
@@ -120,13 +120,13 @@ public class ServletContextCleaner implements ServletContextListener {
loader = null;
}
}
-
+
// Just to be sure, invoke release on the LogFactory that is visible from
// this ServletContextCleaner class too. This should already have been caught
// by the above loop but just in case...
LogFactory.release(tccl);
}
-
+
/**
* Invoked when a webapp is deployed. Nothing needs to be done here.
*/
diff --git a/src/java/org/apache/commons/logging/impl/SimpleLog.java b/src/java/org/apache/commons/logging/impl/SimpleLog.java
index c2fd400..c750036 100644
--- a/src/java/org/apache/commons/logging/impl/SimpleLog.java
+++ b/src/java/org/apache/commons/logging/impl/SimpleLog.java
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.apache.commons.logging.impl;
@@ -361,7 +361,7 @@ public class SimpleLog implements Log, Serializable {
// -------------------------------------------------------- Log Implementation
/**
- * Logs a message with
+ * Logs a message with
* org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG.
*
* @param message to log
@@ -374,7 +374,7 @@ public class SimpleLog implements Log, Serializable {
}
/**
- * Logs a message with
+ * Logs a message with
* org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG.
*
* @param message to log
@@ -598,8 +598,7 @@ public class SimpleLog implements Log, Serializable {
// Get the thread context class loader (if there is one)
try {
- classLoader = (ClassLoader)method.invoke(Thread.currentThread(),
- (Class[]) null);
+ classLoader = (ClassLoader)method.invoke(Thread.currentThread(), (Class[]) null);
} catch (IllegalAccessException e) {
// ignore
} catch (InvocationTargetException e) {
diff --git a/src/java/org/apache/commons/logging/impl/WeakHashtable.java b/src/java/org/apache/commons/logging/impl/WeakHashtable.java
index 9aee8b8..afb69f0 100644
--- a/src/java/org/apache/commons/logging/impl/WeakHashtable.java
+++ b/src/java/org/apache/commons/logging/impl/WeakHashtable.java
@@ -5,16 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
-
+ */
package org.apache.commons.logging.impl;
@@ -44,17 +43,17 @@ import java.util.Set;
* have been made with this in mind.
*
- * Usage: typical use case is as a drop-in replacement
+ * Usage: typical use case is as a drop-in replacement
* for the Hashtable used in LogFactory for J2EE environments
* running 1.3+ JVMs. Use of this class in most cases (see below) will
- * allow classloaders to be collected by the garbage collector without the need
+ * allow classloaders to be collected by the garbage collector without the need
* to call {@link org.apache.commons.logging.LogFactory#release(ClassLoader) LogFactory.release(ClassLoader)}.
*
org.apache.commons.logging.LogFactory checks whether this class
* can be supported by the current JVM, and if so then uses it to store
- * references to the LogFactory implementation it loads
- * (rather than using a standard Hashtable instance).
+ * references to the LogFactory implementation it loads
+ * (rather than using a standard Hashtable instance).
* Having this class used instead of Hashtable solves
* certain issues related to dynamic reloading of applications in J2EE-style
* environments. However this class requires java 1.3 or later (due to its use
@@ -64,37 +63,37 @@ import java.util.Set;
* for method LogFactory.createFactoryStore for more details.
The reason all this is necessary is due to a issue which
- * arises during hot deploy in a J2EE-like containers.
+ * arises during hot deploy in a J2EE-like containers.
* Each component running in the container owns one or more classloaders; when
* the component loads a LogFactory instance via the component classloader
* a reference to it gets stored in the static LogFactory.factories member,
* keyed by the component's classloader so different components don't
* stomp on each other. When the component is later unloaded, the container
- * sets the component's classloader to null with the intent that all the
+ * sets the component's classloader to null with the intent that all the
* component's classes get garbage-collected. However there's still a
* reference to the component's classloader from a key in the "global"
* LogFactory's factories member! If LogFactory.release()
* is called whenever component is unloaded, the classloaders will be correctly
- * garbage collected; this should be done by any container that
+ * garbage collected; this should be done by any container that
* bundles commons-logging by default. However, holding the classloader
* references weakly ensures that the classloader will be garbage collected
* without the container performing this step.
* Limitations: - * There is still one (unusual) scenario in which a component will not + * There is still one (unusual) scenario in which a component will not * be correctly unloaded without an explicit release. Though weak references * are used for its keys, it is necessary to use strong references for its values. *
* - * If the abstract class LogFactory is
- * loaded by the container classloader but a subclass of
- * LogFactory [LogFactory1] is loaded by the component's
+ *
If the abstract class LogFactory is
+ * loaded by the container classloader but a subclass of
+ * LogFactory [LogFactory1] is loaded by the component's
* classloader and an instance stored in the static map associated with the
* base LogFactory class, then there is a strong reference from the LogFactory
* class to the LogFactory1 instance (as normal) and a strong reference from
* the LogFactory1 instance to the component classloader via
- * getClass().getClassLoader(). This chain of references will prevent
+ * getClass().getClassLoader(). This chain of references will prevent
* collection of the child classloader.
@@ -102,16 +101,16 @@ import java.util.Set;
* loaded by a parent classloader (e.g. a server level classloader in a
* servlet container) and a custom LogFactory implementation is
* loaded by a child classloader (e.g. a web app classloader).
To avoid this scenario, ensure
- * that any custom LogFactory subclass is loaded by the same classloader as
+ * that any custom LogFactory subclass is loaded by the same classloader as
* the base LogFactory. Creating custom LogFactory subclasses is,
* however, rare. The standard LogFactoryImpl class should be sufficient
* for most or all users.
null
- */
+ */
private Referenced(Object referant) {
reference = new WeakReference(referant);
// Calc a permanent hashCode so calls to Hashtable.remove()
// work if the WeakReference has been cleared
hashCode = referant.hashCode();
}
-
+
/**
- *
+ *
* @throws NullPointerException if key is null
*/
private Referenced(Object key, ReferenceQueue queue) {
@@ -424,34 +419,34 @@ public final class WeakHashtable extends Hashtable {
hashCode = key.hashCode();
}
-
+
public int hashCode() {
return hashCode;
}
-
+
private Object getValue() {
return reference.get();
}
-
+
public boolean equals(Object o) {
boolean result = false;
if (o instanceof Referenced) {
Referenced otherKey = (Referenced) o;
Object thisKeyValue = getValue();
Object otherKeyValue = otherKey.getValue();
- if (thisKeyValue == null) {
+ if (thisKeyValue == null) {
result = otherKeyValue == null;
-
+
// Since our hashcode was calculated from the original
- // non-null referant, the above check breaks the
+ // non-null referant, the above check breaks the
// hashcode/equals contract, as two cleared Referenced
// objects could test equal but have different hashcodes.
// We can reduce (not eliminate) the chance of this
// happening by comparing hashcodes.
result = result && this.hashCode() == otherKey.hashCode();
// In any case, as our c'tor does not allow null referants
- // and Hashtable does not do equality checks between
- // existing keys, normal hashtable operations should never
+ // and Hashtable does not do equality checks between
+ // existing keys, normal hashtable operations should never
// result in an equals comparison between null referants
}
else
@@ -462,7 +457,7 @@ public final class WeakHashtable extends Hashtable {
return result;
}
}
-
+
/**
* WeakReference subclass that holds a hard reference to an
* associated value and also makes accessible
@@ -471,14 +466,14 @@ public final class WeakHashtable extends Hashtable {
private final static class WeakKey extends WeakReference {
private final Referenced referenced;
-
- private WeakKey(Object key,
+
+ private WeakKey(Object key,
ReferenceQueue queue,
Referenced referenced) {
super(key, queue);
this.referenced = referenced;
}
-
+
private Referenced getReferenced() {
return referenced;
}