* @throws Exception
*/
public void testJ2EEServer() throws Exception
{
getLog().debug("+++ testJ2EEServer");
Management jsr77MEJB = getManagementEJB();
String domainName = jsr77MEJB.getDefaultDomain();
ObjectName queryName = new ObjectName(domainName + ":" +
J2EEManagedObject.TYPE + "=" + J2EETypeConstants.J2EEServer + "," + "*");
Set names = jsr77MEJB.queryNames(queryName, null);
if (names.isEmpty())
{
fail("Could not find JSR-77 J2EEServer '" + J2EETypeConstants.J2EEServer + "'");
}
Iterator iter = names.iterator();
ObjectName serverName = null;
while (iter.hasNext())
{
serverName = (ObjectName) iter.next();
getLog().debug("J2EEServer: " + serverName);
}
// Get the server info
String vendor = (String) jsr77MEJB.getAttribute(serverName, "serverVendor");
getLog().debug("ServerVendor: " + vendor);
String version = (String) jsr77MEJB.getAttribute(serverName, "serverVersion");
getLog().debug("ServerVersion: " + version);
// Get the list of JVMs
String[] jvms = (String[]) jsr77MEJB.getAttribute(serverName, "javaVMs");
if (jvms == null || jvms.length == 0)
fail("Failed to find any JavaVMs");
ObjectName jvm = new ObjectName(jvms[0]);
getLog().debug("JavaVMs[0]: " + jvms[0]);
String javaVendor = (String) jsr77MEJB.getAttribute(jvm, "javaVendor");
getLog().debug("JavaVendor: " + javaVendor);
String javaVersion = (String) jsr77MEJB.getAttribute(jvm, "javaVersion");
getLog().debug("JavaVersion: " + javaVersion);
String node = (String) jsr77MEJB.getAttribute(jvm, "node");
getLog().debug("Node: " + node);
jsr77MEJB.remove();
}