public class LogFactoryImpl extends LogFactory
Title: 常用代码打包
Description:
Concrete subclass of LogFactory that implements the
following algorithm to dynamically select a logging implementation
class to instantiate a wrapper for.
org.apache.commons.logging.Log to identify the
requested implementation class.org.apache.commons.logging.Log system property
to identify the requested implementation class.org.apache.commons.logging.impl.Log4JLogger.org.apache.commons.logging.impl.Jdk14Logger.org.apache.commons.logging.impl.SimpleLog.If the selected Log implementation class has a
setLogFactory() method that accepts a LogFactory
parameter, this method will be called on each newly created instance
to identify the associated factory. This makes factory configuration
attributes available to the Log instance, if it so desires.
This factory will remember previously created Log instances
for the same name, and will return them on repeated requests to the
getInstance() method. This implementation ignores any
configured attributes.
Copyright: Copyright (c) 2006
Company: www.justdos.net
| 限定符和类型 | 字段和说明 |
|---|---|
protected Hashtable |
instances
The
Log instances that have
already been created, keyed by logger name. |
protected Constructor |
logConstructor
The one-argument constructor of the
Log
implementation class that will be used to create new instances. |
protected Class[] |
logConstructorSignature
The signature of the Constructor to be used.
|
protected Method |
logMethod
The one-argument
setLogFactory method of the selected
Log method, if it exists. |
protected Class[] |
logMethodSignature
The signature of the
setLogFactory method to be used. |
configKey, factories, FACTORY_DEFAULT| 构造器和说明 |
|---|
LogFactoryImpl()
Public no-arguments constructor required by the lookup mechanism.
|
| 限定符和类型 | 方法和说明 |
|---|---|
Log |
getInstance(Class clazz)
Convenience method to derive a name from the specified class and
call
getInstance(String) with it. |
Log |
getInstance(String name)
Construct (if necessary) and return a
Log instance,
using the factory's current set of configuration attributes. |
protected String |
getLogClassName()
Return the fully qualified Java classname of the
Log
implementation we will be using. |
protected Constructor |
getLogConstructor()
Return the
Constructor that can be called to instantiate
new Log instances. |
protected boolean |
isJdk14Available()
Is JDK 1.4 or later logging available?
|
protected boolean |
isLog4JAvailable()
Is a Log4J implementation available?
|
protected Log |
newInstance(String name)
Create and return a new
Log
instance for the specified name. |
void |
release()
Release any internal references to previously created
Log
instances returned by this factory. |
getContextClassLoader, getFactory, getLog, getLog, newFactory, release, releaseAllprotected Hashtable instances
Log instances that have
already been created, keyed by logger name.protected Constructor logConstructor
Log
implementation class that will be used to create new instances.
This value is initialized by getLogConstructor(),
and then returned repeatedly.protected Class[] logConstructorSignature
protected Method logMethod
setLogFactory method of the selected
Log method, if it exists.protected Class[] logMethodSignature
setLogFactory method to be used.public LogFactoryImpl()
public Log getInstance(Class clazz) throws LogConfigurationException
getInstance(String) with it.getInstance 在类中 LogFactoryclazz - Class for which a suitable Log name will be derivedLogConfigurationException - if a suitable Log
instance cannot be returnedpublic 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.
getInstance 在类中 LogFactoryname - Logical name of the Log instance to be
returned (the meaning of this name is only known to the underlying
logging implementation that is being wrapped)LogConfigurationException - if a suitable Log
instance cannot be returnedpublic void release()
Log
instances returned by this factory. This is useful 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.release 在类中 LogFactoryprotected String getLogClassName()
Log
implementation we will be using.protected Constructor getLogConstructor() throws LogConfigurationException
Return the Constructor that can be called to instantiate
new Log instances.
IMPLEMENTATION NOTE - Race conditions caused by
calling this method from more than one thread are ignored, because
the same Constructor instance will ultimately be derived
in all circumstances.
LogConfigurationException - if a suitable constructor
cannot be returnedprotected boolean isJdk14Available()
protected boolean isLog4JAvailable()
protected Log newInstance(String name) throws LogConfigurationException
Log
instance for the specified name.name - Name of the new loggerLogConfigurationException - if a new instance cannot
be createdCopyright © 2023 onecode. All rights reserved.