public static final String | HASHTABLE_IMPLEMENTATION_PROPERTY | Setting this system property
(org.apache.commons.logging.LogFactory.HashtableImpl )
value allows the Hashtable used to store
classloaders to be substituted by an alternative implementation.
Note: LogFactory will print:
[ERROR] LogFactory: Load of custom hashtable failed
to system error and then continue using a standard Hashtable.
Usage: Set this property when Java is invoked
and LogFactory will attempt to load a new instance
of the given implementation class.
For example, running the following ant scriplet:
<java classname="${test.runner}" fork="yes" failonerror="${test.failonerror}">
...
<sysproperty
key="org.apache.commons.logging.LogFactory.HashtableImpl"
value="org.apache.commons.logging.AltHashtable"/>
</java>
will mean that LogFactory will load an instance of
org.apache.commons.logging.AltHashtable .
A typical use case is to allow a custom
Hashtable implementation using weak references to be substituted.
This will allow classloaders to be garbage collected without
the need to release them (on 1.3+ JVMs only, of course ;)
|
Method from org.apache.commons.logging.LogFactory Detail: |
protected static Object createFactory(String factoryClass,
ClassLoader classLoader) {
// This will be used to diagnose bad configurations
// and allow a useful message to be sent to the user
Class logFactoryClass = null;
try {
if (classLoader != null) {
try {
// First the given class loader param (thread class loader)
// Warning: must typecast here & allow exception
// to be generated/caught & recast properly.
logFactoryClass = classLoader.loadClass(factoryClass);
if (LogFactory.class.isAssignableFrom(logFactoryClass)) {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"Loaded class " + logFactoryClass.getName()
+ " from classloader " + objectId(classLoader));
}
} else {
//
// This indicates a problem with the ClassLoader tree.
// 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.
//
if (isDiagnosticsEnabled()) {
logDiagnostic(
"Factory class " + logFactoryClass.getName()
+ " loaded from classloader " + objectId(logFactoryClass.getClassLoader())
+ " does not extend '" + LogFactory.class.getName()
+ "' as loaded by this classloader.");
logHierarchy("[BAD CL TREE] ", classLoader);
}
}
return (LogFactory) logFactoryClass.newInstance();
} catch (ClassNotFoundException ex) {
if (classLoader == thisClassLoader) {
// Nothing more to try, onwards.
if (isDiagnosticsEnabled()) {
logDiagnostic(
"Unable to locate any class called '" + factoryClass
+ "' via classloader " + objectId(classLoader));
}
throw ex;
}
// ignore exception, continue
} catch (NoClassDefFoundError e) {
if (classLoader == thisClassLoader) {
// Nothing more to try, onwards.
if (isDiagnosticsEnabled()) {
logDiagnostic(
"Class '" + factoryClass + "' cannot be loaded"
+ " via classloader " + objectId(classLoader)
+ " - it depends on some other class that cannot"
+ " be found.");
}
throw e;
}
// ignore exception, continue
} catch(ClassCastException e) {
if (classLoader == thisClassLoader) {
// There's no point in falling through to the code below that
// tries again with thisClassLoader, because we've just tried
// loading with that loader (not the TCCL). Just throw an
// 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 =
"The application has specified that a custom LogFactory implementation should be used but " +
"Class '" + factoryClass + "' cannot be converted to '"
+ LogFactory.class.getName() + "'. ";
if (implementsLogFactory) {
msg = msg + "The conflict is caused by the presence of multiple LogFactory classes in incompatible classloaders. " +
"Background can be found in http://commons.apache.org/logging/tech.html. " +
"If you have not explicitly specified a custom LogFactory then it is likely that " +
"the container has set one without your knowledge. " +
"In this case, consider using the commons-logging-adapters.jar file or " +
"specifying the standard LogFactory from the command line. ";
} else {
msg = msg + "Please check the custom implementation. ";
}
msg = msg + "Help can be found @http://commons.apache.org/logging/troubleshooting.html.";
if (isDiagnosticsEnabled()) {
logDiagnostic(msg);
}
ClassCastException ex = new ClassCastException(msg);
throw ex;
}
// 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
// a shared classpath but the TCCL has a copy of LogFactory and the
// specified LogFactory implementation; we will fall back to using the
// LogFactory implementation from the same classloader as this class.
//
// Issue: this doesn't handle the reverse case, where this LogFactory
// is in the webapp, and the specified LogFactory implementation is
// in a shared classpath. In that case:
// (a) the class really does implement LogFactory (bad log msg above)
// (b) the fallback code will result in exactly the same problem.
}
}
/* At this point, either classLoader == null, OR
* classLoader was unable to load factoryClass.
*
* In either case, we call Class.forName, which is equivalent
* 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
* consequences of this.
*
* Notes:
* * LogFactory.class.getClassLoader() may return 'null'
* if LogFactory is loaded by the bootstrap classloader.
*/
// Warning: must typecast here & allow exception
// to be generated/caught & recast properly.
if (isDiagnosticsEnabled()) {
logDiagnostic(
"Unable to load factory class via classloader "
+ objectId(classLoader)
+ " - trying the classloader associated with this LogFactory.");
}
logFactoryClass = Class.forName(factoryClass);
return (LogFactory) logFactoryClass.newInstance();
} catch (Exception e) {
// Check to see if we've got a bad configuration
if (isDiagnosticsEnabled()) {
logDiagnostic("Unable to create LogFactory instance.");
}
if (logFactoryClass != null
&& !LogFactory.class.isAssignableFrom(logFactoryClass)) {
return new LogConfigurationException(
"The chosen LogFactory implementation does not extend LogFactory."
+ " Please check your configuration.",
e);
}
return new LogConfigurationException(e);
}
}
Implements the operations described in the javadoc for newFactory. |
protected static ClassLoader directGetContextClassLoader() throws LogConfigurationException {
ClassLoader classLoader = null;
try {
// Are we running on a JDK 1.2 or later system?
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);
} catch (IllegalAccessException e) {
throw new LogConfigurationException
("Unexpected IllegalAccessException", e);
} catch (InvocationTargetException e) {
/**
* InvocationTargetException is thrown by 'invoke' when
* the method being invoked (getContextClassLoader) throws
* an exception.
*
* getContextClassLoader() throws SecurityException when
* the context class loader isn't an ancestor of the
* calling class's class loader, or if security
* permissions are restricted.
*
* In the first case (not related), we want to ignore and
* keep going. We cannot help but also ignore the second
* with the logic below, but other calls elsewhere (to
* obtain a class loader) will trigger this exception where
* we can make a distinction.
*/
if (e.getTargetException() instanceof SecurityException) {
; // ignore
} else {
// Capture 'e.getTargetException()' exception for details
// alternate: log 'e.getTargetException()', and pass back 'e'.
throw new LogConfigurationException
("Unexpected InvocationTargetException", e.getTargetException());
}
}
} catch (NoSuchMethodException e) {
// Assume we are running on JDK 1.1
classLoader = getClassLoader(LogFactory.class);
// We deliberately don't log a message here to outputStream;
// this message would be output for every call to LogFactory.getLog()
// when running on JDK1.1
//
// if (outputStream != null) {
// outputStream.println(
// "Method Thread.getContextClassLoader does not exist;"
// + " assuming this is JDK 1.1, and that the context"
// + " classloader is the same as the class that loaded"
// + " the concrete LogFactory class.");
// }
}
// Return the selected class loader
return classLoader;
}
Return the thread context class loader if available; otherwise return
null.
Most/all code should call getContextClassLoaderInternal rather than
calling this method directly.
The thread context class loader is available for JDK 1.2
or later, if certain security conditions are met.
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. |
abstract public Object getAttribute(String name)
Return the configuration attribute with the specified name (if any),
or null if there is no such attribute. |
abstract public String[] getAttributeNames()
Return an array containing the names of all currently defined
configuration attributes. If there are no such attributes, a zero
length array is returned. |
protected static ClassLoader getClassLoader(Class clazz) {
try {
return clazz.getClassLoader();
} catch(SecurityException ex) {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"Unable to get classloader for class '" + clazz
+ "' due to security restrictions - " + ex.getMessage());
}
throw ex;
}
}
Safely get access to the classloader for the specified class.
Theoretically, calling getClassLoader can throw a security exception,
and so should be done under an AccessController in order to provide
maximum flexibility. However in practice people don't appear to use
security policies that forbid getClassLoader calls. So for the moment
all code is written to call this method rather than Class.getClassLoader,
so that we could put AccessController stuff in this method without any
disruption later if we need to.
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:
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
above, security policies that prevent classloader access aren't common.
Note that returning an object fetched via an AccessController would
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. |
protected static ClassLoader getContextClassLoader() throws LogConfigurationException {
return directGetContextClassLoader();
}
Returns the current context classloader.
In versions prior to 1.1, this method did not use an AccessController.
In version 1.1, an AccessController wrapper was incorrectly added to
this method, causing a minor security flaw.
In version 1.1.1 this change was reverted; this method no longer uses
an AccessController. User code wishing to obtain the context classloader
must invoke this method via AccessController.doPrivileged if it needs
support for that. |
public static LogFactory getFactory() throws LogConfigurationException {
// Identify the class loader we will be using
ClassLoader contextClassLoader = getContextClassLoaderInternal();
if (contextClassLoader == null) {
// This is an odd enough situation to report about. This
// output will be a nuisance on JDK1.1, as the system
// classloader is null in that environment.
if (isDiagnosticsEnabled()) {
logDiagnostic("Context classloader is null.");
}
}
// Return any previously registered factory for this class loader
LogFactory factory = getCachedFactory(contextClassLoader);
if (factory != null) {
return factory;
}
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] LogFactory implementation requested for the first time for context classloader "
+ objectId(contextClassLoader));
logHierarchy("[LOOKUP] ", contextClassLoader);
}
// Load properties file.
//
// If the properties file exists, then its contents are used as
// "attributes" on the LogFactory implementation class. One particular
// 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
// another in the end we may as well look for it first.
Properties props = getConfigurationFile(contextClassLoader, FACTORY_PROPERTIES);
// Determine whether we will be using the thread context class loader to
// load logging classes or not by checking the loaded properties file (if any).
ClassLoader baseClassLoader = contextClassLoader;
if (props != null) {
String useTCCLStr = props.getProperty(TCCL_KEY);
if (useTCCLStr != null) {
// The Boolean.valueOf(useTCCLStr).booleanValue() formulation
// is required for Java 1.2 compatability.
if (Boolean.valueOf(useTCCLStr).booleanValue() == false) {
// Don't use current context classloader when locating any
// LogFactory or Log classes, just use the class that loaded
// this abstract class. When this class is deployed in a shared
// classpath of a container, it means webapps cannot deploy their
// 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;
}
}
}
// 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...");
}
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);
}
factory = newFactory(factoryClass, baseClassLoader, contextClassLoader);
} else {
if (isDiagnosticsEnabled()) {
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...");
}
; // ignore
} catch(RuntimeException e) {
// This is not consistent with the behaviour when a bad LogFactory class is
// specified in a services file.
//
// 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.");
}
throw e;
}
// 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
// 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...");
}
try {
InputStream is = getResourceAsStream(contextClassLoader,
SERVICE_ID);
if( is != null ) {
// This code is needed by EBCDIC and other strange systems.
// It's a fix for bugs reported in xerces
BufferedReader rd;
try {
rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
} catch (java.io.UnsupportedEncodingException e) {
rd = new BufferedReader(new InputStreamReader(is));
}
String factoryClassName = rd.readLine();
rd.close();
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.");
}
factory = newFactory(factoryClassName, baseClassLoader, contextClassLoader );
}
} else {
// is == null
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] No resource file with name '" + SERVICE_ID
+ "' found.");
}
}
} catch( Exception ex ) {
// note: if the specified LogFactory class wasn't compatible with LogFactory
// for some reason, a ClassCastException will be caught here, and attempts will
// continue to find a compatible class.
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] A security exception occurred while trying to create an"
+ " instance of the custom factory class"
+ ": [" + trim(ex.getMessage())
+ "]. Trying alternative implementations...");
}
; // ignore
}
}
// Third try looking into the properties file read earlier (if found)
if (factory == null) {
if (props != null) {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] Looking in properties file for entry with key '"
+ FACTORY_PROPERTY
+ "' to define the LogFactory subclass to use...");
}
String factoryClass = props.getProperty(FACTORY_PROPERTY);
if (factoryClass != null) {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] Properties file specifies LogFactory subclass '"
+ factoryClass + "'");
}
factory = newFactory(factoryClass, baseClassLoader, contextClassLoader);
// TODO: think about whether we need to handle exceptions from newFactory
} else {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] Properties file has no entry specifying LogFactory subclass.");
}
}
} else {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] No properties file available to determine"
+ " LogFactory subclass from..");
}
}
}
// Fourth, try the fallback implementation class
if (factory == null) {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] Loading the default LogFactory implementation '" + FACTORY_DEFAULT
+ "' via the same classloader that loaded this LogFactory"
+ " class (ie not looking in the context classloader).");
}
// Note: unlike the above code which can try to load custom LogFactory
// implementations via the TCCL, we don't try to load the default LogFactory
// implementation via the context classloader because:
// * that can cause problems (see comments in newFactory method)
// * no-one should be customising the code of the default class
// Yes, we do give up the ability for the child to ship a newer
// version of the LogFactoryImpl class and have it used dynamically
// by an old LogFactory class in the parent, but that isn't
// necessarily a good idea anyway.
factory = newFactory(FACTORY_DEFAULT, thisClassLoader, contextClassLoader);
}
if (factory != null) {
/**
* Always cache using context class loader.
*/
cacheFactory(contextClassLoader, factory);
if( props!=null ) {
Enumeration names = props.propertyNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
String value = props.getProperty(name);
factory.setAttribute(name, value);
}
}
}
return factory;
}
Construct (if necessary) and return a LogFactory
instance, using the following ordered lookup procedure to determine
the name of the implementation class to be loaded.
- The
org.apache.commons.logging.LogFactory system
property.
- The JDK 1.3 Service Discovery mechanism
- Use the properties file
commons-logging.properties
file, if found in the class path of this class. The configuration
file is in standard java.util.Properties format and
contains the fully qualified name of the implementation class
with the key being the system property defined above.
- Fall back to a default implementation class
(
org.apache.commons.logging.impl.LogFactoryImpl ).
NOTE - If the properties file method of identifying the
LogFactory implementation class is utilized, all of the
properties defined in this file will be set as configuration attributes
on the corresponding LogFactory instance.
NOTE - In a multithreaded environment it is possible
that two different instances will be returned for the same
classloader environment.
|
abstract public Log getInstance(Class clazz) throws LogConfigurationException
Convenience method to derive a name from the specified class and
call getInstance(String) with it. |
abstract public Log getInstance(String name) throws LogConfigurationException
Construct (if necessary) and return a Log instance,
using the factory's current set of configuration attributes.
NOTE - Depending upon the implementation of
the LogFactory you are using, the Log
instance you are returned may or may not be local to the current
application, and may or may not be returned again on a subsequent
call with the same name argument.
|
public static Log getLog(Class clazz) throws LogConfigurationException {
return (getFactory().getInstance(clazz));
}
Convenience method to return a named logger, without the application
having to care about factories. |
public static Log getLog(String name) throws LogConfigurationException {
return (getFactory().getInstance(name));
}
Convenience method to return a named logger, without the application
having to care about factories. |
protected static boolean isDiagnosticsEnabled() {
return diagnosticsStream != null;
}
Indicates true if the user has enabled internal logging.
By the way, sorry for the incorrect grammar, but calling this method
areDiagnosticsEnabled just isn't java beans style. |
protected static final void logRawDiagnostic(String msg) {
if (diagnosticsStream != null) {
diagnosticsStream.println(msg);
diagnosticsStream.flush();
}
}
Write the specified message to the internal logging destination. |
protected static LogFactory newFactory(String factoryClass,
ClassLoader classLoader) {
return newFactory(factoryClass, classLoader, null);
}
Method provided for backwards compatibility; see newFactory version that
takes 3 parameters.
This method would only ever be called in some rather odd situation.
Note that this method is static, so overriding in a subclass doesn't
have any effect unless this method is called from a method in that
subclass. However this method only makes sense to use from the
getFactory method, and as that is almost always invoked via
LogFactory.getFactory, any custom definition in a subclass would be
pointless. Only a class with a custom getFactory method, then invoked
directly via CustomFactoryImpl.getFactory or similar would ever call
this. Anyway, it's here just in case, though the "managed class loader"
value output to the diagnostics will not report the correct value. |
protected static LogFactory newFactory(String factoryClass,
ClassLoader classLoader,
ClassLoader contextClassLoader) throws LogConfigurationException {
// Note that any unchecked exceptions thrown by the createFactory
// method will propagate out of this method; in particular a
// ClassCastException can be thrown.
Object result = AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
return createFactory(factoryClass, classLoader);
}
});
if (result instanceof LogConfigurationException) {
LogConfigurationException ex = (LogConfigurationException) result;
if (isDiagnosticsEnabled()) {
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));
}
return (LogFactory)result;
}
Return a new instance of the specified LogFactory
implementation class, loaded by the specified class loader.
If that fails, try the class loader used to load this
(abstract) LogFactory.
ClassLoader conflicts
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.
The problem is the same one that can occur when loading a concrete Log
subclass via a context classloader.
The problem occurs when code running in the context classloader calls
class X which was loaded via a parent classloader, and class X then calls
LogFactory.getFactory (either directly or via LogFactory.getLog). Because
class X was loaded via the parent, it binds to LogFactory loaded via
the parent. When the code in this method finds some LogFactoryYYYY
class in the child (context) classloader, and there also happens to be a
LogFactory class defined in the child classloader, then LogFactoryYYYY
will be bound to LogFactory@childloader. It cannot be cast to
LogFactory@parentloader, ie this method cannot return the object as
the desired type. Note that it doesn't matter if the LogFactory class
in the child classloader is identical to the LogFactory class in the
parent classloader, they are not compatible.
The solution taken here is to simply print out an error message when
this occurs then throw an exception. The deployer of the application
must ensure they remove all occurrences of the LogFactory class from
the child classloader in order to resolve the issue. Note that they
do not have to move the custom LogFactory subclass; that is ok as
long as the only LogFactory class it can find to bind to is in the
parent classloader.
|
public static String objectId(Object o) {
if (o == null) {
return "null";
} else {
return o.getClass().getName() + "@" + System.identityHashCode(o);
}
}
Returns a string that uniquely identifies the specified object, including
its class.
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. |
abstract public void release()
Release any internal references to previously created Log
instances returned by this factory. This is useful in environments
like servlet containers, which implement application reloading by
throwing away a ClassLoader. Dangling references to objects in that
class loader would prevent garbage collection. |
public static void release(ClassLoader classLoader) {
if (isDiagnosticsEnabled()) {
logDiagnostic("Releasing factory for classloader " + objectId(classLoader));
}
synchronized (factories) {
if (classLoader == null) {
if (nullClassLoaderFactory != null) {
nullClassLoaderFactory.release();
nullClassLoaderFactory = null;
}
} else {
LogFactory factory = (LogFactory) factories.get(classLoader);
if (factory != null) {
factory.release();
factories.remove(classLoader);
}
}
}
}
Release any internal references to previously created LogFactory
instances that have been associated with the specified class loader
(if any), after calling the instance method release() on
each of them. |
public static void releaseAll() {
if (isDiagnosticsEnabled()) {
logDiagnostic("Releasing factory for all classloaders.");
}
synchronized (factories) {
Enumeration elements = factories.elements();
while (elements.hasMoreElements()) {
LogFactory element = (LogFactory) elements.nextElement();
element.release();
}
factories.clear();
if (nullClassLoaderFactory != null) {
nullClassLoaderFactory.release();
nullClassLoaderFactory = null;
}
}
}
Release any internal references to previously created LogFactory
instances, after calling the instance method release() on
each of them. This is useful in environments like servlet containers,
which implement application reloading by throwing away a ClassLoader.
Dangling references to objects in that class loader would prevent
garbage collection. |
abstract public void removeAttribute(String name)
Remove any configuration attribute associated with the specified name.
If there is no such attribute, no action is taken. |
abstract public void setAttribute(String name,
Object value)
Set the configuration attribute with the specified name. Calling
this with a null value is equivalent to calling
removeAttribute(name) . |