martes, febrero 12, 2008

Using JMX to discover server ports - WAS5 - ibm.software.websphere.application-server | Grupos de Google

Using JMX to discover server ports - WAS5 - ibm.software.websphere.application-server | Grupos de Google: "//create a session
Session session = new Session();

//get a ConfigService object
ConfigService cfgService = ConfigServiceFactory.getConfigService();

//resolve your application server from the configuration
ObjectName[] appServers = cfgService.resolve(session, 'Node=someNodeName:Server=someAppServerName');

//create a pattern to find the HTTPTransport configuration for you application server
ObjectName pattern = ConfigServiceHelper.createObjectName(null, 'HTTPTransport');

//query the configuration to get the http transport values
ObjectName[] httpTransports = cfgService.queryConfigObjects(session, appServers[0], pattern, null);

//loop the result to get the configuration of your ports
for (int i = 0; i < httpTransports.length; i++) {
AttributeList address = (AttributeList) cfgService.getAttribute(session, httpTransports[i], 'address');
Object port = ConfigServiceHelper.getAttributeValue(address, 'port');
Object isSSL = cfgService.getAttribute(session, httpTransports[i], 'sslEnabled');

System.out.println('Port is ' + port + '. Is secure = ' + isSSL);

}

//cleanup session
cfgService.discard(session);"

No hay comentarios: