Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using JMX to discover server ports - WAS5

68 views
Skip to first unread message

Yoel Yaffe

unread,
Dec 10, 2006, 8:27:53 AM12/10/06
to
Hi,
My application that runs within the WebSphere required to discover dynamically the application ports.
I've found some websphere code that uses the JMX, but it requires first the application ports to connect the MBeans.
(AdminClient ac = AdminClientFactory.createAdminClient(prop))

Do websphere enables other APIs to discover the applications ports?

Thanks,
Yoel

jimmy.f...@jayway.se

unread,
Dec 10, 2006, 8:50:05 AM12/10/06
to
Hi,

I'm not sure what you mean with discover your application ports. But if you are already running inside WebSphere you could use;

AdminService adminService = AdminServiceFactory.getAdminService();

to get an AdminService object for your local JVM. You can then do the same thing as you can with the AdminClient object, but only within your local JVM. The AdminClient object is used when you want to access remote MBeans.

Please explain some more if this is not what you mean.


Br,
Jimmy

Yoel Yaffe

unread,
Dec 11, 2006, 4:34:06 AM12/11/06
to
Thanks for the quick response.
Do you know how can I get the application listening ports by using the AdminService ?

jimmy.f...@jayway.se

unread,
Dec 11, 2006, 5:38:51 AM12/11/06
to
Well, do you mean the http/s port/s for the WebContainer or do you mean the BOOTSTRAP_ADDRESS, SOAP_CONNECTOR_ADDRESS and so on for your application server?

Look at some sample code of how to get the http/s ports from the configuration:

//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);

0 new messages