Methods Summary |
---|
void | addCmd()
requireNumOperands( 1, "A command classname must be specified");
final String commandClassname = getOperands()[ 0 ];
final ClassList list = createCmdList();
if ( list.exists( commandClassname ) )
{
println( "Command already in list: " + commandClassname );
}
else if ( ! isLegalClassname( commandClassname ) )
{
printError( "Illegal classname: " + commandClassname );
}
else
{
final CmdFactoryIniter initer = new CmdFactoryIniter( getCmdFactory() );
final Class theClass = ClassUtil.getClassFromName( commandClassname );
initer.addMappings( theClass );
list.add( commandClassname );
envPut( ENV_COMMANDS, list.toString(), true );
}
|
void | addProvider()
requireNumOperands( 1, "A provider classname must be specified");
final String providerClassname = getOperands()[ 0 ];
ClassList list = createProviderList();
if ( list.exists( providerClassname ) )
{
println( "Provider already in list: " + providerClassname );
}
else if ( ! isLegalClassname( providerClassname ) )
{
printError( "Illegal classname: " + providerClassname );
}
else
{
// if this succeeds, then we'll update the env
try
{
getConnectionMgr().addProvider( Class.forName( providerClassname ) );
}
catch( Exception e )
{
printError( "WARNING: unable to instantiate provider (added to list anyway): " +
e.getMessage() );
}
list.add( providerClassname );
envPut( ENV_PROVIDERS, list.toString(), true );
}
|
com.sun.cli.jmx.cmd.ConfigureCmd$ClassList | createCmdList()
return( new ClassList( (String)envGet( ENV_COMMANDS ) ) );
|
com.sun.cli.jmx.cmd.ConfigureCmd$ClassList | createProviderList()
return( new ClassList( (String)envGet( ENV_PROVIDERS ) ) );
|
void | displayCmds()
println( "Commands configured: " );
final String list = IteratorStringifier.stringify( createCmdList().iterator(), "\n" );
println( (list.length() == 0) ? "<none>" : list );
|
void | displayConfig()
displayProviders();
println( "" );
displayCmds();
|
void | displayProviders()
println( "Available providers: " );
final String list = IteratorStringifier.stringify( createProviderList().iterator(), "\n" );
println( (list.length() == 0) ? "<none>" : list );
println( "\nProviders successfully loaded (includes built-ins): " );
final JMXConnectorProvider [] providersLoaded = getConnectionMgr().getProviders();
for ( int i = 0; i < providersLoaded.length; ++i )
{
JMXConnectorProvider provider = providersLoaded[ i ];
println( provider.getClass().getName() );
}
|
void | executeInternal()
final String cmdName = getCmdNameAsInvoked();
if ( cmdName.equals( SHOW_CONFIG ) )
{
displayConfig();
}
else if ( cmdName.equals( ADD_PROVIDER ) )
{
addProvider();
}
else if ( cmdName.equals( REMOVE_PROVIDER ) )
{
removeProvider( );
}
else if ( cmdName.equals( ADD_CMD ) )
{
addCmd( );
}
else if ( cmdName.equals( REMOVE_CMD ) )
{
removeCmd( );
}
else
{
printUsage();
}
|
public static java.lang.String[] | getNames()
return( NAMES );
|
int | getNumRequiredOperands()
return( 0 );
|
ArgHelper.OptionsInfo | getOptionInfo()
return( new ArgHelperOptionsInfo( OPTIONS_INFO ) );
|
java.lang.String | getUsage()
return( CmdStrings.CONFIGURE_HELP.toString() );
|
boolean | isLegalClassname(java.lang.String name)
// should test this properly, but at least make sure it doesn't have our delim
return( name.indexOf( CLASSNAME_DELIM ) < 0 );
|
void | removeCmd()
requireNumOperands( 1, "A classname must be specified");
final String classname = getOperands()[ 0 ];
final ClassList list = createCmdList();
if ( ! list.exists( classname ) )
{
println( "Command not registered: " + classname );
}
else
{
// remove it from the preferences
list.remove( classname );
envPut( ENV_PROVIDERS, list.toString(), true );
// remove it from the factory
final CmdFactoryIniter initer = new CmdFactoryIniter( getCmdFactory() );
initer.removeMappings( ClassUtil.getClassFromName( classname ) );
}
|
void | removeProvider()
requireNumOperands( 1, "A provider classname must be specified");
final String providerClassname = getOperands()[ 0 ];
ClassList list = createProviderList();
if ( ! list.exists( providerClassname ) )
{
println( "Provider not found: " + providerClassname );
}
else
{
// if this succeeds, then we'll update the env
try
{
final Class theClass = Class.forName( providerClassname );
getConnectionMgr().removeProvider( theClass );
}
catch( Exception e )
{
// ignore
}
list.remove( providerClassname );
envPut( ENV_PROVIDERS, list.toString(), true );
}
|