Methods Summary |
---|
void | executeInternal()
final String [] operands = getOperands();
if ( operands.length == 0 )
{
printUsage();
}
else
{
for ( int i = 0; i < operands.length; ++i )
{
final String cmd = operands[ i ];
CmdStrings.CmdHelp help = CmdStrings.getHelp( cmd );
if ( help == null )
{
final Class cmdClass = getCmdFactory().getClass( cmd );
if ( cmdClass != null )
{
final String [] aka = getCmdNames( cmdClass );
if ( aka != null && aka.length != 0)
{
help = CmdStrings.getHelp( aka[ 0 ] );
}
}
}
String msg = null;
if ( help != null )
{
msg = help.toString();
final Class cmdClass = getCmdFactory().getClass( cmd );
if ( cmdClass != null )
{
msg = msg + "\n" + getAlsoKnownAs( cmdClass );
}
}
else
{
println( "Searching for MBeans with operation \"" + stripColon( cmd ) + "\"" );
msg = getHelpUnknown( cmd );
if ( msg == null || msg.length() == 0 )
{
println( "No matching operations found" );
}
}
println( msg );
}
}
|
java.lang.String | getHelpUnknown(java.lang.String cmdString)
cmdString = stripColon( cmdString );
String msg = "";
try
{
establishProxy();
// if there is a proxy, see if any MBeans have matching operations
final CLISupportMBeanProxy proxy = getProxy();
if ( proxy != null && ! cmdString.equals( "*" ) )
{
final InspectRequest request = new InspectRequest();
// ask for operations only
request.includeSummary = true;
request.includeDescription = false;
request.attrs = null;
request.notifications = null;
request.constructors = false;
request.operations = cmdString;
final InspectResult [] results =
proxy.mbeanInspect( request, new String [] { "*" } );
String operationsMsg = "";
for( int i = 0; i < results.length; ++i )
{
final InspectResult result = results[ i ];
if ( result.operationsInfo.length != 0 )
{
operationsMsg = operationsMsg + result.objectInstance.getObjectName() + "\n";
operationsMsg = operationsMsg + ArrayStringifier.DEFAULT.stringify( result.operationsInfo, "\n");
operationsMsg = operationsMsg + "\n\n";
}
}
if ( operationsMsg.length() != 0 )
{
msg = msg + operationsMsg;
}
}
}
catch( Exception e )
{
// squelch
}
return( msg );
|
public static java.lang.String[] | getNames()
return( new String [] { "help", "h", "--h"} );
|
int | getNumRequiredOperands()
// there may be some, but there may be none
return( 0 );
|
java.lang.String | getUsage()
String usage = "*** Available commands ***\n\n";
final CmdStrings.CmdHelp [] allHelp = CmdStrings.getAllHelp();
for( int i = 0; i < allHelp.length; ++i )
{
usage = usage + allHelp[ i ].getSynopsis() + "\n\n";
}
return( usage );
|
private java.lang.String | stripColon(java.lang.String cmd)
String cmdString = cmd;
if ( cmdString.endsWith( ":" ) )
{
// indicates generic JMX method
cmdString = cmdString.substring( 0, cmdString.length() -1);
}
return( cmdString );
|