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
{
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);
}

View File

@ -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());
}
/* ------------------------------------------------------------ */

View File

@ -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');
}
}

View File

@ -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();
}
}

View File

@ -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");
}
}
}

View File

@ -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);
}
}

View File

@ -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())+"}";
}
/* ------------------------------------------------------------ */