TestServerpublic class TestServer extends Object
Fields Summary |
---|
MBeanServer | mServer | final boolean | mTestInProcess |
Constructors Summary |
---|
private TestServer(int port, boolean testInProcess)
mTestInProcess = testInProcess;
new StringifierRegistryIniter();
mServer = createAgent( );
registerConnectors( port );
registerAdapters( 8082 );
AddMBeans( mServer );
|
Methods Summary |
---|
private void | AddMBeans(javax.management.MBeanServer conn)
// setup alias mgr
final AliasMgrHashMapImpl aliasImpl = new AliasMgrHashMapImpl();
try
{
aliasImpl.load( new java.io.File( AliasMgrHashMapImpl.DEFAULT_FILENAME ) );
}
catch( Exception e )
{
// ignore
}
final AliasMgr aliasMgr = new AliasMgr( aliasImpl );
StandardAliasesIniter.init( aliasMgr );
registerMBean( conn, aliasMgr , CLISupportStrings.ALIAS_MGR_TARGET );
// setup CLI support, using alias mgr via a proxy (don't use directly)
final CLISupport cliSupport = new CLISupport( conn, aliasMgr);
registerMBean( conn, cliSupport, CLISupportStrings.CLI_SUPPORT_TARGET );
// register our testees
registerMBean( conn, new CLISupportTestee( ), CLISupportStrings.CLI_SUPPORT_TESTEE_TARGET );
registerMBean( conn, new CLISupportSimpleTestee( ), CLISupportStrings.CLI_SIMPLE_TESTEE_TARGET );
registerMBean( conn, new kstatMgr( ), "kstat:name=kstat-mgr,type=kstat-mgr" );
| private javax.management.MBeanServer | createAgent()
final MBeanServer server = MBeanServerFactory.createMBeanServer( "Test" );
return( server );
| public static void | main(java.lang.String[] args)
try
{
final ArgHelperOptionsInfo optionInfo = new ArgHelperOptionsInfo( );
optionInfo.addOptions( "port,1 testInProcess" );
final ArgHelperImpl argHelper = new ArgHelperImpl( Arrays.asList( args ).listIterator(), optionInfo);
final Integer port = argHelper.getInteger( "--port" );
if ( port == null )
{
System.out.println( "USAGE: TestServer --port=<port-number> [--testInProcess]" );
System.exit( 1 );
}
final Boolean testInProcess = argHelper.getBoolean( "testInProcess", Boolean.FALSE );
final TestServer server = new TestServer( port.intValue(), testInProcess.booleanValue() );
if ( testInProcess.booleanValue() )
{
final AliasMgrHashMapImpl aliasMgrImpl = new AliasMgrHashMapImpl();
aliasMgrImpl.load( new java.io.File( AliasMgrHashMapImpl.DEFAULT_FILENAME ) );
final AliasMgr aliasMgr = new AliasMgr( aliasMgrImpl );
final CLISupport cliSupport = new CLISupport( server.mServer, aliasMgr );
final CLISupportMBeanProxy proxy = new CLISupportMBeanProxy( aliasMgr, cliSupport ) ;
final CLISupportTester tester = new CLISupportTester( server.mServer, proxy );
tester.Run();
}
p( "Server is running." );
}
catch( Exception e )
{
p( e );
}
| private static void | p(java.lang.Object arg)
System.out.println( arg.toString() );
| private void | registerAdapters(int adapterPort)
/*
// CREATE and START a new HTML adaptor
final HtmlAdaptorServer html = new HtmlAdaptorServer();
try
{
final String name = ":name=html,type=adapter,port=" + adapterPort;
registerMBean( mServer, html, name);
html.start();
}
catch(Exception e)
{
System.out.println("\tCould not create the HTML adaptor.");
e.printStackTrace();
}
*/
| private void | registerConnectors(int connectorPort)
// create the StandardConnector
try
{
final JMXServiceURL url = new JMXServiceURL( "service:jmx:jmxmp://localhost:" + connectorPort );
final JMXMPConnectorServer connector = new JMXMPConnectorServer( url, null, mServer );
final String name = ":name=JMXMPConnectorServer,type=connector,port=" + connectorPort;
registerMBean( mServer, connector, name);
connector.start();
}
catch( Exception e )
{
System.out.println("\tCould not create the StandardConnector");
e.printStackTrace();
}
| private void | registerMBean(javax.management.MBeanServer conn, java.lang.Object mbean, java.lang.String name)
conn.registerMBean( mbean, new ObjectName( name ) );
p( "registered object: " + name );
|
|