From: <cr...@us...> - 2008-04-25 14:04:05
|
Revision: 4023 http://jnode.svn.sourceforge.net/jnode/?rev=4023&view=rev Author: crawley Date: 2008-04-25 07:03:56 -0700 (Fri, 25 Apr 2008) Log Message: ----------- Converted OnheapCommand Modified Paths: -------------- trunk/shell/descriptors/org.jnode.shell.command.xml trunk/shell/src/shell/org/jnode/shell/command/OnHeapCommand.java Modified: trunk/shell/descriptors/org.jnode.shell.command.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.xml 2008-04-25 14:03:05 UTC (rev 4022) +++ trunk/shell/descriptors/org.jnode.shell.command.xml 2008-04-25 14:03:56 UTC (rev 4023) @@ -175,6 +175,12 @@ </syntax> <syntax alias="memory" description="Show JNode memory usage"/> <syntax alias="namespace" description="Print the contents of the system namespace"/> + <syntax alias="onheap" description="Print heap object count and size statistics"> + <optionSet> + <option argLabel="minCount" longName="minCount"/> + <option argLabel="minTotalSize" longName="minTotalSize"/> + </optionSet> + </syntax> <syntax alias="run" description="Run a command file"> <argument argLabel="file"/> </syntax> Modified: trunk/shell/src/shell/org/jnode/shell/command/OnHeapCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/OnHeapCommand.java 2008-04-25 14:03:05 UTC (rev 4022) +++ trunk/shell/src/shell/org/jnode/shell/command/OnHeapCommand.java 2008-04-25 14:03:56 UTC (rev 4023) @@ -26,11 +26,9 @@ import org.jnode.shell.AbstractCommand; import org.jnode.shell.CommandLine; -import org.jnode.shell.help.Help; -import org.jnode.shell.help.Parameter; -import org.jnode.shell.help.ParsedArguments; -import org.jnode.shell.help.argument.IntegerArgument; -import org.jnode.shell.help.argument.SizeArgument; +import org.jnode.shell.syntax.Argument; +import org.jnode.shell.syntax.IntegerArgument; +import org.jnode.shell.syntax.LongArgument; import org.jnode.vm.Vm; import org.jnode.vm.memmgr.HeapStatistics; @@ -39,22 +37,17 @@ */ public class OnHeapCommand extends AbstractCommand { - private static final IntegerArgument ARG_MININSTANCECOUNT = new IntegerArgument( - "mic", "the minimum instance count to show"); + private final IntegerArgument ARG_MIN_INSTANCE_COUNT = new IntegerArgument( + "minCount", Argument.OPTIONAL, 1, Integer.MAX_VALUE, "the minimum instance count to show"); - private static final SizeArgument ARG_MINTOTALSIZE = new SizeArgument( - "mts", "the minimum total size to show"); + private final LongArgument ARG_MIN_TOTAL_SIZE = new LongArgument( + "minTotalSize", Argument.OPTIONAL, 1L, Long.MAX_VALUE, "the minimum total size to show"); - private static final Parameter PARAM_MININSTANCECOUNT = new Parameter( - ARG_MININSTANCECOUNT, Parameter.OPTIONAL); + public OnHeapCommand() { + super("show the number of instances on the heap with memory usage"); + registerArguments(ARG_MIN_INSTANCE_COUNT, ARG_MIN_TOTAL_SIZE); + } - private static final Parameter PARAM_MINTOTALSIZE = new Parameter( - ARG_MINTOTALSIZE, Parameter.OPTIONAL); - - public static Help.Info HELP_INFO = new Help.Info("onheap", - "show the number of instances on the heap with memory usage", - new Parameter[] { PARAM_MININSTANCECOUNT , PARAM_MINTOTALSIZE }); - public static void main(String[] args) throws Exception { new OnHeapCommand().execute(null, System.in, System.out, System.err); } @@ -64,16 +57,14 @@ */ public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) throws Exception { - final ParsedArguments args = HELP_INFO.parse(commandLine); - out.println("on heap:"); final HeapStatistics stats = Vm.getHeapManager().getHeapStatistics(); - if (PARAM_MININSTANCECOUNT.isSet(args)) { - stats.setMinimumInstanceCount(ARG_MININSTANCECOUNT.getInteger(args)); + if (ARG_MIN_INSTANCE_COUNT.isSet()) { + stats.setMinimumInstanceCount(ARG_MIN_INSTANCE_COUNT.getValue()); } - if (PARAM_MINTOTALSIZE.isSet(args)) { - stats.setMinimumTotalSize(ARG_MINTOTALSIZE.getLong(args)); + if (ARG_MIN_TOTAL_SIZE.isSet()) { + stats.setMinimumTotalSize(ARG_MIN_TOTAL_SIZE.getValue()); } out.println(stats.toString()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |