commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skitch...@apache.org
Subject svn commit: r170512 - /jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
Date Tue, 17 May 2005 04:27:58 GMT
Author: skitching
Date: Mon May 16 21:27:57 2005
New Revision: 170512

URL: http://svn.apache.org/viewcvs?rev=170512&view=rev
Log:
Just moved some code out of method getLogConstructor into its own
method reportInvalidLogAdapter to make code easier to read (esp.
as I'm going to add more code to this method later).

Modified:
    jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java

Modified: jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java?rev=170512&r1=170511&r2=170512&view=diff
==============================================================================
--- jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
(original)
+++ jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
Mon May 16 21:27:57 2005
@@ -382,19 +382,8 @@
                     ("No suitable Log implementation for " + logClassName);
             }
             if (!logInterface.isAssignableFrom(logClass)) {
-                Class interfaces[] = logClass.getInterfaces();
-                for (int i = 0; i < interfaces.length; i++) {
-                    if (LOG_INTERFACE.equals(interfaces[i].getName())) {
-                        throw new LogConfigurationException
-                            ("Invalid class loader hierarchy.  " +
-                             "You have more than one version of '" +
-                             LOG_INTERFACE + "' visible, which is " +
-                             "not allowed.");
-                    }
-                }
-                throw new LogConfigurationException
-                    ("Class " + logClassName + " does not implement '" +
-                     LOG_INTERFACE + "'.");
+                LogConfigurationException ex = reportInvalidLogAdapter(logInterface, logClass);
+                throw ex;
             }
         } catch (Throwable t) {
             throw new LogConfigurationException(t);
@@ -419,6 +408,32 @@
         }
     }
 
+    /**
+     * Report a problem loading the log adapter, then <i>always</i> throw
+     * a LogConfigurationException.
+     *  
+     * @param logInterface
+     * @param logClass
+     */
+    private LogConfigurationException reportInvalidLogAdapter(
+            Class logInterface, Class logClass) { 
+
+        Class interfaces[] = logClass.getInterfaces();
+        for (int i = 0; i < interfaces.length; i++) {
+            if (LOG_INTERFACE.equals(interfaces[i].getName())) {
+                throw new LogConfigurationException
+                    ("Invalid class loader hierarchy.  " +
+                     "You have more than one version of '" +
+                     LOG_INTERFACE + "' visible, which is " +
+                     "not allowed.");
+            }
+        }
+            
+        return new LogConfigurationException
+            ("Class " + logClassName + " does not implement '" +
+                    LOG_INTERFACE + "'.");
+    }
+    
     /**
      * Gets the context classloader.
      * This method is a workaround for a java 1.2 compiler bug.



---------------------------------------------------------------------
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