From 396bb04b863b9cd74ef3fc13cfa8128f5cfd6690 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 24 Aug 2011 10:22:37 -0700 Subject: [PATCH] 293739 - Deprecate static Jetty Log usage in favor of named logs + Finished conversion of jetty-util --- .../main/java/org/eclipse/jetty/util/IO.java | 21 +++++++++------- .../java/org/eclipse/jetty/util/LazyList.java | 1 + .../java/org/eclipse/jetty/util/Scanner.java | 25 ++++++++++--------- .../org/eclipse/jetty/util/StringUtil.java | 7 ++++-- .../java/org/eclipse/jetty/util/TypeUtil.java | 8 +++--- .../org/eclipse/jetty/util/ajax/JSON.java | 4 ++- .../jetty/util/ajax/JSONDateConvertor.java | 5 ++-- .../jetty/util/ajax/JSONEnumConvertor.java | 4 ++- .../jetty/util/ajax/JSONPojoConvertor.java | 13 +++++----- .../util/component/AbstractLifeCycle.java | 14 +++++------ .../util/component/AggregateLifeCycle.java | 8 +++--- .../jetty/util/component/Container.java | 10 +++++--- .../jetty/util/component/FileDestroyable.java | 4 ++- .../jetty/util/resource/FileResource.java | 14 ++++++----- .../jetty/util/resource/JarFileResource.java | 10 +++++--- .../jetty/util/resource/JarResource.java | 12 +++++---- .../eclipse/jetty/util/resource/Resource.java | 10 +++++--- .../jetty/util/resource/URLResource.java | 10 +++++--- .../util/security/CertificateValidator.java | 8 +++--- .../jetty/util/thread/ExecutorThreadPool.java | 4 ++- .../jetty/util/thread/QueuedThreadPool.java | 17 +++++++------ .../jetty/util/thread/ShutdownThread.java | 15 ++++++----- .../eclipse/jetty/util/thread/Timeout.java | 4 ++- 23 files changed, 136 insertions(+), 92 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/IO.java b/jetty-util/src/main/java/org/eclipse/jetty/util/IO.java index c3d94d3bd65..f6107d911a6 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/IO.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/IO.java @@ -26,6 +26,7 @@ import java.io.StringWriter; import java.io.Writer; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.thread.QueuedThreadPool; /* ======================================================================== */ @@ -35,6 +36,8 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool; */ public class IO { + private static final Logger LOG = Log.getLogger(IO.class); + /* ------------------------------------------------------------------- */ public final static String CRLF = "\015\012"; @@ -53,7 +56,7 @@ public class IO static { try{__pool.start();} - catch(Exception e){Log.warn(e); System.exit(1);} + catch(Exception e){LOG.warn(e); System.exit(1);} } } @@ -94,7 +97,7 @@ public class IO } catch(IOException e) { - Log.ignore(e); + LOG.ignore(e); try{ if (out!=null) out.close(); @@ -103,7 +106,7 @@ public class IO } catch(IOException e2) { - Log.ignore(e2); + LOG.ignore(e2); } } } @@ -122,7 +125,7 @@ public class IO } catch(Exception e) { - Log.warn(e); + LOG.warn(e); } } @@ -149,7 +152,7 @@ public class IO } catch(Exception e) { - Log.warn(e); + LOG.warn(e); } } @@ -364,7 +367,7 @@ public class IO } catch (IOException e) { - Log.ignore(e); + LOG.ignore(e); } } @@ -381,7 +384,7 @@ public class IO reader.close(); } catch (IOException e) { - Log.ignore(e); + LOG.ignore(e); } } @@ -398,7 +401,7 @@ public class IO writer.close(); } catch (IOException e) { - Log.ignore(e); + LOG.ignore(e); } } @@ -426,7 +429,7 @@ public class IO } catch (IOException e) { - Log.ignore(e); + LOG.ignore(e); } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/LazyList.java b/jetty-util/src/main/java/org/eclipse/jetty/util/LazyList.java index a8d823154bc..9b3c72353c5 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/LazyList.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/LazyList.java @@ -12,6 +12,7 @@ // ======================================================================== package org.eclipse.jetty.util; + import java.io.Serializable; import java.lang.reflect.Array; import java.util.ArrayList; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Scanner.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Scanner.java index 211aabe1016..7acdb243476 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Scanner.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Scanner.java @@ -31,6 +31,7 @@ import java.util.TimerTask; import org.eclipse.jetty.util.component.AbstractLifeCycle; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /** @@ -42,6 +43,7 @@ import org.eclipse.jetty.util.log.Log; */ public class Scanner extends AbstractLifeCycle { + private static final Logger LOG = Log.getLogger(Scanner.class); private static int __scannerId=0; private int _scanInterval; private int _scanCount = 0; @@ -315,6 +317,7 @@ public class Scanner extends AbstractLifeCycle /** * Start the scanning action. */ + @Override public synchronized void doStart() { if (_running) @@ -370,6 +373,7 @@ public class Scanner extends AbstractLifeCycle /** * Stop the scanning. */ + @Override public synchronized void doStop() { if (_running) @@ -405,11 +409,11 @@ public class Scanner extends AbstractLifeCycle } catch (Exception e) { - Log.warn(e); + LOG.warn(e); } catch (Error e) { - Log.warn(e); + LOG.warn(e); } } } @@ -435,7 +439,7 @@ public class Scanner extends AbstractLifeCycle } catch (IOException e) { - Log.warn("Error scanning files.", e); + LOG.warn("Error scanning files.", e); } } } @@ -501,8 +505,8 @@ public class Scanner extends AbstractLifeCycle } } - if (Log.isDebugEnabled()) - Log.debug("scanned "+_scanDirs+": "+_notifications); + if (LOG.isDebugEnabled()) + LOG.debug("scanned "+_scanDirs+": "+_notifications); // Process notifications // Only process notifications that are for stable files (ie same in old and current scan). @@ -575,14 +579,13 @@ public class Scanner extends AbstractLifeCycle } catch (IOException e) { - Log.warn("Error scanning watched files", e); + LOG.warn("Error scanning watched files", e); } } private void warn(Object listener,String filename,Throwable th) { - Log.warn(th); - Log.warn(listener+" failed on '"+filename); + LOG.warn(listener+" failed on '"+filename, th); } /** @@ -703,8 +706,7 @@ public class Scanner extends AbstractLifeCycle } catch (Exception e) { - Log.warn(e); - Log.warn(listener + " failed on scan start for cycle " + cycle); + LOG.warn(listener + " failed on scan start for cycle " + cycle, e); } } } @@ -725,8 +727,7 @@ public class Scanner extends AbstractLifeCycle } catch (Exception e) { - Log.warn(e); - Log.warn(listener + " failed on scan end for cycle " + cycle); + LOG.warn(listener + " failed on scan end for cycle " + cycle, e); } } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java b/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java index 3effaa317a3..06976d45832 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java @@ -17,6 +17,7 @@ import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; // ==================================================================== /** Fast String Utilities. @@ -30,6 +31,8 @@ import org.eclipse.jetty.util.log.Log; */ public class StringUtil { + private static final Logger LOG = Log.getLogger(StringUtil.class); + public static final String ALL_INTERFACES="0.0.0.0"; public static final String CRLF="\015\012"; public static final String __LINE_SEPARATOR= @@ -372,7 +375,7 @@ public class StringUtil } catch(Exception e) { - Log.warn(e); + LOG.warn(e); return s.getBytes(); } } @@ -385,7 +388,7 @@ public class StringUtil } catch(Exception e) { - Log.warn(e); + LOG.warn(e); return s.getBytes(); } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/TypeUtil.java b/jetty-util/src/main/java/org/eclipse/jetty/util/TypeUtil.java index 38f9b071a13..c304427d74f 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/TypeUtil.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/TypeUtil.java @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.List; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /* ------------------------------------------------------------ */ @@ -38,6 +39,7 @@ import org.eclipse.jetty.util.log.Log; */ public class TypeUtil { + private static final Logger LOG = Log.getLogger(TypeUtil.class); public static int CR = '\015'; public static int LF = '\012'; @@ -510,7 +512,7 @@ public class TypeUtil } catch(Exception e) { - Log.ignore(e); + LOG.ignore(e); } return null; } @@ -537,11 +539,11 @@ public class TypeUtil } catch (IllegalAccessException e) { - Log.ignore(e); + LOG.ignore(e); } catch (IllegalArgumentException e) { - Log.ignore(e); + LOG.ignore(e); } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSON.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSON.java index 7c9a15371c8..360a836d3d5 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSON.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSON.java @@ -30,6 +30,7 @@ import org.eclipse.jetty.util.Loader; import org.eclipse.jetty.util.QuotedStringTokenizer; import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /** * JSON Parser and Generator. @@ -85,6 +86,7 @@ import org.eclipse.jetty.util.log.Log; */ public class JSON { + private static final Logger LOG = Log.getLogger(JSON.class); public final static JSON DEFAULT = new JSON(); private Map _convertors = new ConcurrentHashMap(); @@ -1636,7 +1638,7 @@ public class JSON */ public Literal(String json) { - if (Log.isDebugEnabled()) + if (LOG.isDebugEnabled()) // TODO: Make this a configurable option on JSON instead! parse(json); _json = json; } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSONDateConvertor.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSONDateConvertor.java index 6a36becc5cf..d66558c9a66 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSONDateConvertor.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSONDateConvertor.java @@ -23,6 +23,7 @@ import java.util.TimeZone; import org.eclipse.jetty.util.DateCache; import org.eclipse.jetty.util.ajax.JSON.Output; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /* ------------------------------------------------------------ */ /** @@ -33,6 +34,7 @@ import org.eclipse.jetty.util.log.Log; */ public class JSONDateConvertor implements JSON.Convertor { + private static final Logger LOG = Log.getLogger(JSONDateConvertor.class); private boolean _fromJSON; DateCache _dateCache; SimpleDateFormat _format; @@ -78,7 +80,7 @@ public class JSONDateConvertor implements JSON.Convertor } catch(Exception e) { - Log.warn(e); + LOG.warn(e); } return null; } @@ -96,5 +98,4 @@ public class JSONDateConvertor implements JSON.Convertor out.add(date); } } - } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSONEnumConvertor.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSONEnumConvertor.java index 17e91f5671c..effea430a5d 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSONEnumConvertor.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSONEnumConvertor.java @@ -19,6 +19,7 @@ import java.util.Map; import org.eclipse.jetty.util.Loader; import org.eclipse.jetty.util.ajax.JSON.Output; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /* ------------------------------------------------------------ */ /** @@ -31,6 +32,7 @@ import org.eclipse.jetty.util.log.Log; */ public class JSONEnumConvertor implements JSON.Convertor { + private static final Logger LOG = Log.getLogger(JSONEnumConvertor.class); private boolean _fromJSON; private Method _valueOf; { @@ -66,7 +68,7 @@ public class JSONEnumConvertor implements JSON.Convertor } catch(Exception e) { - Log.warn(e); + LOG.warn(e); } return null; } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSONPojoConvertor.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSONPojoConvertor.java index 6683eabe60d..781618d1c9d 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSONPojoConvertor.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSONPojoConvertor.java @@ -26,7 +26,7 @@ import java.util.Set; import org.eclipse.jetty.util.ajax.JSON.Output; import org.eclipse.jetty.util.log.Log; -/* ------------------------------------------------------------ */ +import org.eclipse.jetty.util.log.Logger; /** * Converts POJOs to JSON and vice versa. * The key difference: @@ -37,6 +37,7 @@ import org.eclipse.jetty.util.log.Log; */ public class JSONPojoConvertor implements JSON.Convertor { + private static final Logger LOG = Log.getLogger(JSONPojoConvertor.class); public static final Object[] GETTER_ARG = new Object[]{}, NULL_ARG = new Object[]{null}; private static final Map, NumberType> __numberTypes = new HashMap, NumberType>(); @@ -204,7 +205,7 @@ public class JSONPojoConvertor implements JSON.Convertor catch(Exception e) { // TODO throw exception? - Log.warn(_pojoClass.getName()+"#"+setter.getPropertyName()+" not set from "+ + LOG.warn(_pojoClass.getName()+"#"+setter.getPropertyName()+" not set from "+ (entry.getValue().getClass().getName())+"="+entry.getValue().toString()); log(e); } @@ -227,7 +228,7 @@ public class JSONPojoConvertor implements JSON.Convertor catch(Exception e) { // TODO throw exception? - Log.warn("{} property '{}' excluded. (errors)", _pojoClass.getName(), + LOG.warn("{} property '{}' excluded. (errors)", _pojoClass.getName(), entry.getKey()); log(e); } @@ -237,7 +238,7 @@ public class JSONPojoConvertor implements JSON.Convertor /* ------------------------------------------------------------ */ protected void log(Throwable t) { - Log.ignore(t); + LOG.ignore(t); } /* ------------------------------------------------------------ */ @@ -333,7 +334,7 @@ public class JSONPojoConvertor implements JSON.Convertor catch(Exception e) { // unusual array with multiple types - Log.ignore(e); + LOG.ignore(e); _setter.invoke(obj, new Object[]{value}); return; } @@ -351,7 +352,7 @@ public class JSONPojoConvertor implements JSON.Convertor catch(Exception e) { // unusual array with multiple types - Log.ignore(e); + LOG.ignore(e); _setter.invoke(obj, new Object[]{value}); return; } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java index 4cae9a32798..c6d1f7b0be9 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java @@ -15,8 +15,8 @@ package org.eclipse.jetty.util.component; import java.util.concurrent.CopyOnWriteArrayList; -import org.eclipse.jetty.util.LazyList; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /** * Basic implementation of the life cycle interface for components. @@ -25,6 +25,7 @@ import org.eclipse.jetty.util.log.Log; */ public abstract class AbstractLifeCycle implements LifeCycle { + private static final Logger LOG = Log.getLogger(AbstractLifeCycle.class); public static final String STOPPED="STOPPED"; public static final String FAILED="FAILED"; public static final String STARTING="STARTING"; @@ -163,14 +164,14 @@ public abstract class AbstractLifeCycle implements LifeCycle private void setStarted() { _state = __STARTED; - Log.debug(STARTED+" {}",this); + LOG.debug(STARTED+" {}",this); for (Listener listener : _listeners) listener.lifeCycleStarted(this); } private void setStarting() { - Log.debug("starting {}",this); + LOG.debug("starting {}",this); _state = __STARTING; for (Listener listener : _listeners) listener.lifeCycleStarting(this); @@ -178,7 +179,7 @@ public abstract class AbstractLifeCycle implements LifeCycle private void setStopping() { - Log.debug("stopping {}",this); + LOG.debug("stopping {}",this); _state = __STOPPING; for (Listener listener : _listeners) listener.lifeCycleStopping(this); @@ -187,7 +188,7 @@ public abstract class AbstractLifeCycle implements LifeCycle private void setStopped() { _state = __STOPPED; - Log.debug(STOPPED+" {}",this); + LOG.debug(STOPPED+" {}",this); for (Listener listener : _listeners) listener.lifeCycleStopped(this); } @@ -195,8 +196,7 @@ public abstract class AbstractLifeCycle implements LifeCycle private void setFailed(Throwable th) { _state = __FAILED; - Log.warn(FAILED+" " + this+": "+th); - Log.debug(th); + LOG.warn(FAILED+" " + this+": "+th,th); for (Listener listener : _listeners) listener.lifeCycleFailure(this,th); } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/AggregateLifeCycle.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/AggregateLifeCycle.java index b5099f8b3d7..efc6998af3d 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/AggregateLifeCycle.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/AggregateLifeCycle.java @@ -9,6 +9,7 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /** * An AggregateLifeCycle is an AbstractLifeCycle with a collection of dependent beans. @@ -18,6 +19,7 @@ import org.eclipse.jetty.util.log.Log; */ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable, Dumpable { + private static final Logger LOG = Log.getLogger(AggregateLifeCycle.class); private final Queue _dependentBeans=new ConcurrentLinkedQueue(); public void destroy() @@ -139,7 +141,7 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable } } if (count>1) - Log.debug("getBean({}) 1 of {}",clazz.getName(),count); + LOG.debug("getBean({}) 1 of {}",clazz.getName(),count); return t; } @@ -173,7 +175,7 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable } catch (IOException e) { - Log.warn(e); + LOG.warn(e); } } @@ -193,7 +195,7 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable } catch (IOException e) { - Log.warn(e); + LOG.warn(e); } return b.toString(); } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/Container.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/Container.java index 0cec73d2463..267eb5f79f6 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/Container.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/Container.java @@ -18,6 +18,7 @@ import java.util.concurrent.CopyOnWriteArrayList; import org.eclipse.jetty.util.LazyList; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /* ------------------------------------------------------------ */ /** Container. @@ -39,6 +40,7 @@ import org.eclipse.jetty.util.log.Log; */ public class Container { + private static final Logger LOG = Log.getLogger(Container.class); private final CopyOnWriteArrayList _listeners=new CopyOnWriteArrayList(); public void addEventListener(Container.Listener listener) @@ -195,8 +197,8 @@ public class Container */ private void add(Object parent, Object child, String relationship) { - if (Log.isDebugEnabled()) - Log.debug("Container "+parent+" + "+child+" as "+relationship); + if (LOG.isDebugEnabled()) + LOG.debug("Container "+parent+" + "+child+" as "+relationship); if (_listeners!=null) { Relationship event=new Relationship(this,parent,child,relationship); @@ -213,8 +215,8 @@ public class Container */ private void remove(Object parent, Object child, String relationship) { - if (Log.isDebugEnabled()) - Log.debug("Container "+parent+" - "+child+" as "+relationship); + if (LOG.isDebugEnabled()) + LOG.debug("Container "+parent+" - "+child+" as "+relationship); if (_listeners!=null) { Relationship event=new Relationship(this,parent,child,relationship); diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/FileDestroyable.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/FileDestroyable.java index 740007ab456..4f5b7b1d0a8 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/FileDestroyable.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/FileDestroyable.java @@ -8,10 +8,12 @@ import java.util.List; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.resource.Resource; public class FileDestroyable implements Destroyable { + private static final Logger LOG = Log.getLogger(FileDestroyable.class); final List _files = new ArrayList(); public FileDestroyable() @@ -59,7 +61,7 @@ public class FileDestroyable implements Destroyable { if (file.exists()) { - Log.debug("Destroy {}",file); + LOG.debug("Destroy {}",file); IO.delete(file); } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/FileResource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/FileResource.java index 21efe8a76af..1cf2ce18b49 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/FileResource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/FileResource.java @@ -28,6 +28,7 @@ import java.security.Permission; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /* ------------------------------------------------------------ */ @@ -42,6 +43,7 @@ import org.eclipse.jetty.util.log.Log; */ public class FileResource extends URLResource { + private static final Logger LOG = Log.getLogger(FileResource.class); private static boolean __checkAliases = true; /* ------------------------------------------------------------ */ @@ -80,7 +82,7 @@ public class FileResource extends URLResource } catch (Exception e) { - Log.ignore(e); + LOG.ignore(e); try { // Assume that File.toURL produced unencoded chars. So try @@ -94,7 +96,7 @@ public class FileResource extends URLResource } catch (Exception e2) { - Log.ignore(e2); + LOG.ignore(e2); // Still can't get the file. Doh! try good old hack! checkConnection(); @@ -187,15 +189,15 @@ public class FileResource extends URLResource _aliasChecked=true; - if (_alias!=null && Log.isDebugEnabled()) + if (_alias!=null && LOG.isDebugEnabled()) { - Log.debug("ALIAS abs="+abs); - Log.debug("ALIAS can="+can); + LOG.debug("ALIAS abs="+abs); + LOG.debug("ALIAS can="+can); } } catch(Exception e) { - Log.warn(Log.EXCEPTION,e); + LOG.warn(Log.EXCEPTION,e); return getURL(); } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarFileResource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarFileResource.java index a7ba967139f..785f360aae9 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarFileResource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarFileResource.java @@ -23,10 +23,12 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /* ------------------------------------------------------------ */ class JarFileResource extends JarResource { + private static final Logger LOG = Log.getLogger(JarFileResource.class); private JarFile _jarFile; private File _file; private String[] _list; @@ -119,7 +121,7 @@ class JarFileResource extends JarResource String file_url=_urlString.substring(4,_urlString.length()-2); try{return newResource(file_url).exists();} - catch(Exception e) {Log.ignore(e); return false;} + catch(Exception e) {LOG.ignore(e); return false;} } boolean check=checkConnection(); @@ -149,7 +151,7 @@ class JarFileResource extends JarResource } catch(Exception e) { - Log.ignore(e); + LOG.ignore(e); } } @@ -195,7 +197,7 @@ class JarFileResource extends JarResource } catch(MalformedURLException ex) { - Log.warn(ex); + LOG.warn(ex); } } } @@ -252,7 +254,7 @@ class JarFileResource extends JarResource } catch(Exception e) { - Log.ignore(e); + LOG.ignore(e); } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarResource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarResource.java index 33627251331..e317ec00cd2 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarResource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarResource.java @@ -26,11 +26,13 @@ import java.util.jar.Manifest; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /* ------------------------------------------------------------ */ public class JarResource extends URLResource { + private static final Logger LOG = Log.getLogger(JarResource.class); protected JarURLConnection _jarConnection; /* -------------------------------------------------------- */ @@ -65,7 +67,7 @@ public class JarResource extends URLResource } catch(IOException e) { - Log.ignore(e); + LOG.ignore(e); _jarConnection=null; } @@ -128,7 +130,7 @@ public class JarResource extends URLResource if (!exists()) return; - if(Log.isDebugEnabled())Log.debug("Extract "+this+" to "+directory); + if(LOG.isDebugEnabled())LOG.debug("Extract "+this+" to "+directory); String urlString = this.getURL().toExternalForm().trim(); int endOfJarUrl = urlString.indexOf("!/"); @@ -141,7 +143,7 @@ public class JarResource extends URLResource String subEntryName = (endOfJarUrl+2 < urlString.length() ? urlString.substring(endOfJarUrl + 2) : null); boolean subEntryIsDir = (subEntryName != null && subEntryName.endsWith("/")?true:false); - if (Log.isDebugEnabled()) Log.debug("Extracting entry = "+subEntryName+" from jar "+jarFileURL); + if (LOG.isDebugEnabled()) LOG.debug("Extracting entry = "+subEntryName+" from jar "+jarFileURL); InputStream is = jarFileURL.openConnection().getInputStream(); JarInputStream jin = new JarInputStream(is); @@ -192,7 +194,7 @@ public class JarResource extends URLResource if (!shouldExtract) { - if (Log.isDebugEnabled()) Log.debug("Skipping entry: "+entryName); + if (LOG.isDebugEnabled()) LOG.debug("Skipping entry: "+entryName); continue; } @@ -200,7 +202,7 @@ public class JarResource extends URLResource dotCheck = URIUtil.canonicalPath(dotCheck); if (dotCheck == null) { - if (Log.isDebugEnabled()) Log.debug("Invalid entry: "+entryName); + if (LOG.isDebugEnabled()) LOG.debug("Invalid entry: "+entryName); continue; } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java index 34f7ec3c2b5..4cb78891eb1 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java @@ -30,6 +30,7 @@ import org.eclipse.jetty.util.Loader; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /* ------------------------------------------------------------ */ @@ -38,6 +39,7 @@ import org.eclipse.jetty.util.log.Log; */ public abstract class Resource implements ResourceFactory { + private static final Logger LOG = Log.getLogger(Resource.class); public static boolean __defaultUseCaches = true; volatile Object _associate; @@ -103,7 +105,7 @@ public abstract class Resource implements ResourceFactory } catch(Exception e) { - Log.debug(Log.EXCEPTION,e); + LOG.debug(Log.EXCEPTION,e); return new BadResource(url,e.toString()); } } @@ -169,13 +171,13 @@ public abstract class Resource implements ResourceFactory } catch(Exception e2) { - Log.debug(Log.EXCEPTION,e2); + LOG.debug(Log.EXCEPTION,e2); throw e; } } else { - Log.warn("Bad Resource: "+resource); + LOG.warn("Bad Resource: "+resource); throw e; } } @@ -443,7 +445,7 @@ public abstract class Resource implements ResourceFactory } catch(Exception e) { - Log.debug(e); + LOG.debug(e); return null; } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java index c6b5c14d489..c97f07f91aa 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java @@ -23,12 +23,14 @@ import java.security.Permission; import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /* ------------------------------------------------------------ */ /** Abstract resource class. */ public class URLResource extends Resource { + private static final Logger LOG = Log.getLogger(URLResource.class); protected URL _url; protected String _urlString; @@ -62,7 +64,7 @@ public class URLResource extends Resource } catch(IOException e) { - Log.ignore(e); + LOG.ignore(e); } } return _connection!=null; @@ -76,7 +78,7 @@ public class URLResource extends Resource { if (_in!=null) { - try{_in.close();}catch(IOException e){Log.ignore(e);} + try{_in.close();}catch(IOException e){LOG.ignore(e);} _in=null; } @@ -101,7 +103,7 @@ public class URLResource extends Resource } catch (IOException e) { - Log.ignore(e); + LOG.ignore(e); } return _in!=null; } @@ -173,7 +175,7 @@ public class URLResource extends Resource // Try the URL file arg try {return new File(_url.getFile());} - catch(Exception e) {Log.ignore(e);} + catch(Exception e) {LOG.ignore(e);} // Don't know the file return null; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/security/CertificateValidator.java b/jetty-util/src/main/java/org/eclipse/jetty/util/security/CertificateValidator.java index 9afbd6bfbbc..fb2d2843884 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/security/CertificateValidator.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/security/CertificateValidator.java @@ -38,6 +38,7 @@ import java.util.Enumeration; import java.util.concurrent.atomic.AtomicLong; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /** * Convenience class to handle validation of certificates, aliases and keystores @@ -51,6 +52,7 @@ import org.eclipse.jetty.util.log.Log; */ public class CertificateValidator { + private static final Logger LOG = Log.getLogger(CertificateValidator.class); private static AtomicLong __aliasCount = new AtomicLong(); private KeyStore _trustStore; @@ -129,7 +131,7 @@ public class CertificateValidator } catch (KeyStoreException kse) { - Log.debug(kse); + LOG.debug(kse); throw new CertificateException("Unable to validate certificate" + " for alias [" + keyAlias + "]: " + kse.getMessage(), kse); } @@ -177,7 +179,7 @@ public class CertificateValidator } catch (KeyStoreException kse) { - Log.debug(kse); + LOG.debug(kse); throw new CertificateException("Unable to validate certificate" + (certAlias == null ? "":" for alias [" +certAlias + "]") + ": " + kse.getMessage(), kse); } @@ -243,7 +245,7 @@ public class CertificateValidator } catch (GeneralSecurityException gse) { - Log.debug(gse); + LOG.debug(gse); throw new CertificateException("Unable to validate certificate: " + gse.getMessage(), gse); } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ExecutorThreadPool.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ExecutorThreadPool.java index 85de89eaa37..cd92f7ff9d9 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ExecutorThreadPool.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ExecutorThreadPool.java @@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit; import org.eclipse.jetty.util.component.AbstractLifeCycle; import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /* ------------------------------------------------------------ */ /** @@ -34,6 +35,7 @@ import org.eclipse.jetty.util.log.Log; */ public class ExecutorThreadPool extends AbstractLifeCycle implements ThreadPool, LifeCycle { + private static final Logger LOG = Log.getLogger(ExecutorThreadPool.class); private final ExecutorService _executor; /* ------------------------------------------------------------ */ @@ -105,7 +107,7 @@ public class ExecutorThreadPool extends AbstractLifeCycle implements ThreadPool, } catch(RejectedExecutionException e) { - Log.warn(e); + LOG.warn(e); return false; } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java index 0023571d584..466082df6de 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java @@ -33,10 +33,13 @@ import org.eclipse.jetty.util.component.AggregateLifeCycle; import org.eclipse.jetty.util.component.Dumpable; import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool; public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPool, Executor, Dumpable { + private static final Logger LOG = Log.getLogger(QueuedThreadPool.class); + private final AtomicInteger _threadsStarted = new AtomicInteger(); private final AtomicInteger _threadsIdle = new AtomicInteger(); private final AtomicLong _lastShrink = new AtomicLong(); @@ -134,16 +137,16 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo int size=_threads.size(); if (size>0) { - Log.warn(size+" threads could not be stopped"); + LOG.warn(size+" threads could not be stopped"); - if (Log.isDebugEnabled()) + if (LOG.isDebugEnabled()) { for (Thread unstopped : _threads) { - Log.debug("Couldn't stop "+unstopped); + LOG.debug("Couldn't stop "+unstopped); for (StackTraceElement element : unstopped.getStackTrace()) { - Log.debug(" at "+element); + LOG.debug(" at "+element); } } } @@ -567,11 +570,11 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo } catch(InterruptedException e) { - Log.ignore(e); + LOG.ignore(e); } catch(Exception e) { - Log.warn(e); + LOG.warn(e); } finally { @@ -588,7 +591,7 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo * @return true if the thread was found and stopped. * @deprecated Use {@link #interruptThread(long)} in preference */ - @SuppressWarnings("deprecation") + @Deprecated public boolean stopThread(long id) { for (Thread thread: _threads) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ShutdownThread.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ShutdownThread.java index ab133c82c6b..96c9c2527e8 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ShutdownThread.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ShutdownThread.java @@ -19,6 +19,7 @@ import java.util.concurrent.CopyOnWriteArrayList; import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /* ------------------------------------------------------------ */ @@ -30,6 +31,7 @@ import org.eclipse.jetty.util.log.Log; */ public class ShutdownThread extends Thread { + private static final Logger LOG = Log.getLogger(ShutdownThread.class); private static final ShutdownThread _thread = new ShutdownThread(); private boolean _hooked; @@ -56,8 +58,8 @@ public class ShutdownThread extends Thread } catch(Exception e) { - Log.ignore(e); - Log.info("shutdown already commenced"); + LOG.ignore(e); + LOG.info("shutdown already commenced"); } } @@ -71,8 +73,8 @@ public class ShutdownThread extends Thread } catch(Exception e) { - Log.ignore(e); - Log.info("shutdown already commenced"); + LOG.ignore(e); + LOG.info("shutdown already commenced"); } } @@ -112,6 +114,7 @@ public class ShutdownThread extends Thread } /* ------------------------------------------------------------ */ + @Override public void run() { for (LifeCycle lifeCycle : _thread._lifeCycles) @@ -119,11 +122,11 @@ public class ShutdownThread extends Thread try { lifeCycle.stop(); - Log.debug("Stopped " + lifeCycle); + LOG.debug("Stopped " + lifeCycle); } catch (Exception ex) { - Log.debug(ex); + LOG.debug(ex); } } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Timeout.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Timeout.java index c1aabe11d12..a2e9853403e 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Timeout.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Timeout.java @@ -14,6 +14,7 @@ package org.eclipse.jetty.util.thread; import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; /* ------------------------------------------------------------ */ @@ -27,6 +28,7 @@ import org.eclipse.jetty.util.log.Log; */ public class Timeout { + private static final Logger LOG = Log.getLogger(Timeout.class); private Object _lock; private long _duration; private volatile long _now=System.currentTimeMillis(); @@ -134,7 +136,7 @@ public class Timeout } catch(Throwable th) { - Log.warn(Log.EXCEPTION,th); + LOG.warn(Log.EXCEPTION,th); } } }