commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skitch...@apache.org
Subject svn commit: r383786 - in /jakarta/commons/proper/logging/contrib/simon/jcl2: core-dynamic/java/org/apache/commons/logging/ core/java/org/apache/commons/logging/ simple/java/org/apache/commons/logging/simple/
Date Tue, 07 Mar 2006 05:15:30 GMT
Author: skitching
Date: Mon Mar  6 21:15:27 2006
New Revision: 383786

URL: http://svn.apache.org/viewcvs?rev=383786&view=rev
Log:
Checkstyle-related fixes.

Modified:
    jakarta/commons/proper/logging/contrib/simon/jcl2/core-dynamic/java/org/apache/commons/logging/LogFactoryDynamic.java
    jakarta/commons/proper/logging/contrib/simon/jcl2/core/java/org/apache/commons/logging/LogConfigurationException.java
    jakarta/commons/proper/logging/contrib/simon/jcl2/core/java/org/apache/commons/logging/Utils.java
    jakarta/commons/proper/logging/contrib/simon/jcl2/simple/java/org/apache/commons/logging/simple/SimpleLog.java
    jakarta/commons/proper/logging/contrib/simon/jcl2/simple/java/org/apache/commons/logging/simple/SimpleLogHandler.java

Modified: jakarta/commons/proper/logging/contrib/simon/jcl2/core-dynamic/java/org/apache/commons/logging/LogFactoryDynamic.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/contrib/simon/jcl2/core-dynamic/java/org/apache/commons/logging/LogFactoryDynamic.java?rev=383786&r1=383785&r2=383786&view=diff
==============================================================================
--- jakarta/commons/proper/logging/contrib/simon/jcl2/core-dynamic/java/org/apache/commons/logging/LogFactoryDynamic.java
(original)
+++ jakarta/commons/proper/logging/contrib/simon/jcl2/core-dynamic/java/org/apache/commons/logging/LogFactoryDynamic.java
Mon Mar  6 21:15:27 2006
@@ -69,7 +69,7 @@
     }
     
     private synchronized LogHandler getHandler() {
-        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+        final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
         LogHandler handler = (LogHandler) handlers.get(tccl);
         if (handler == null) {
             handler = (LogHandler) Utils.createServiceInstance(LogHandler.class, tccl);

Modified: jakarta/commons/proper/logging/contrib/simon/jcl2/core/java/org/apache/commons/logging/LogConfigurationException.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/contrib/simon/jcl2/core/java/org/apache/commons/logging/LogConfigurationException.java?rev=383786&r1=383785&r2=383786&view=diff
==============================================================================
--- jakarta/commons/proper/logging/contrib/simon/jcl2/core/java/org/apache/commons/logging/LogConfigurationException.java
(original)
+++ jakarta/commons/proper/logging/contrib/simon/jcl2/core/java/org/apache/commons/logging/LogConfigurationException.java
Mon Mar  6 21:15:27 2006
@@ -27,7 +27,7 @@
     /**
      * The underlying cause of this exception.
      */
-    protected Throwable cause = null;
+    protected Throwable cause;
 
     /**
      * Construct a new exception with <code>null</code> as its detail message.

Modified: jakarta/commons/proper/logging/contrib/simon/jcl2/core/java/org/apache/commons/logging/Utils.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/contrib/simon/jcl2/core/java/org/apache/commons/logging/Utils.java?rev=383786&r1=383785&r2=383786&view=diff
==============================================================================
--- jakarta/commons/proper/logging/contrib/simon/jcl2/core/java/org/apache/commons/logging/Utils.java
(original)
+++ jakarta/commons/proper/logging/contrib/simon/jcl2/core/java/org/apache/commons/logging/Utils.java
Mon Mar  6 21:15:27 2006
@@ -77,8 +77,8 @@
     public static Object createServiceInstance(Class baseClass, ClassLoader baseLoader) 
     throws LogConfigurationException {
 
-        String serviceName = baseClass.getName();
-        String serviceFileName = "META-INF/services/" + serviceName;
+        final String serviceName = baseClass.getName();
+        final String serviceFileName = "META-INF/services/" + serviceName;
         InputStream is;
         
         if (baseLoader == null) {
@@ -117,7 +117,7 @@
         }
         
         try {
-            Class serviceClass = Class.forName(serviceClassName);
+            final Class serviceClass = Class.forName(serviceClassName);
             if (!(baseClass.isAssignableFrom(serviceClass))) {
                 throw new LogConfigurationException(
                     "Class '" + serviceClassName + "' does not implement "
@@ -137,12 +137,13 @@
     }
     
     private static String readServiceClassName(InputStream is) throws IOException {
-        InputStreamReader isr = new InputStreamReader(is);
-        BufferedReader reader = new BufferedReader(isr);
+        final InputStreamReader isr = new InputStreamReader(is);
+        final BufferedReader reader = new BufferedReader(isr);
         for(;;) {
-            String s = reader.readLine();
-            if (s == null)
+            final String s = reader.readLine();
+            if (s == null) {
                 return null;
+            }
             s.trim();
             if (!s.startsWith("#")) {
                 return s;

Modified: jakarta/commons/proper/logging/contrib/simon/jcl2/simple/java/org/apache/commons/logging/simple/SimpleLog.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/contrib/simon/jcl2/simple/java/org/apache/commons/logging/simple/SimpleLog.java?rev=383786&r1=383785&r2=383786&view=diff
==============================================================================
--- jakarta/commons/proper/logging/contrib/simon/jcl2/simple/java/org/apache/commons/logging/simple/SimpleLog.java
(original)
+++ jakarta/commons/proper/logging/contrib/simon/jcl2/simple/java/org/apache/commons/logging/simple/SimpleLog.java
Mon Mar  6 21:15:27 2006
@@ -30,16 +30,18 @@
 
     // ------------------------------------------------------------- Attributes
 
+    private static final int STACKTRACE_BUF_SIZE = 1024;
+
     /** The name of this simple log instance */
-    protected String category = null;
+    protected String category;
 
     /** The current log level */
     protected int threshold;
 
     /** The name to display as the source of messages; typically same as logCategory.*/
-    private String displayName = null;
+    private String displayName;
     
-    private DateFormat dateFormatter = null;
+    private DateFormat dateFormatter;
 
     // ------------------------------------------------------------- Constructor
 
@@ -66,7 +68,7 @@
      */
     private void log(int level, Object message, Throwable t) {
         // Use a string buffer for better performance
-        StringBuffer buf = new StringBuffer();
+        final StringBuffer buf = new StringBuffer();
 
         // Append date-time if so configured
         if(dateFormatter != null) {
@@ -82,6 +84,7 @@
             case SimpleLogHandler.LOG_LEVEL_WARN:  buf.append("[WARN] ");  break;
             case SimpleLogHandler.LOG_LEVEL_ERROR: buf.append("[ERROR] "); break;
             case SimpleLogHandler.LOG_LEVEL_FATAL: buf.append("[FATAL] "); break;
+            default: break;
         }
 
         // Append the name of the log instance if so configured
@@ -99,8 +102,8 @@
             buf.append(t.toString());
             buf.append(">");
 
-            java.io.StringWriter sw= new java.io.StringWriter(1024);
-            java.io.PrintWriter pw= new java.io.PrintWriter(sw);
+            final java.io.StringWriter sw= new java.io.StringWriter(STACKTRACE_BUF_SIZE);
+            final java.io.PrintWriter pw= new java.io.PrintWriter(sw);
             t.printStackTrace(pw);
             pw.close();
             buf.append(sw.toString());
@@ -118,7 +121,7 @@
     private boolean isLevelEnabled(int logLevel) {
         // log levels are numerically ordered so can use simple numeric
         // comparison
-        return (logLevel >= threshold);
+        return logLevel >= threshold;
     }
 
 

Modified: jakarta/commons/proper/logging/contrib/simon/jcl2/simple/java/org/apache/commons/logging/simple/SimpleLogHandler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/contrib/simon/jcl2/simple/java/org/apache/commons/logging/simple/SimpleLogHandler.java?rev=383786&r1=383785&r2=383786&view=diff
==============================================================================
--- jakarta/commons/proper/logging/contrib/simon/jcl2/simple/java/org/apache/commons/logging/simple/SimpleLogHandler.java
(original)
+++ jakarta/commons/proper/logging/contrib/simon/jcl2/simple/java/org/apache/commons/logging/simple/SimpleLogHandler.java
Mon Mar  6 21:15:27 2006
@@ -76,8 +76,8 @@
     static final int LOG_LEVEL_WARN   = 4;
     static final int LOG_LEVEL_ERROR  = 5;
     static final int LOG_LEVEL_FATAL  = 6;
-    static final int LOG_LEVEL_ALL    = (LOG_LEVEL_TRACE - 1);
-    static final int LOG_LEVEL_OFF    = (LOG_LEVEL_FATAL + 1);
+    static final int LOG_LEVEL_ALL    = LOG_LEVEL_TRACE - 1;
+    static final int LOG_LEVEL_OFF    = LOG_LEVEL_FATAL + 1;
 
     // ----------- Static members ----------------------------
 
@@ -132,8 +132,9 @@
     }
 
     public synchronized Log getLog(String category) {
-        if (logs == null)
+        if (logs == null) {
             init();
+        }
 
         Log log = (Log) logs.get(category);
         if (log == null) {
@@ -164,19 +165,23 @@
         // jarfile containing this class just needs to be deployed at the
         // webapp level to resolve that. Using the TCCL here would introduce
         // significant complexity that is not desirable in most cases.
-        InputStream in = SimpleLogHandler.class.getResourceAsStream("simplelog.properties");
+        final InputStream in = SimpleLogHandler.class.getResourceAsStream(
+                "simplelog.properties");
         if(null != in) {
             try {
                 simpleLogProps.load(in);
                 in.close();
             } catch(java.io.IOException e) {
-                // ignored
+                logDiagnostics("Unable to load file simplelog.properties");
             }
         }
 
-        showLogName = getBooleanProperty( systemPrefix + "showlogname", simpleLogProps, showLogName);
-        showShortName = getBooleanProperty( systemPrefix + "showShortLogname", simpleLogProps,
showShortName);
-        showDateTime = getBooleanProperty( systemPrefix + "showdatetime", simpleLogProps,
showDateTime);
+        showLogName = getBooleanProperty(
+                systemPrefix + "showlogname", simpleLogProps, showLogName);
+        showShortName = getBooleanProperty(
+                systemPrefix + "showShortLogname", simpleLogProps, showShortName);
+        showDateTime = getBooleanProperty(
+                systemPrefix + "showdatetime", simpleLogProps, showDateTime);
 
         if(showDateTime) {
             dateTimeFormat = getStringProperty(systemPrefix + "dateTimeFormat",
@@ -265,7 +270,7 @@
      * provided default value.
      */
     private static String getStringProperty(String name, Properties dfltProps, String dflt)
{
-        String prop = getStringProperty(name, dfltProps);
+        final String prop = getStringProperty(name, dfltProps);
         return (prop == null) ? dflt : prop;
     }
 
@@ -274,7 +279,7 @@
      * provided default value.
      */
     private static boolean getBooleanProperty(String name, Properties dfltProps, boolean
dflt) {
-        String prop = getStringProperty(name, dfltProps);
+        final String prop = getStringProperty(name, dfltProps);
         return (prop == null) ? dflt : "true".equalsIgnoreCase(prop);
     }
 



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