This is my very first question on StackOverflow so, please bear with me.
What am I trying to achieve?
I need to write a standalone program to access a particular instance or multiple instances of Websphere Application Server and get details from it. As far as my research goes, there are two ways to do this.
- Adaptors
- Connectors
I am currently taking up the 'Connectors' approach and that too the SOAP connector (for its firewall friendliness)
So, my code would be something like this..
// Initialize the AdminClient.
Properties adminProps = new Properties();
adminProps.setProperty("type", AdminClient.CONNECTOR_TYPE_SOAP );
adminProps.setProperty("host", "localhost");
adminProps.setProperty("port", "8880");
AdminClient adminClient = AdminClientFactory.createAdminClient(adminProps);
String query = "WebSphere:*";
//String query = "WebSphere:type=Server,*";
ObjectName queryName = new ObjectName(query);
Set s = adminClient.queryNames(queryName, null);
if (!s.isEmpty()) {
iter = s.iterator();
while (iter.hasNext()) {
ObjectName nodeagent = (ObjectName) iter.next();
System.out.println("*********************************************");
System.out.println("KeyPropertyList: " + nodeagent.getKeyPropertyListString());
}
}
With this piece of code, I am able to get the list of all the MBeans on that particular instance of the WAS (C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01) and it successfully prints the Key - Property list.
Now I have a list of MBeans. What next? Link: _http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.javadoc.doc/web/mbeanDocs/index.html
Here is my query:
How do I get an instance of a particular MBean I am interested in and fetch all related properties?
For example:
AppManagement appM = AppManagementProxy.getJMXProxyForClient (adminClient);
System.out.println(appM.listApplications(null, null, null));
Would list all the application(s) on that particular instance of WAS
[query, SamplesGallery, ivtApp, DefaultApplication, PlantsByWebSphere]
I am interested in knowing more about the applications installed say, are they up and running? If so, the IP Address, build number, is it in maintenance, etc., (just quoting them as an example) If I can get all possible details of the application that the MBean could offer, then it would complete my task (partly)
The aforementioned is just an example and I would like to get more out of MBeans. So, please provide a solution / sample code that would help me out in getting information from any MBean the WAS instance has to offer. (Using JMX)
Additional Details: IBM WebSphere Application Server, 7.0.0.0 (Base Installation)
Thanks in Advance, AJ