Methods Summary |
---|
void | clearProxy()
envRemove( ENV_PROXY );
|
java.lang.String | connectionNameToEnvName(java.lang.String connectionName)
return( ENV_CONNECT_NAME_BASE + connectionName );
|
static com.sun.cli.jmx.support.AliasMgrMBean | createAliasMgr()
final AliasMgrHashMapImpl aliasMgrImpl = new AliasMgrHashMapImpl();
final AliasMgr aliasMgr = new AliasMgr( aliasMgrImpl );
try
{
aliasMgrImpl.load( JMXAdminFileNames.getAliasesFile() );
StandardAliasesIniter.init( aliasMgr );
}
catch( Exception e )
{
StandardAliasesIniter.init( aliasMgr );
System.err.println( "can't load aliases file: " + e.getMessage());
}
return( aliasMgr );
|
java.lang.String | envNameToConnectionName(java.lang.String envName)
return( envName.substring( ENV_CONNECT_NAME_BASE.length(), envName.length() ) );
|
com.sun.cli.jmx.support.CLISupportMBeanProxy | establishProxy(java.lang.String name, ConnectInfo connectInfo)
CLISupportMBeanProxy proxy = null;
proxy = setProxy( name, connectInfo );
final String host = connectInfo.getParam( JMXConnectorProvider.HOST );
final String port = connectInfo.getParam( JMXConnectorProvider.PORT );
String protocol = connectInfo.getParam( JMXConnectorProvider.PROTOCOL );
if ( protocol == null )
{
protocol = "jmxmp";
}
println( "Established connection to " +
host + ":" + port + " using " + protocol );
return( proxy );
|
com.sun.cli.jmx.support.CLISupportMBeanProxy | establishProxy(ConnectInfo connectInfo)
final String envName = connectionNameToEnvName( DEFAULT_CONNECTION_NAME );
final CLISupportMBeanProxy proxy = establishProxy( envName , connectInfo );
return( proxy );
|
void | establishProxy()
if ( envGet( ENV_PROXY ) == null )
{
final String envName = connectionNameToEnvName( DEFAULT_CONNECTION_NAME );
final String connectString = (String)envGet( envName );
if ( connectString != null )
{
establishProxy( new ConnectInfo( connectString ) );
}
}
if ( envGet( ENV_PROXY ) == null )
{
throw new java.io.IOException( "can't connect" );
}
|
com.sun.cli.jmx.support.AliasMgrMBean | getAliasMgr()
final AliasMgrMBean proxy = (AliasMgrMBean)envGet( ENV_ALIAS_MGR );
return( proxy );
|
private com.sun.cli.jmx.support.CLISupportMBean | getCLISupport(javax.management.MBeanServerConnection conn)
final CLISupportMBean cliSupport = new CLISupport( conn, sAliasMgr);
return( cliSupport );
|
javax.management.MBeanServerConnection | getConnection()
final MBeanServerConnection conn = (MBeanServerConnection)envGet( ENV_CONNECTION );
return( conn );
|
ConnectionMgr | getConnectionMgr()
initConnectionMgr();
return( sConnectionMgr );
|
java.lang.String[] | getEnvTargets()
final String targetsEnv = (String)envGet( ENV_TARGET );
if ( targetsEnv == null )
return( null );
// convert to String []
final String [] targets = (String [])
TargetPersister.DEFAULT.asObject( targetsEnv );
return( targets );
|
com.sun.cli.jmx.support.CLISupportMBeanProxy | getProxy()
final CLISupportMBeanProxy proxy = (CLISupportMBeanProxy)envGet( ENV_PROXY );
return( proxy );
|
java.lang.String[] | getTargets()
String [] targets = getOperands();
if ( targets.length == 0 )
{
targets = getEnvTargets();
}
return( targets );
|
void | handleException(java.lang.Exception e)
super.handleException( e );
if ( e instanceof java.io.IOException )
{
clearProxy();
}
|
void | initConnectionMgr()
if ( sConnectionMgr != null )
return;
sConnectionMgr = new ConnectionMgrImpl( );
final String providersString = ((String)envGet( ENV_PROVIDERS, "")).trim();
if ( providersString != null && providersString.length() != 0 )
{
final String [] providers = providersString.split( "," );
for( int i = 0; i < providers.length; ++i )
{
try
{
final Class theClass = Class.forName( providers[ i ] );
sConnectionMgr.addProvider( theClass );
println( "Added JMXConnectorProvider: " + providers[ i ] );
}
catch( Exception e )
{
printError( "WARNING: Can't add JMXConnectorProvider: " + providers[ i ] );
}
}
}
|
void | preExecute()
getConnectionMgr();
super.preExecute();
|
void | putEnvTargets(java.lang.String[] targets)
// put targets into environment
final String targetsStr = TargetPersister.DEFAULT.asString( targets );
envPut( ENV_TARGET, targetsStr, true);
|
com.sun.cli.jmx.support.CLISupportMBeanProxy | setProxy(java.lang.String name, ConnectInfo connectInfo)
JMXConnector jmxConnector = null;
try
{
jmxConnector = getConnectionMgr().connect( name, connectInfo );
}
catch( java.io.IOException e )
{
throw new Exception( e.getMessage() + " (" + connectInfo.toString() + ")", e);
}
final MBeanServerConnection managedServer = jmxConnector.getMBeanServerConnection();
final CLISupportMBean cliSupport = getCLISupport( managedServer );
final CLISupportMBeanProxy proxy = new CLISupportMBeanProxy( sAliasMgr, cliSupport );
envPut( connectionNameToEnvName( name ), connectInfo.toString(), true );
envPut( ENV_PROXY, proxy, false );
envPut( ENV_CONNECTION, managedServer, false );
return( proxy );
|