Use Javadoc @code
- Javadoc and comments: Distinguish 'hash table' the concept versus 'Hashtable' the class - Use generics in test - Close HTML tags
This commit is contained in:
@@ -159,7 +159,7 @@ public abstract class LogFactory {
|
|||||||
* <strong>Note:</strong> {@code LogFactory} will print:
|
* <strong>Note:</strong> {@code LogFactory} will print:
|
||||||
* </p>
|
* </p>
|
||||||
* <pre>
|
* <pre>
|
||||||
* [ERROR] LogFactory: Load of custom hashtable failed
|
* [ERROR] LogFactory: Load of custom hash table failed
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p>
|
* <p>
|
||||||
* to system error and then continue using a standard Hashtable.
|
* to system error and then continue using a standard Hashtable.
|
||||||
@@ -192,7 +192,7 @@ public abstract class LogFactory {
|
|||||||
public static final String HASHTABLE_IMPLEMENTATION_PROPERTY =
|
public static final String HASHTABLE_IMPLEMENTATION_PROPERTY =
|
||||||
"org.apache.commons.logging.LogFactory.HashtableImpl";
|
"org.apache.commons.logging.LogFactory.HashtableImpl";
|
||||||
|
|
||||||
/** Name used to load the weak hashtable implementation by names. */
|
/** Name used to load the weak hash table implementation by names. */
|
||||||
private static final String WEAK_HASHTABLE_CLASSNAME =
|
private static final String WEAK_HASHTABLE_CLASSNAME =
|
||||||
"org.apache.commons.logging.impl.WeakHashtable";
|
"org.apache.commons.logging.impl.WeakHashtable";
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ public abstract class LogFactory {
|
|||||||
* class loader (only likely for embedded systems work).</li>
|
* class loader (only likely for embedded systems work).</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* Note that {@code factories} is a <em>Hashtable</em> (not a HashMap),
|
* Note that {@code factories} is a <em>Hashtable</em> (not a HashMap),
|
||||||
* and hashtables don't allow null as a key.
|
* and hash tables don't allow null as a key.
|
||||||
* @deprecated since 1.1.2
|
* @deprecated since 1.1.2
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -440,7 +440,7 @@ public abstract class LogFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the hashtable which will be used to store a map of
|
* Create the hash table which will be used to store a map of
|
||||||
* (context class loader -> logfactory-object). Version 1.2+ of Java
|
* (context class loader -> logfactory-object). Version 1.2+ of Java
|
||||||
* supports "weak references", allowing a custom Hashtable class
|
* supports "weak references", allowing a custom Hashtable class
|
||||||
* to be used which uses only weak references to its keys. Using weak
|
* to be used which uses only weak references to its keys. Using weak
|
||||||
@@ -462,7 +462,7 @@ public abstract class LogFactory {
|
|||||||
storeImplementationClass = getSystemProperty(HASHTABLE_IMPLEMENTATION_PROPERTY, null);
|
storeImplementationClass = getSystemProperty(HASHTABLE_IMPLEMENTATION_PROPERTY, null);
|
||||||
} catch (final SecurityException ex) {
|
} catch (final SecurityException ex) {
|
||||||
// Permissions don't allow this to be accessed. Default to the "modern"
|
// Permissions don't allow this to be accessed. Default to the "modern"
|
||||||
// weak hashtable implementation if it is available.
|
// weak hash table implementation if it is available.
|
||||||
storeImplementationClass = null;
|
storeImplementationClass = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class AvalonLogger implements Log {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an {@code AvalonLogger} that will log to a child
|
* Constructs an {@code AvalonLogger} that will log to a child
|
||||||
* of the <code>Logger</code> set by calling {@link #setDefaultLogger}.
|
* of the {@code Logger} set by calling {@link #setDefaultLogger}.
|
||||||
*
|
*
|
||||||
* @param name the name of the avalon logger implementation to delegate to
|
* @param name the name of the avalon logger implementation to delegate to
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* If the selected {@link Log} implementation class has a
|
* If the selected {@link Log} implementation class has a
|
||||||
* <code>setLogFactory()</code> method that accepts a {@link LogFactory}
|
* {@code setLogFactory()} method that accepts a {@link LogFactory}
|
||||||
* parameter, this method will be called on each newly created instance
|
* parameter, this method will be called on each newly created instance
|
||||||
* to identify the associated factory. This makes factory configuration
|
* to identify the associated factory. This makes factory configuration
|
||||||
* attributes available to the Log instance, if it so desires.
|
* attributes available to the Log instance, if it so desires.
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ public final class WeakHashtable extends Hashtable {
|
|||||||
result = result && hashCode() == otherKey.hashCode();
|
result = result && hashCode() == otherKey.hashCode();
|
||||||
// In any case, as our c'tor does not allow null referants
|
// In any case, as our c'tor does not allow null referants
|
||||||
// and Hashtable does not do equality checks between
|
// and Hashtable does not do equality checks between
|
||||||
// existing keys, normal hashtable operations should never
|
// existing keys, normal hash table operations should never
|
||||||
// result in an equals comparison between null referants
|
// result in an equals comparison between null referants
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -29,10 +29,10 @@
|
|||||||
* <li><a href="https://java.sun.com/j2se/1.4/docs/guide/util/logging/index.html">
|
* <li><a href="https://java.sun.com/j2se/1.4/docs/guide/util/logging/index.html">
|
||||||
* JDK Logging API</a>, included in JDK 1.4 or later systems. Each named
|
* JDK Logging API</a>, included in JDK 1.4 or later systems. Each named
|
||||||
* <a href="Log.html">Log</a> instance is connected to a corresponding
|
* <a href="Log.html">Log</a> instance is connected to a corresponding
|
||||||
* <code>java.util.logging.Logger</code> instance.</li>
|
* {@code java.util.logging.Logger} instance.</li>
|
||||||
* <li><a href="https://avalon.apache.org/logkit/">LogKit</a> from Apache's
|
* <li><a href="https://avalon.apache.org/logkit/">LogKit</a> from Apache's
|
||||||
* Avalon project. Each named <a href="Log.html">Log</a> instance is
|
* Avalon project. Each named <a href="Log.html">Log</a> instance is
|
||||||
* connected to a corresponding LogKit <code>Logger</code>.</li>
|
* connected to a corresponding LogKit {@code Logger}.</li>
|
||||||
* <li><a href="impl/NoOpLog.html">NoOpLog</a> implementation that simply swallows
|
* <li><a href="impl/NoOpLog.html">NoOpLog</a> implementation that simply swallows
|
||||||
* all log output, for all named <a href="Log.html">Log</a> instances.</li>
|
* all log output, for all named <a href="Log.html">Log</a> instances.</li>
|
||||||
* <li><a href="impl/SimpleLog.html">SimpleLog</a> implementation that writes all
|
* <li><a href="impl/SimpleLog.html">SimpleLog</a> implementation that writes all
|
||||||
@@ -66,66 +66,66 @@
|
|||||||
* this page in order to understand how to configure logging for your
|
* this page in order to understand how to configure logging for your
|
||||||
* application.</p>
|
* application.</p>
|
||||||
* <h2>Configuring the Commons Logging Package</h2>
|
* <h2>Configuring the Commons Logging Package</h2>
|
||||||
* <h3>Choosing a <code>LogFactory</code> Implementation</h3>
|
* <h3>Choosing a {@code LogFactory} Implementation</h3>
|
||||||
* <p>From an application perspective, the first requirement is to retrieve an
|
* <p>From an application perspective, the first requirement is to retrieve an
|
||||||
* object reference to the <code>LogFactory</code> instance that will be used
|
* object reference to the {@code LogFactory} instance that will be used
|
||||||
* to create <code><a href="Log.html">Log</a></code> instances for this
|
* to create {@code <a href="Log.html">Log</a>} instances for this
|
||||||
* application. This is normally accomplished by calling the static
|
* application. This is normally accomplished by calling the static
|
||||||
* <code>getFactory()</code> method. This method implements the following
|
* {@code getFactory()} method. This method implements the following
|
||||||
* discovery algorithm to select the name of the <code>LogFactory</code>
|
* discovery algorithm to select the name of the {@code LogFactory}
|
||||||
* implementation class this application wants to use:</p>
|
* implementation class this application wants to use:</p>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Check for a system property named
|
* <li>Check for a system property named
|
||||||
* <code>org.apache.commons.logging.LogFactory</code>.</li>
|
* {@code org.apache.commons.logging.LogFactory}.</li>
|
||||||
* <li>Use the JDK 1.3 JAR Services Discovery mechanism (see
|
* <li>Use the JDK 1.3 JAR Services Discovery mechanism (see
|
||||||
* <a href="https://java.sun.com/j2se/1.3/docs/guide/jar/jar.html">
|
* <a href="https://java.sun.com/j2se/1.3/docs/guide/jar/jar.html">
|
||||||
* https://java.sun.com/j2se/1.3/docs/guide/jar/jar.html</a> for
|
* https://java.sun.com/j2se/1.3/docs/guide/jar/jar.html</a> for
|
||||||
* more information) to look for a resource named
|
* more information) to look for a resource named
|
||||||
* <code>META-INF/services/org.apache.commons.logging.LogFactory</code>
|
* {@code META-INF/services/org.apache.commons.logging.LogFactory}
|
||||||
* whose first line is assumed to contain the desired class name.</li>
|
* whose first line is assumed to contain the desired class name.</li>
|
||||||
* <li>Look for a properties file named <code>commons-logging.properties</code>
|
* <li>Look for a properties file named {@code commons-logging.properties}
|
||||||
* visible in the application class path, with a property named
|
* visible in the application class path, with a property named
|
||||||
* <code>org.apache.commons.logging.LogFactory</code> defining the
|
* {@code org.apache.commons.logging.LogFactory} defining the
|
||||||
* desired implementation class name.</li>
|
* desired implementation class name.</li>
|
||||||
* <li>Fall back to a default implementation, which is described
|
* <li>Fall back to a default implementation, which is described
|
||||||
* further below.</li>
|
* further below.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>If a <code>commons-logging.properties</code> file is found, all of the
|
* <p>If a {@code commons-logging.properties} file is found, all of the
|
||||||
* properties defined there are also used to set configuration attributes on
|
* properties defined there are also used to set configuration attributes on
|
||||||
* the instantiated <code>LogFactory</code> instance.</p>
|
* the instantiated {@code LogFactory} instance.</p>
|
||||||
* <p>Once an implementation class name is selected, the corresponding class is
|
* <p>Once an implementation class name is selected, the corresponding class is
|
||||||
* loaded from the current Thread context class loader (if there is one), or
|
* loaded from the current Thread context class loader (if there is one), or
|
||||||
* from the class loader that loaded the <code>LogFactory</code> class itself
|
* from the class loader that loaded the {@code LogFactory} class itself
|
||||||
* otherwise. This allows a copy of <code>commons-logging.jar</code> to be
|
* otherwise. This allows a copy of {@code commons-logging.jar} to be
|
||||||
* shared in a multiple class loader environment (such as a servlet container),
|
* shared in a multiple class loader environment (such as a servlet container),
|
||||||
* but still allow each web application to provide its own <code>LogFactory</code>
|
* but still allow each web application to provide its own {@code LogFactory}
|
||||||
* implementation, if it so desires. An instance of this class will then be
|
* implementation, if it so desires. An instance of this class will then be
|
||||||
* created, and cached per class loader.
|
* created, and cached per class loader.
|
||||||
* <h3>The Default <code>LogFactory</code> Implementation</h3>
|
* <h3>The Default {@code LogFactory} Implementation</h3>
|
||||||
* <p>The Logging Package APIs include a default <code>LogFactory</code>
|
* <p>The Logging Package APIs include a default {@code LogFactory}
|
||||||
* implementation class (<a href="impl/LogFactoryImpl.html">
|
* implementation class (<a href="impl/LogFactoryImpl.html">
|
||||||
* org.apache.commons.logging.impl.LogFactoryImpl</a>) that is selected if no
|
* org.apache.commons.logging.impl.LogFactoryImpl</a>) that is selected if no
|
||||||
* other implementation class name can be discovered. Its primary purpose is
|
* other implementation class name can be discovered. Its primary purpose is
|
||||||
* to create (as necessary) and return <a href="Log.html">Log</a> instances
|
* to create (as necessary) and return <a href="Log.html">Log</a> instances
|
||||||
* in response to calls to the <code>getInstance()</code> method. The default
|
* in response to calls to the {@code getInstance()} method. The default
|
||||||
* implementation uses the following rules:</p>
|
* implementation uses the following rules:</p>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>At most one <code>Log</code> instance of the same name will be created.
|
* <li>At most one {@code Log} instance of the same name will be created.
|
||||||
* Subsequent <code>getInstance()</code> calls to the same
|
* Subsequent {@code getInstance()} calls to the same
|
||||||
* <code>LogFactory</code> instance, with the same name or <code>Class</code>
|
* {@code LogFactory} instance, with the same name or {@code Class}
|
||||||
* parameter, will return the same <code>Log</code> instance.</li>
|
* parameter, will return the same {@code Log} instance.</li>
|
||||||
* <li>When a new <code>Log</code> instance must be created, the default
|
* <li>When a new {@code Log} instance must be created, the default
|
||||||
* <code>LogFactory</code> implementation uses the following discovery
|
* {@code LogFactory} implementation uses the following discovery
|
||||||
* process:
|
* process:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Look for a configuration attribute of this factory named
|
* <li>Look for a configuration attribute of this factory named
|
||||||
* <code>org.apache.commons.logging.Log</code> (for backwards
|
* {@code org.apache.commons.logging.Log} (for backwards
|
||||||
* compatibility to pre-1.0 versions of this API, an attribute
|
* compatibility to pre-1.0 versions of this API, an attribute
|
||||||
* <code>org.apache.commons.logging.log</code> is also consulted).</li>
|
* {@code org.apache.commons.logging.log} is also consulted).</li>
|
||||||
* <li>Look for a system property named
|
* <li>Look for a system property named
|
||||||
* <code>org.apache.commons.logging.Log</code> (for backwards
|
* {@code org.apache.commons.logging.Log} (for backwards
|
||||||
* compatibility to pre-1.0 versions of this API, a system property
|
* compatibility to pre-1.0 versions of this API, a system property
|
||||||
* <code>org.apache.commons.logging.log</code> is also consulted).</li>
|
* {@code org.apache.commons.logging.log} is also consulted).</li>
|
||||||
* <li>If the Log4J logging system is available in the application
|
* <li>If the Log4J logging system is available in the application
|
||||||
* class path, use the corresponding wrapper class
|
* class path, use the corresponding wrapper class
|
||||||
* (<a href="impl/Log4JLogger.html">Log4JLogger</a>).</li>
|
* (<a href="impl/Log4JLogger.html">Log4JLogger</a>).</li>
|
||||||
@@ -137,8 +137,8 @@
|
|||||||
* </ul></li>
|
* </ul></li>
|
||||||
* <li>Load the class of the specified name from the thread context class
|
* <li>Load the class of the specified name from the thread context class
|
||||||
* loader (if any), or from the class loader that loaded the
|
* loader (if any), or from the class loader that loaded the
|
||||||
* <code>LogFactory</code> class otherwise.</li>
|
* {@code LogFactory} class otherwise.</li>
|
||||||
* <li>Instantiate an instance of the selected <code>Log</code>
|
* <li>Instantiate an instance of the selected {@code Log}
|
||||||
* implementation class, passing the specified name as the single
|
* implementation class, passing the specified name as the single
|
||||||
* argument to its constructor.</li>
|
* argument to its constructor.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
@@ -151,7 +151,7 @@
|
|||||||
* <p>Each individual <a href="Log.html">Log</a> implementation may
|
* <p>Each individual <a href="Log.html">Log</a> implementation may
|
||||||
* support its own configuration properties. These will be documented in the
|
* support its own configuration properties. These will be documented in the
|
||||||
* class descriptions for the corresponding implementation class.</p>
|
* class descriptions for the corresponding implementation class.</p>
|
||||||
* <p>Finally, some <code>Log</code> implementations (such as the one for Log4J)
|
* <p>Finally, some {@code Log} implementations (such as the one for Log4J)
|
||||||
* require an external configuration file for the entire logging environment.
|
* require an external configuration file for the entire logging environment.
|
||||||
* This file should be prepared in a manner that is specific to the actual logging
|
* This file should be prepared in a manner that is specific to the actual logging
|
||||||
* technology being used.</p>
|
* technology being used.</p>
|
||||||
@@ -168,12 +168,12 @@
|
|||||||
* purposes. A typical scenario for a server application is to have each
|
* purposes. A typical scenario for a server application is to have each
|
||||||
* major component of the server use its own Log instance.</li>
|
* major component of the server use its own Log instance.</li>
|
||||||
* <li>Cause messages to be logged (if the corresponding detail level is enabled)
|
* <li>Cause messages to be logged (if the corresponding detail level is enabled)
|
||||||
* by calling appropriate methods (<code>trace()</code>, <code>debug()</code>,
|
* by calling appropriate methods ({@code trace()}, {@code debug()},
|
||||||
* <code>info()</code>, <code>warn()</code>, <code>error</code>, and
|
* {@code info()}, {@code warn()}, {@code error}, and
|
||||||
* <code>fatal()</code>).</li>
|
* {@code fatal()}).</li>
|
||||||
* </ol>
|
* </ol>
|
||||||
* <p>For convenience, <code>LogFactory</code> also offers a static method
|
* <p>For convenience, {@code LogFactory} also offers a static method
|
||||||
* <code>getLog()</code> that combines the typical two-step pattern:</p>
|
* {@code getLog()} that combines the typical two-step pattern:</p>
|
||||||
* <pre>
|
* <pre>
|
||||||
* Log log = LogFactory.getFactory().getInstance(Foo.class);
|
* Log log = LogFactory.getFactory().getInstance(Foo.class);
|
||||||
* </pre>
|
* </pre>
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ public class WeakHashtableTestCase extends TestCase {
|
|||||||
|
|
||||||
assertEquals(Long.valueOf(1066), weakHashtable.get(anotherKey));
|
assertEquals(Long.valueOf(1066), weakHashtable.get(anotherKey));
|
||||||
|
|
||||||
// Test compliance with the hashtable API re nulls
|
// Test compliance with the Hashtable API re nulls
|
||||||
Exception caught = null;
|
Exception caught = null;
|
||||||
try {
|
try {
|
||||||
weakHashtable.put(null, new Object());
|
weakHashtable.put(null, new Object());
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import org.apache.commons.logging.PathableTestSuite;
|
|||||||
*/
|
*/
|
||||||
public class SecurityAllowedTestCase extends TestCase {
|
public class SecurityAllowedTestCase extends TestCase {
|
||||||
|
|
||||||
// Dummy special hashtable, so we can tell JCL to use this instead of
|
// Dummy special Hashtable, so we can tell JCL to use this instead of
|
||||||
// the standard one.
|
// the standard one.
|
||||||
public static class CustomHashtable extends Hashtable {
|
public static class CustomHashtable extends Hashtable {
|
||||||
|
|
||||||
|
|||||||
@@ -39,24 +39,28 @@ import org.apache.commons.logging.PathableTestSuite;
|
|||||||
* Performing tests with security permissions disabled is tricky, as building error
|
* Performing tests with security permissions disabled is tricky, as building error
|
||||||
* messages on failure requires certain security permissions. If the security manager
|
* messages on failure requires certain security permissions. If the security manager
|
||||||
* blocks these, then the test can fail without the error messages being output.
|
* blocks these, then the test can fail without the error messages being output.
|
||||||
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* This class has only one unit test, as we are (in part) checking behavior in
|
* This class has only one unit test, as we are (in part) checking behavior in
|
||||||
* the static block of the LogFactory class. As that class cannot be unloaded after
|
* the static block of the LogFactory class. As that class cannot be unloaded after
|
||||||
* being loaded into a class loader, the only workaround is to use the
|
* being loaded into a class loader, the only workaround is to use the
|
||||||
* PathableClassLoader approach to ensure each test is run in its own
|
* PathableClassLoader approach to ensure each test is run in its own
|
||||||
* class loader, and use a separate test class for each test.
|
* class loader, and use a separate test class for each test.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class SecurityForbiddenTestCase extends TestCase {
|
public class SecurityForbiddenTestCase extends TestCase {
|
||||||
|
|
||||||
// Dummy special hashtable, so we can tell JCL to use this instead of
|
/**
|
||||||
// the standard one.
|
* Dummy special Hashtable, so we can tell JCL to use this instead of the standard one.
|
||||||
public static class CustomHashtable extends Hashtable {
|
*/
|
||||||
|
public static class CustomHashtable extends Hashtable<Object, Object> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated serial version ID.
|
* Generated serial version ID.
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 7224652794746236024L;
|
private static final long serialVersionUID = 7224652794746236024L;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the tests included in this test suite.
|
* Return the tests included in this test suite.
|
||||||
*/
|
*/
|
||||||
@@ -112,7 +116,7 @@ public class SecurityForbiddenTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test what happens when JCL is run with absolutely no security
|
* Tests what happens when JCL is run with absolutely no security
|
||||||
* privileges at all, including reading system properties. Everything
|
* privileges at all, including reading system properties. Everything
|
||||||
* should fall back to the built-in defaults.
|
* should fall back to the built-in defaults.
|
||||||
*/
|
*/
|
||||||
@@ -148,7 +152,7 @@ public class SecurityForbiddenTestCase extends TestCase {
|
|||||||
final Object factoryTable = factoryField.get(null);
|
final Object factoryTable = factoryField.get(null);
|
||||||
assertNotNull(factoryTable);
|
assertNotNull(factoryTable);
|
||||||
final String ftClassName = factoryTable.getClass().getName();
|
final String ftClassName = factoryTable.getClass().getName();
|
||||||
assertNotEquals("Custom hashtable unexpectedly used",
|
assertNotEquals("Custom Hashtable unexpectedly used",
|
||||||
CustomHashtable.class.getName(), ftClassName);
|
CustomHashtable.class.getName(), ftClassName);
|
||||||
|
|
||||||
assertEquals(0, mySecurityManager.getUntrustedCodeCount());
|
assertEquals(0, mySecurityManager.getUntrustedCodeCount());
|
||||||
@@ -165,7 +169,7 @@ public class SecurityForbiddenTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test what happens when JCL is run with absolutely no security
|
* Tests what happens when JCL is run with absolutely no security
|
||||||
* privileges at all and a class loaded with a different class loader
|
* privileges at all and a class loaded with a different class loader
|
||||||
* than the context class loader of the current thread tries to log something.
|
* than the context class loader of the current thread tries to log something.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user