/** * Returns a string array containing the default JMX domains of all available MBeanServers in this * JVM. * * @return a string array of JMX default domains */ public static String[] getMBeanServerDomains() { Set<String> domains = new HashSet<String>(); for (MBeanServer mbs : MBeanServerFactory.findMBeanServer(null)) { String domain = mbs.getDefaultDomain(); if (domain == null) domain = "DefaultDomain"; domains.add(domain); } return domains.toArray(new String[domains.size()]); }
private static String[] findStandardMBeans(URL codeBase) throws Exception { Set<String> names; if (codeBase.getProtocol().equalsIgnoreCase("file") && codeBase.toString().endsWith("/")) names = findStandardMBeansFromDir(codeBase); else names = findStandardMBeansFromJar(codeBase); Set<String> standardMBeanNames = new TreeSet<String>(); for (String name : names) { if (name.endsWith("MBean")) { String prefix = name.substring(0, name.length() - 5); if (names.contains(prefix)) standardMBeanNames.add(prefix); } } return standardMBeanNames.toArray(new String[0]); }
private synchronized NameValueMap getCachedAttributes(ObjectName objName, Set<String> attrNames) throws InstanceNotFoundException, ReflectionException, IOException { NameValueMap values = cachedValues.get(objName); if (values != null && values.keySet().containsAll(attrNames)) { return values; } attrNames = new TreeSet<String>(attrNames); Set<String> oldNames = cachedNames.get(objName); if (oldNames != null) { attrNames.addAll(oldNames); } values = new NameValueMap(); final AttributeList attrs = conn.getAttributes(objName, attrNames.toArray(new String[attrNames.size()])); for (Attribute attr : attrs.asList()) { values.put(attr.getName(), attr.getValue()); } cachedValues.put(objName, values); cachedNames.put(objName, attrNames); return values; }