commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-commons/logging/src/java/org/apache/commons/logging/impl Log4jFactory.java LogFactoryImpl.java
Date Wed, 02 Apr 2003 01:53:04 GMT
craigmcc    2003/04/01 17:53:04

  Modified:    logging/src/java/org/apache/commons/logging/impl
                        Log4jFactory.java LogFactoryImpl.java
  Log:
  Per discussion on COMMONS-DEV and bug reports 17561 and 17894, deprecate
  the "proxy log factory" class o.a.c.l.impl.Log4jFactory (which didn't really
  accomplish any functional purpose), and remove from LogFactoryImpl the
  creation and use of a proxy instance.
  
  PR:  Bugzilla #17561
  Submitted by:  Felix Janssen <thundur at mayaxatl.org>
  
  PR:  Bugzilla #17894
  Submitted by:  Nathan Niesen <nathann at objectfx.com>
  
  Revision  Changes    Path
  1.4       +5 -0      jakarta-commons/logging/src/java/org/apache/commons/logging/impl/Log4jFactory.java
  
  Index: Log4jFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/Log4jFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Log4jFactory.java	30 Mar 2003 23:42:36 -0000	1.3
  +++ Log4jFactory.java	2 Apr 2003 01:53:04 -0000	1.4
  @@ -73,6 +73,11 @@
   /**
    * <p>Concrete subclass of {@link LogFactory} specific to log4j.
    *
  + * @deprecated Per discussion on COMMONS-DEV, the behind-the-scenes use
  + *  of this class as a proxy factory has been removed.  For 1.0, you
  + *  can still request it directly if you wish, but it doesn't really
  + *  do anything useful, and will be removed in 1.1.
  + *
    * @author Costin Manolache
    */
   public final class Log4jFactory extends LogFactory {
  
  
  
  1.25      +30 -63    jakarta-commons/logging/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
  
  Index: LogFactoryImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- LogFactoryImpl.java	30 Mar 2003 23:42:36 -0000	1.24
  +++ LogFactoryImpl.java	2 Apr 2003 01:53:04 -0000	1.25
  @@ -120,23 +120,12 @@
        */
       public LogFactoryImpl() {
           super();
  -        guessConfig();
       }
   
   
       // ----------------------------------------------------- Manifest Constants
   
   
  -    // Defaulting to NullLogger means important messages will be lost if
  -    // no other logger is available. This is as bad as having a catch() and
  -    // ignoring the exception because 'it can't happen'
  -    /**
  -     * The fully qualified name of the default {@link Log} implementation.
  -     */
  -    public static final String LOG_DEFAULT =
  -        "org.apache.commons.logging.impl.SimpleLog";
  -
  -
       /**
        * The name of the system property identifying our {@link Log}
        * implementation class.
  @@ -153,9 +142,6 @@
           "org.apache.commons.logging.log";
   
   
  -    private static final String LOG4JLOGIMPL =
  -        "org.apache.commons.logging.impl.Log4JLogger".intern();
  -
       // ----------------------------------------------------- Instance Variables
   
   
  @@ -177,6 +163,7 @@
        */
       private String logClassName;
   
  +
       /**
        * The one-argument constructor of the
        * {@link org.apache.commons.logging.Log}
  @@ -187,8 +174,6 @@
       protected Constructor logConstructor = null;
   
   
  -    protected LogFactory proxyFactory=null;
  -
       /**
        * The signature of the Constructor to be used.
        */
  @@ -220,10 +205,9 @@
        * @param name Name of the attribute to return
        */
       public Object getAttribute(String name) {
  -        if( proxyFactory != null )
  -            return proxyFactory.getAttribute( name );
   
  -        return attributes.get(name);
  +        return (attributes.get(name));
  +
       }
   
   
  @@ -233,8 +217,6 @@
        * length array is returned.
        */
       public String[] getAttributeNames() {
  -        if( proxyFactory != null )
  -            return proxyFactory.getAttributeNames();
   
           Vector names = new Vector();
           Enumeration keys = attributes.keys();
  @@ -245,7 +227,8 @@
           for (int i = 0; i < results.length; i++) {
               results[i] = (String) names.elementAt(i);
           }
  -        return results;
  +        return (results);
  +
       }
   
   
  @@ -259,10 +242,9 @@
        *  instance cannot be returned
        */
       public Log getInstance(Class clazz) throws LogConfigurationException {
  -        if( proxyFactory != null )
  -            return proxyFactory.getInstance(clazz);
   
  -        return getInstance(clazz.getName());
  +        return (getInstance(clazz.getName()));
  +
       }
   
   
  @@ -284,15 +266,14 @@
        *  instance cannot be returned
        */
       public Log getInstance(String name) throws LogConfigurationException {
  -        if( proxyFactory != null )
  -            return proxyFactory.getInstance(name);
   
           Log instance = (Log) instances.get(name);
           if (instance == null) {
               instance = newInstance(name);
               instances.put(name, instance);
           }
  -        return instance;
  +        return (instance);
  +
       }
   
   
  @@ -305,8 +286,6 @@
        * class loader would prevent garbage collection.
        */
       public void release() {
  -        if( proxyFactory != null )
  -            proxyFactory.release();
   
           instances.clear();
       }
  @@ -319,9 +298,9 @@
        * @param name Name of the attribute to remove
        */
       public void removeAttribute(String name) {
  -        if( proxyFactory != null )
  -            proxyFactory.removeAttribute(name);
  +
           attributes.remove(name);
  +
       }
   
   
  @@ -335,8 +314,6 @@
        *  to remove any setting for this attribute
        */
       public void setAttribute(String name, Object value) {
  -        if( proxyFactory != null )
  -            proxyFactory.setAttribute(name, value);
   
           if (value == null) {
               attributes.remove(name);
  @@ -351,8 +328,13 @@
   
   
   
  +    /**
  +     * Return the fully qualified Java classname of the {@link Log}
  +     * implementation we will be using.
  +     */
       protected String getLogClassName() {
  -        // Identify the Log implementation class we will be using
  +
  +        // Return the previously identified class name (if any)
           if (logClassName != null) {
               return logClassName;
           }
  @@ -380,19 +362,19 @@
           }
   
           if ((logClassName == null) && isLog4JAvailable()) {
  -            logClassName = LOG4JLOGIMPL;
  +            logClassName = "org.apache.commons.logging.impl.Log4JLogger";
           }
   
           if ((logClassName == null) && isJdk14Available()) {
  -            logClassName =
  -                "org.apache.commons.logging.impl.Jdk14Logger";
  +            logClassName = "org.apache.commons.logging.impl.Jdk14Logger";
           }
   
           if (logClassName == null) {
  -            logClassName = LOG_DEFAULT;
  +            logClassName = "org.apache.commons.logging.impl.SimpleLog";
           }
   
  -        return logClassName;
  +        return (logClassName);
  +
       }
   
   
  @@ -495,24 +477,6 @@
       }
   
   
  -    protected void guessConfig() {
  -        if (getLogClassName() == LOG4JLOGIMPL) {
  -            proxyFactory = null;
  -            try {
  -                Class proxyClass=
  -                    loadClass("org.apache.commons.logging.impl.Log4jFactory");
  -                if (proxyClass != null) {
  -                    proxyFactory = (LogFactory)proxyClass.newInstance();
  -                }
  -            } catch( Throwable t ) {
  -                ; // ignore
  -            }
  -        }
  -        // other logger specific initialization
  -        // ...
  -    }
  -
  -
       /**
        * Is <em>JDK 1.4 or later</em> logging available?
        */
  @@ -553,8 +517,8 @@
        *  be created
        */
       protected Log newInstance(String name) throws LogConfigurationException {
  -        Log instance = null;
   
  +        Log instance = null;
           try {
               Object params[] = new Object[1];
               params[0] = name;
  @@ -567,5 +531,8 @@
           } catch (Throwable t) {
               throw new LogConfigurationException(t);
           }
  +
       }
  +
  +
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message