Author: markt Date: Thu Dec 29 08:07:54 2011 New Revision: 1225467 URL: http://svn.apache.org/viewvc?rev=1225467&view=rev Log: Code clean-up. Run UCDetector over o.a.juli
Modified: tomcat/trunk/java/org/apache/juli/AsyncFileHandler.java tomcat/trunk/java/org/apache/juli/ClassLoaderLogManager.java tomcat/trunk/java/org/apache/juli/DateFormatCache.java tomcat/trunk/java/org/apache/juli/FileHandler.java tomcat/trunk/java/org/apache/juli/logging/DirectJDKLog.java tomcat/trunk/java/org/apache/juli/logging/LogConfigurationException.java tomcat/trunk/java/org/apache/juli/logging/LogFactory.java tomcat/trunk/java/org/apache/juli/logging/UserDataHelper.java Modified: tomcat/trunk/java/org/apache/juli/AsyncFileHandler.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/juli/AsyncFileHandler.java?rev=1225467&r1=1225466&r2=1225467&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/juli/AsyncFileHandler.java (original) +++ tomcat/trunk/java/org/apache/juli/AsyncFileHandler.java Thu Dec 29 08:07:54 2011 @@ -48,13 +48,17 @@ public class AsyncFileHandler extends Fi public static final int OVERFLOW_DROP_FLUSH = 3; public static final int OVERFLOW_DROP_CURRENT = 4; - public static final int OVERFLOW_DROP_TYPE = Integer.parseInt(System.getProperty("org.apache.juli.AsyncOverflowDropType","1")); - public static final int DEFAULT_MAX_RECORDS = Integer.parseInt(System.getProperty("org.apache.juli.AsyncMaxRecordCount","10000")); - public static final int LOGGER_SLEEP_TIME = Integer.parseInt(System.getProperty("org.apache.juli.AsyncLoggerPollInterval","1000")); + public static final int OVERFLOW_DROP_TYPE = Integer.parseInt( + System.getProperty("org.apache.juli.AsyncOverflowDropType","1")); + public static final int DEFAULT_MAX_RECORDS = Integer.parseInt( + System.getProperty("org.apache.juli.AsyncMaxRecordCount","10000")); + public static final int LOGGER_SLEEP_TIME = Integer.parseInt( + System.getProperty("org.apache.juli.AsyncLoggerPollInterval","1000")); - protected static LinkedBlockingDeque<LogEntry> queue = new LinkedBlockingDeque<LogEntry>(DEFAULT_MAX_RECORDS); + protected static final LinkedBlockingDeque<LogEntry> queue = + new LinkedBlockingDeque<LogEntry>(DEFAULT_MAX_RECORDS); - protected static LoggerThread logger = new LoggerThread(); + protected static final LoggerThread logger = new LoggerThread(); static { logger.start(); @@ -131,7 +135,7 @@ public class AsyncFileHandler extends Fi } protected static class LoggerThread extends Thread { - protected boolean run = true; + protected final boolean run = true; public LoggerThread() { this.setDaemon(true); this.setName("AsyncFileHandlerWriter-"+System.identityHashCode(this)); @@ -153,8 +157,8 @@ public class AsyncFileHandler extends Fi } protected static class LogEntry { - private LogRecord record; - private AsyncFileHandler handler; + private final LogRecord record; + private final AsyncFileHandler handler; public LogEntry(LogRecord record, AsyncFileHandler handler) { super(); this.record = record; Modified: tomcat/trunk/java/org/apache/juli/ClassLoaderLogManager.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/juli/ClassLoaderLogManager.java?rev=1225467&r1=1225466&r2=1225467&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/juli/ClassLoaderLogManager.java (original) +++ tomcat/trunk/java/org/apache/juli/ClassLoaderLogManager.java Thu Dec 29 08:07:54 2011 @@ -86,7 +86,7 @@ public class ClassLoaderLogManager exten * This prefix is used to allow using prefixes for the properties names * of handlers and their subcomponents. */ - protected ThreadLocal<String> prefix = new ThreadLocal<String>(); + protected final ThreadLocal<String> prefix = new ThreadLocal<String>(); /** Modified: tomcat/trunk/java/org/apache/juli/DateFormatCache.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/juli/DateFormatCache.java?rev=1225467&r1=1225466&r2=1225467&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/juli/DateFormatCache.java (original) +++ tomcat/trunk/java/org/apache/juli/DateFormatCache.java Thu Dec 29 08:07:54 2011 @@ -52,9 +52,9 @@ public class DateFormatCache { private final String format; /* Number of cached entries */ - private int cacheSize = 0; + private final int cacheSize; - private Cache cache; + private final Cache cache; /** * Replace the millisecond formatting character 'S' by Modified: tomcat/trunk/java/org/apache/juli/FileHandler.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/juli/FileHandler.java?rev=1225467&r1=1225466&r2=1225467&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/juli/FileHandler.java (original) +++ tomcat/trunk/java/org/apache/juli/FileHandler.java Thu Dec 29 08:07:54 2011 @@ -143,7 +143,7 @@ public class FileHandler /** * Lock used to control access to the writer. */ - protected ReadWriteLock writerLock = new ReentrantReadWriteLock(); + protected final ReadWriteLock writerLock = new ReentrantReadWriteLock(); /** Modified: tomcat/trunk/java/org/apache/juli/logging/DirectJDKLog.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/juli/logging/DirectJDKLog.java?rev=1225467&r1=1225466&r2=1225467&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/juli/logging/DirectJDKLog.java (original) +++ tomcat/trunk/java/org/apache/juli/logging/DirectJDKLog.java Thu Dec 29 08:07:54 2011 @@ -31,7 +31,7 @@ import java.util.logging.Logger; */ class DirectJDKLog implements Log { // no reason to hide this - but good reasons to not hide - public Logger logger; + public final Logger logger; /** Alternate config reader and console format */ @@ -200,11 +200,6 @@ class DirectJDKLog implements Log { } } - // for LogFactory - static void release() { - - } - static Log getInstance(String name) { return new DirectJDKLog( name ); } Modified: tomcat/trunk/java/org/apache/juli/logging/LogConfigurationException.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/juli/logging/LogConfigurationException.java?rev=1225467&r1=1225466&r2=1225467&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/juli/logging/LogConfigurationException.java (original) +++ tomcat/trunk/java/org/apache/juli/logging/LogConfigurationException.java Thu Dec 29 08:07:54 2011 @@ -69,28 +69,6 @@ public class LogConfigurationException e * @param cause The underlying cause */ public LogConfigurationException(String message, Throwable cause) { - - super(message); - this.cause = cause; // Two-argument version requires JDK 1.4 or later - + super(message, cause); } - - - /** - * The underlying cause of this exception. - */ - protected Throwable cause = null; - - - /** - * Return the underlying cause of this exception (if any). - */ - @Override - public Throwable getCause() { - - return (this.cause); - - } - - } Modified: tomcat/trunk/java/org/apache/juli/logging/LogFactory.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/juli/logging/LogFactory.java?rev=1225467&r1=1225466&r2=1225467&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/juli/logging/LogFactory.java (original) +++ tomcat/trunk/java/org/apache/juli/logging/LogFactory.java Thu Dec 29 08:07:54 2011 @@ -14,14 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.juli.logging; - -import java.util.Properties; import java.util.logging.LogManager; - /** * Modified LogFactory: removed all discovery, hardcode a specific implementation * If you like a different logging implementation - use either the discovery-based @@ -65,85 +61,18 @@ import java.util.logging.LogManager; * @author Richard A. Sitze * @version $Id$ */ -public /* abstract */ class LogFactory { - - // ----------------------------------------------------- Manifest Constants - - /** - * The name of the property used to identify the LogFactory implementation - * class name. - */ - public static final String FACTORY_PROPERTY = - "org.apache.commons.logging.LogFactory"; - - /** - * The fully qualified class name of the fallback <code>LogFactory</code> - * implementation class to use, if no other can be found. - */ - public static final String FACTORY_DEFAULT = - "org.apache.commons.logging.impl.LogFactoryImpl"; - - /** - * The name of the properties file to search for. - */ - public static final String FACTORY_PROPERTIES = - "commons-logging.properties"; - - /** - * <p>Setting this system property value allows the <code>Hashtable</code> used to store - * classloaders to be substituted by an alternative implementation. - * </p> - * <p> - * <strong>Note:</strong> <code>LogFactory</code> will print: - * <code><pre> - * [ERROR] LogFactory: Load of custom hashtable failed</em> - * </code></pre> - * to system error and then continue using a standard Hashtable. - * </p> - * <p> - * <strong>Usage:</strong> Set this property when Java is invoked - * and <code>LogFactory</code> will attempt to load a new instance - * of the given implementation class. - * For example, running the following ant scriptlet: - * <code><pre> - * <java classname="${test.runner}" fork="yes" failonerror="${test.failonerror}"> - * ... - * <sysproperty - * key="org.apache.commons.logging.LogFactory.HashtableImpl" - * value="org.apache.commons.logging.AltHashtable"/> - * </java> - * </pre></code> - * will mean that <code>LogFactory</code> will load an instance of - * <code>org.apache.commons.logging.AltHashtable</code>. - * </p> - * <p> - * A typical use case is to allow a custom - * Hashtable implementation using weak references to be substituted. - * This will allow classloaders to be garbage collected without - * the need to release them (on 1.3+ JVMs only, of course ;) - * </p> - */ - public static final String HASHTABLE_IMPLEMENTATION_PROPERTY = - "org.apache.commons.logging.LogFactory.HashtableImpl"; - - private static LogFactory singleton=new LogFactory(); - - Properties logConfig; +public class LogFactory { - // ----------------------------------------------------------- Constructors + private static final LogFactory singleton = new LogFactory(); /** * Protected constructor that is not available for public use. */ private LogFactory() { - logConfig=new Properties(); } - // hook for syserr logger - class level - void setLogConfig( Properties p ) { - this.logConfig=p; - } + // --------------------------------------------------------- Public Methods // only those 2 methods need to change to use a different direct logger. @@ -172,63 +101,6 @@ public /* abstract */ class LogFactory { /** - * Release any internal references to previously created {@link Log} - * instances returned by this factory. This is useful in 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. - */ - public void release() { - DirectJDKLog.release(); - } - - /** - * Return the configuration attribute with the specified name (if any), - * or <code>null</code> if there is no such attribute. - * - * @param name Name of the attribute to return - */ - public Object getAttribute(String name) { - return logConfig.get(name); - } - - - /** - * Return an array containing the names of all currently defined - * configuration attributes. If there are no such attributes, a zero - * length array is returned. - */ - public String[] getAttributeNames() { - String result[] = new String[logConfig.size()]; - return logConfig.keySet().toArray(result); - } - - /** - * Remove any configuration attribute associated with the specified name. - * If there is no such attribute, no action is taken. - * - * @param name Name of the attribute to remove - */ - public void removeAttribute(String name) { - logConfig.remove(name); - } - - - /** - * Set the configuration attribute with the specified name. Calling - * this with a <code>null</code> value is equivalent to calling - * <code>removeAttribute(name)</code>. - * - * @param name Name of the attribute to set - * @param value Value of the attribute to set, or <code>null</code> - * to remove any setting for this attribute - */ - public void setAttribute(String name, Object value) { - logConfig.put(name, value); - } - - - /** * Convenience method to derive a name from the specified class and * call <code>getInstance(String)</code> with it. * @@ -330,36 +202,4 @@ public /* abstract */ class LogFactory { LogManager.getLogManager().reset(); } } - - - /** - * Release any internal references to previously created {@link LogFactory} - * instances, after calling the instance method <code>release()</code> on - * each of them. This is useful in 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. - */ - public static void releaseAll() { - singleton.release(); - } - - /** - * Returns a string that uniquely identifies the specified object, including - * its class. - * <p> - * The returned string is of form "classname@hashcode", ie is the same as - * the return value of the Object.toString() method, but works even when - * the specified object's class has overridden the toString method. - * - * @param o may be null. - * @return a string of form classname@hashcode, or "null" if param o is null. - */ - public static String objectId(Object o) { - if (o == null) { - return "null"; - } else { - return o.getClass().getName() + "@" + System.identityHashCode(o); - } - } } Modified: tomcat/trunk/java/org/apache/juli/logging/UserDataHelper.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/juli/logging/UserDataHelper.java?rev=1225467&r1=1225466&r2=1225467&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/juli/logging/UserDataHelper.java (original) +++ tomcat/trunk/java/org/apache/juli/logging/UserDataHelper.java Thu Dec 29 08:07:54 2011 @@ -38,12 +38,12 @@ public class UserDataHelper { private final Log log; - private Config config; + private final Config config; // A value of 0 is equivalent to using INFO_ALL // A negative value will trigger infinite suppression // The value is milliseconds - private long suppressionTime; + private final long suppressionTime; private volatile long lastInfoTime = 0; @@ -51,16 +51,17 @@ public class UserDataHelper { public UserDataHelper(Log log) { this.log = log; + Config tempConfig; String configString = System.getProperty( "org.apache.juli.logging.UserDataHelper.CONFIG"); if (configString == null) { - config = Config.INFO_THEN_DEBUG; + tempConfig = Config.INFO_THEN_DEBUG; } else { try { - config = Config.valueOf(configString); + tempConfig = Config.valueOf(configString); } catch (IllegalArgumentException iae) { // Ignore - use default - config = Config.INFO_THEN_DEBUG; + tempConfig = Config.INFO_THEN_DEBUG; } } @@ -70,8 +71,10 @@ public class UserDataHelper { 60 * 60 * 24).intValue() * 1000L; if (suppressionTime == 0) { - config = Config.INFO_ALL; + tempConfig = Config.INFO_ALL; } + + config = tempConfig; } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org