368635 moved lifecycle state reporting from toString to dump

This commit is contained in:
Greg Wilkins 2012-01-16 15:24:31 +11:00
parent d4a23c2a65
commit ef9ac7760d
7 changed files with 25 additions and 32 deletions

View File

@ -372,7 +372,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public void dump(Appendable out, String indent) throws IOException 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)); AggregateLifeCycle.dump(out,indent,TypeUtil.asList(_selectSet));
} }
@ -983,9 +983,8 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
public String toString() public String toString()
{ {
Selector selector=_selector; Selector selector=_selector;
return String.format("%s %s keys=%d selected=%d", return String.format("%s keys=%d selected=%d",
super.toString(), super.toString(),
SelectorManager.this.getState(),
selector != null && selector.isOpen() ? selector.keys().size() : -1, selector != null && selector.isOpen() ? selector.keys().size() : -1,
selector != null && selector.isOpen() ? selector.selectedKeys().size() : -1); selector != null && selector.isOpen() ? selector.selectedKeys().size() : -1);
} }

View File

@ -889,11 +889,10 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Ht
@Override @Override
public String toString() public String toString()
{ {
return String.format("%s@%s:%d %s", return String.format("%s@%s:%d",
getClass().getSimpleName(), getClass().getSimpleName(),
getHost()==null?"0.0.0.0":getHost(), getHost()==null?"0.0.0.0":getHost(),
getLocalPort()<=0?getPort():getLocalPort(), getLocalPort()<=0?getPort():getLocalPort());
AbstractLifeCycle.getState(this));
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */

View File

@ -94,7 +94,7 @@ public abstract class AbstractHandler extends AggregateLifeCycle implements Hand
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public void dumpThis(Appendable out) throws IOException public void dumpThis(Appendable out) throws IOException
{ {
out.append(toString()).append(' ').append(getState()).append('\n'); out.append(toString()).append(" - ").append(getState()).append('\n');
} }
} }

View File

@ -209,9 +209,4 @@ public abstract class AbstractLifeCycle implements LifeCycle
public void lifeCycleStopped(LifeCycle event) {} public void lifeCycleStopped(LifeCycle event) {}
public void lifeCycleStopping(LifeCycle event) {} public void lifeCycleStopping(LifeCycle event) {}
} }
public String toString()
{
return super.toString()+"#"+getState();
}
} }

View File

@ -339,7 +339,16 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
protected void dumpThis(Appendable out) throws IOException 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");
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -360,14 +369,10 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable
if (b._bean instanceof Dumpable) if (b._bean instanceof Dumpable)
((Dumpable)b._bean).dump(out,indent+(i==size?" ":" | ")); ((Dumpable)b._bean).dump(out,indent+(i==size?" ":" | "));
else else
out.append(String.valueOf(b._bean)).append("\n"); dumpObject(out,b._bean);
} }
else else
{ dumpObject(out,b._bean);
out.append(indent).append(" +~ ");
out.append(String.valueOf(b._bean)).append("\n");
}
} }
if (i!=size) if (i!=size)
@ -396,15 +401,11 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable
if (o instanceof Dumpable) if (o instanceof Dumpable)
((Dumpable)o).dump(out,indent+(i==size?" ":" | ")); ((Dumpable)o).dump(out,indent+(i==size?" ":" | "));
else else
out.append(String.valueOf(o)).append("\n"); dumpObject(out,o);
} }
if (i!=size) if (i!=size)
out.append(indent).append(" |\n"); out.append(indent).append(" |\n");
} }
} }
} }

View File

@ -1524,11 +1524,10 @@ public class SslContextFactory extends AbstractLifeCycle
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public String toString() public String toString()
{ {
return String.format("%s@%x(%s,%s)#%s", return String.format("%s@%x(%s,%s)",
getClass().getSimpleName(), getClass().getSimpleName(),
hashCode(), hashCode(),
_keyStorePath, _keyStorePath,
_trustStorePath, _trustStorePath);
getState());
} }
} }

View File

@ -508,7 +508,7 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
@Override @Override
public String toString() 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())+"}";
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */