TPTP 4.4.0 Platform Project
Public API Specification

org.eclipse.hyades.logging.commons
Class LoggerFactory

java.lang.Object
  extended byorg.apache.commons.logging.LogFactory
      extended byorg.eclipse.hyades.logging.commons.LoggerFactory

public class LoggerFactory
extends org.apache.commons.logging.LogFactory

Implementation of the Apache Commons org.apache.commons.logging.LogFacotry abstract class which represents a proxy factory specific for org.eclipse.hyades.logging.commons.Logger instances.

This proxy factory is intended for use in multiple class loader environments where one or more different types of loggers and their factories are required for each separate class loader, all utilizing the same Apache Commons binaries. Alternatively, users may configure the default org.apache.commons.logging.LogFactory implementation to use the generate org.eclipse.hyades.logging.commons.Logger instances but all class loaders will be forced to use the org.eclipse.hyades.logging.commons.Logger instances.

An instance of this class will be returned from the static getFactory() API on the default org.apache.commons.logging.LogFactory implementation. The org.apache.commons.logging.LogFactory implementation uses the following discovery process to resolve the configured org.apache.commons.logging.LogFactory implementation within the caller's class loader:

1) Look for a system property named org.apache.commons.logging.LogFactory.

For example, ...-Dorg.apache.commons.logging.LogFactory=org.eclipse.hyades.logging.commons.LoggerFactory... - or - System.setProperty("org.apache.commons.logging.LogFactory","org.eclipse.hyades.logging.commons.LoggerFactory");

2) Use the JDK 1.3 JAR Services Discovery mechanism (see http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html) to look for a resource named META-INF/services/org.apache.commons.logging.LogFactory whose first line is assumed to contain the desired class name.

For example (META-INF/services/org.apache.commons.logging.LogFactory), org.eclipse.hyades.logging.commons.LoggerFactory

2) Look for a properties file named commons-logging.properties visible in the application class path, with a property named org.apache.commons.logging.LogFactory defining the desired implementation class name.

For example, org.apache.commons.logging.LogFactory=org.eclipse.hyades.logging.commons.LoggerFactory

NOTE: Although this proxy factory provides functionality for setting/getting/removing configuration attributes, no configuration attributes are used internally. As such, setting any configuration attributes will have no effect aside from containment purposes.

NOTE: The Apache Commons logging classes must be on the CLASSPATH at run-time to utilize this logging class

Since:
August 13, 2004
See Also:
LogFactory, Logger

Field Summary
protected  java.util.Hashtable loggers
          Private store of org.eclipse.hyades.logging.commons.Logger instances.
 
Fields inherited from class org.apache.commons.logging.LogFactory
factories, FACTORY_DEFAULT, FACTORY_PROPERTIES, FACTORY_PROPERTY, SERVICE_ID
 
Constructor Summary
LoggerFactory()
          No-argument constructor.
 
Method Summary
 java.lang.Object getAttribute(java.lang.String name)
          Returns the configuration attribute with the specified non-null name, or null if no such named attribute exists.
 java.lang.String[] getAttributeNames()
          Returns an array containing the names of all currently defined configuration attributes.
 org.apache.commons.logging.Log getInstance(java.lang.Class classInstance)
          Convenience API which returns an instance of a named org.eclipse.hyades.logging.commons.Logger based on the name of the parameter class instance.
 org.apache.commons.logging.Log getInstance(java.lang.String loggerName)
          Returns an instance of a non-null named org.eclipse.hyades.logging.commons.Logger based on the parameter name.
 void release()
          Releases all cached org.eclipse.hyades.logging.commons.Logger instances created by this org.eclipse.hyades.logging.commons.LoggerFactory instance.
 void removeAttribute(java.lang.String name)
          Removes a configuration attribute with the specified non-null name.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Set a configuration attribute with the specified non-null name.
 
Methods inherited from class org.apache.commons.logging.LogFactory
getContextClassLoader, getFactory, getLog, getLog, newFactory, release, releaseAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loggers

protected java.util.Hashtable loggers
Private store of org.eclipse.hyades.logging.commons.Logger instances.

Constructor Detail

LoggerFactory

