private Set<ObjectName> getObjectNamesForInterface(String type, String alias, String interfaceName) throws MalformedObjectNameException { Hashtable<String,String> table = new Hashtable<>(); table.put("interface", ObjectName.quote(interfaceName)); table.put("type", ObjectName.quote(type)); if (alias != null) table.put("alias", ObjectName.quote(alias)); ObjectName objName = new ObjectName(getDomain(), table); // Add the wildcard for any other properties. objName = new ObjectName(objName.getCanonicalName()+",*"); MBeanServer mBeanServer = getMbs(); return mBeanServer.queryNames(objName, null); } }
@Override public <T> T getControl(String type, String alias, Class<T> controlInterface) { MBeanServer mBeanServer = getMbs(); ObjectName name = getObjectNameForInterface(type, alias, controlInterface); return name != null ? JMX.newMXBeanProxy(mBeanServer, name, controlInterface) : null; }
getMbs().registerMBean(control, on);