From ef9ac7760daf460e6201e3daab35815aa1f6aa8e Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 16 Jan 2012 15:24:31 +1100 Subject: [PATCH] 368635 moved lifecycle state reporting from toString to dump --- .../eclipse/jetty/io/nio/SelectorManager.java | 5 ++- .../jetty/server/AbstractConnector.java | 5 ++- .../jetty/server/handler/AbstractHandler.java | 2 +- .../util/component/AbstractLifeCycle.java | 5 --- .../util/component/AggregateLifeCycle.java | 33 ++++++++++--------- .../jetty/util/ssl/SslContextFactory.java | 5 ++- .../jetty/util/thread/QueuedThreadPool.java | 2 +- 7 files changed, 25 insertions(+), 32 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java index a28b46ab824..212a6e264c0 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java @@ -372,7 +372,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa /* ------------------------------------------------------------ */ public void dump(Appendable out, String indent) throws IOException { - out.append(String.valueOf(this)).append("\n"); + AggregateLifeCycle.dumpObject(out,this); AggregateLifeCycle.dump(out,indent,TypeUtil.asList(_selectSet)); } @@ -983,9 +983,8 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa public String toString() { Selector selector=_selector; - return String.format("%s %s keys=%d selected=%d", + return String.format("%s keys=%d selected=%d", super.toString(), - SelectorManager.this.getState(), selector != null && selector.isOpen() ? selector.keys().size() : -1, selector != null && selector.isOpen() ? selector.selectedKeys().size() : -1); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java index 2dd058a615a..e36ee95331b 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java @@ -889,11 +889,10 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Ht @Override public String toString() { - return String.format("%s@%s:%d %s", + return String.format("%s@%s:%d", getClass().getSimpleName(), getHost()==null?"0.0.0.0":getHost(), - getLocalPort()<=0?getPort():getLocalPort(), - AbstractLifeCycle.getState(this)); + getLocalPort()<=0?getPort():getLocalPort()); } /* ------------------------------------------------------------ */ diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandler.java index c17da968245..975e7991e53 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandler.java @@ -94,7 +94,7 @@ public abstract class AbstractHandler extends AggregateLifeCycle implements Hand /* ------------------------------------------------------------ */ public void dumpThis(Appendable out) throws IOException { - out.append(toString()).append(' ').append(getState()).append('\n'); + out.append(toString()).append(" - ").append(getState()).append('\n'); } } 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 b0ef41ce86c..e99b87555e2 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 @@ -209,9 +209,4 @@ public abstract class AbstractLifeCycle implements LifeCycle public void lifeCycleStopped(LifeCycle event) {} public void lifeCycleStopping(LifeCycle event) {} } - - public String toString() - { - return super.toString()+"#"+getState(); - } } 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 05448362f92..33796a2ba7c 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 @@ -339,7 +339,16 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable /* ------------------------------------------------------------ */ protected void dumpThis(Appendable out) throws IOException { - out.append(String.valueOf(this)).append("\n"); + out.append(String.valueOf(this)).append(" - ").append(getState()).append("\n"); + } + + /* ------------------------------------------------------------ */ + public static void dumpObject(Appendable out,Object o) throws IOException + { + if (o instanceof LifeCycle) + out.append(String.valueOf(o)).append(" - ").append((AbstractLifeCycle.getState((LifeCycle)o))).append("\n"); + else + out.append(String.valueOf(o)).append("\n"); } /* ------------------------------------------------------------ */ @@ -359,15 +368,11 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable out.append(indent).append(" +- "); if (b._bean instanceof Dumpable) ((Dumpable)b._bean).dump(out,indent+(i==size?" ":" | ")); - else - out.append(String.valueOf(b._bean)).append("\n"); + else + dumpObject(out,b._bean); } - else - { - out.append(indent).append(" +~ "); - out.append(String.valueOf(b._bean)).append("\n"); - } - + else + dumpObject(out,b._bean); } if (i!=size) @@ -395,16 +400,12 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable if (o instanceof Dumpable) ((Dumpable)o).dump(out,indent+(i==size?" ":" | ")); - else - out.append(String.valueOf(o)).append("\n"); + else + dumpObject(out,o); } if (i!=size) - out.append(indent).append(" |\n"); - + out.append(indent).append(" |\n"); } } - - - } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java index 956c294b885..94c0d93cf65 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java @@ -1524,11 +1524,10 @@ public class SslContextFactory extends AbstractLifeCycle /* ------------------------------------------------------------ */ public String toString() { - return String.format("%s@%x(%s,%s)#%s", + return String.format("%s@%x(%s,%s)", getClass().getSimpleName(), hashCode(), _keyStorePath, - _trustStorePath, - getState()); + _trustStorePath); } } 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 1efec3536d0..981faa607c0 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 @@ -508,7 +508,7 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo @Override public String toString() { - return _name+"{"+getMinThreads()+"<="+getIdleThreads()+"<="+getThreads()+"/"+getMaxThreads()+","+(_jobs==null?-1:_jobs.size())+"}#"+getState(); + return _name+"{"+getMinThreads()+"<="+getIdleThreads()+"<="+getThreads()+"/"+getMaxThreads()+","+(_jobs==null?-1:_jobs.size())+"}"; } /* ------------------------------------------------------------ */