public LoggerFactory()
No-argument constructor.

Method Detail

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Set a configuration attribute with the specified non-null name.

Passing a null name results in no action.

Passing a null value is equivalent to calling #removeAttribute(String).

Parameters:
name - The non-null name of the configuration attribute.
value - The value of the configuration attribute, or null to remove the named configuration attribute.
See Also:
LogFactory.setAttribute(java.lang.String, java.lang.Object)

removeAttribute

public void removeAttribute(java.lang.String name)
Removes a configuration attribute with the specified non-null name.

Passing a null name results in a no-operation.

Parameters:
name - The non-null name of the configuration attribute to be removed.
See Also:
LogFactory.removeAttribute(java.lang.String)

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns the configuration attribute with the specified non-null name, or null if no such named attribute exists.

Passing a null name results in a null return value.

Parameters:
name - Name of the requested configuration attribute.
Returns:
The requested configuration attribute, or null if no such named attribute exists
See Also:
LogFactory.getAttribute(java.lang.String)

getAttributeNames

public java.lang.String[] getAttributeNames()
Returns an array containing the names of all currently defined configuration attributes. If there are no configuration attributes, a zero length array is returned.

Returns:
The array of configuration attribute names, otherwise a zero length array.
See Also:
LogFactory.getAttributeNames()

getInstance

public org.apache.commons.logging.Log getInstance(java.lang.Class classInstance)
                                           throws org.apache.commons.logging.LogConfigurationException
Convenience API which returns an instance of a named org.eclipse.hyades.logging.commons.Logger based on the name of the parameter class instance.

An instance of a named org.eclipse.hyades.logging.commons.Logger is created if no named instance current exists or all instances have been released.

Once a named org.eclipse.hyades.logging.commons.Logger is created, the instance is cached for future calls to retrieve the same named org.eclipse.hyades.logging.commons.Logger.

The name of the org.eclipse.hyades.logging.commons.Logger uniquely identifies an instance of an org.eclipse.hyades.logging.commons.Logger. All subsequent calls will return the same instance of the named org.eclipse.hyades.logging.commons.Logger.

Parameters:
classInstance - Class instance used to derive the name of the returned org.eclipse.hyades.logging.commons.Logger instance.
Returns:
A named org.eclipse.hyades.logging.commons.Logger instance.
Throws:
org.apache.commons.logging.LogConfigurationException - if the named org.eclipse.hyades.logging.commons.Logger instance could not be created.
See Also:
LogFactory.getInstance(java.lang.Class), getInstance(String)

getInstance

public org.apache.commons.logging.Log getInstance(java.lang.String loggerName)
                                           throws org.apache.commons.logging.LogConfigurationException
Returns an instance of a non-null named org.eclipse.hyades.logging.commons.Logger based on the parameter name.

Passing a null logger name results in a null return value.

An instance of a named org.eclipse.hyades.logging.commons.Logger is created if no named instance current exists or all instances have been released.

Once a named org.eclipse.hyades.logging.commons.Logger is created, the instance is cached for future calls to retrieve the same named org.eclipse.hyades.logging.commons.Logger.

The name of the org.eclipse.hyades.logging.commons.Logger uniquely identifies an instance of an org.eclipse.hyades.logging.commons.Logger. All subsequent calls will return the same instance of the named org.eclipse.hyades.logging.commons.Logger.

Parameters:
loggerName - The non-null name of the returned org.eclipse.hyades.logging.commons.Logger instance.
Returns:
A named org.eclipse.hyades.logging.commons.Logger instance, otherwise null if the parameter logger name is null.
Throws:
org.apache.commons.logging.LogConfigurationException - if the named org.eclipse.hyades.logging.commons.Logger instance could not be created.
See Also:
LogFactory.getInstance(java.lang.String)

release

public void release()
Releases all cached org.eclipse.hyades.logging.commons.Logger instances created by this org.eclipse.hyades.logging.commons.LoggerFactory instance.

All cached org.eclipse.hyades.logging.commons.Logger are de-registered (e.g. org.eclipse.hyades.logging.commons.Logger#finalize() before being released.

See Also:
LogFactory.release()

TPTP 4.4.0 Platform Project
Public API Specification