Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

de.danet.an.util.log4j
Class ApplLog4jFactory  view ApplLog4jFactory download ApplLog4jFactory.java

java.lang.Object
  extended byorg.apache.commons.logging.LogFactory
      extended byde.danet.an.util.log4j.ApplLog4jFactory

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

This class provides an alternate access to the log4j logging library for Apache commons logging.. The necessity arises from the usage of log4j as logging package in the JBoss application server. As log4j is already included in JBoss' classpath and configured by JBoss, we cannot have really independent application level logging.

The central problem is the static default hierarchy used by org.apache.log4j.Category. For a distinct application level logging we need an alternate hierarchy. This factory uses such an alternate hierarchy.

This implementation is based on the Log4JFactory from Apache.

Version:
$Revision: 1.2 $

Field Summary
private  java.util.Hashtable attributes
          The configuration attributes for this org.apache.commons.logging.LogFactory.
private  java.util.Hashtable instances
           
 
Fields inherited from class org.apache.commons.logging.LogFactory
factories, FACTORY_DEFAULT, FACTORY_PROPERTIES, FACTORY_PROPERTY, SERVICE_ID
 
Constructor Summary
ApplLog4jFactory()
           
 
Method Summary
 java.lang.Object getAttribute(java.lang.String name)
          Return the configuration attribute with the specified name (if any), or null if there is no such attribute.
 java.lang.String[] getAttributeNames()
          Return an array containing the names of all currently defined configuration attributes.
 org.apache.commons.logging.Log getInstance(java.lang.Class clazz)
          Convenience method to derive a name from the specified class and call getInstance(String) with it.
 org.apache.commons.logging.Log getInstance(java.lang.String name)
          Construct (if necessary) and return a Log instance, using the factory's current set of configuration attributes.
 void release()
          Release any internal references to previously created org.apache.commons.logging.Log instances returned by this factory.
 void removeAttribute(java.lang.String name)
          Remove any configuration attribute associated with the specified name.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Set the configuration attribute with the specified 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

attributes

private java.util.Hashtable attributes
The configuration attributes for this org.apache.commons.logging.LogFactory.


instances

private java.util.Hashtable instances
Constructor Detail

ApplLog4jFactory

public ApplLog4jFactory()
Method Detail

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Return the configuration attribute with the specified name (if any), or null if there is no such attribute.


getAttributeNames

public java.lang.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.


getInstance

public org.apache.commons.logging.Log getInstance(java.lang.Class clazz)
                                           throws org.apache.commons.logging.LogConfigurationException
Convenience method to derive a name from the specified class and call getInstance(String) with it.


getInstance

public org.apache.commons.logging.Log getInstance(java.lang.String name)
                                           throws org.apache.commons.logging.LogConfigurationException
Description copied from class: org.apache.commons.logging.LogFactory

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.


release

public void release()
Release any internal references to previously created org.apache.commons.logging.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.


removeAttribute

public void removeAttribute(java.lang.String name)
Remove any configuration attribute associated with the specified name. If there is no such attribute, no action is taken.


setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Set the configuration attribute with the specified name. Calling this with a null value is equivalent to calling removeAttribute(name).