Registry { private Registry() { } private  Registry(); static synchronized Object registerMBean(final ObjectName objectName, final Object mbean); static synchronized void registerIfNotExistsMBean(final ObjectName objectName, final Object mbean); static synchronized Object getRegistered(final ObjectName objectName); static Object getRegistered(final String domain, final String name); static Object registerMBean(final String domain, final String name, final Object object); @Nullable static Object unregister(final Object object); @Nullable static Object unregister(final Class<?> object); @Nullable static Object unregister(final String packageName, final String mbeanName); @Nullable static synchronized Object unregister(final ObjectName objectName); static ExportedValuesMBean export(final Object object); static ExportedValuesMBean export(final Class<?> object); static ExportedValuesMBean export(final String packageName, final String mbeanName,
          final Object... objects); @Nullable static ExportedValuesMBean exportIfNeeded(final String packageName, final String mbeanName,
          final Object... objects); @SuppressFBWarnings("OCP_OVERLY_CONCRETE_PARAMETER") @Deprecated static ExportedValuesMBean export(final String packageName, final String mbeanName,
          final Properties attributes, final Object... objects); @Deprecated static ExportedValuesMBean export(final String packageName, final String mbeanName,
          @Nullable final Map<String, Object> attributes, final Object... objects);  }
@Test public void testRegistry() throws InterruptedException, IOException, InstanceNotFoundException, MBeanException, AttributeNotFoundException, ReflectionException, InvalidAttributeValueException { JmxTest testObj = new JmxTest(); Properties props = new Properties(); props.setProperty("propKey", "propvalue"); Registry.export("caca", "maca", props); Registry.export("test", "Test", props, testObj); Registry.registerMBean("test2", "TestClassic", new org.spf4j.jmx.Test()); Map<String, Object> map = new HashMap<>(); map.put("isCrap", Boolean.TRUE); map.put("a.crap", Boolean.FALSE); map.put("isNonsense", "bla"); map.put("", "bla"); Registry.export("testMap", "map", map, testObj); Client.setAttribute("service:jmx:rmi: "test", "Test", "booleanFlag", Boolean.TRUE); Client.setAttribute("service:jmx:rmi: "test", "Test", "propKey", "caca"); Object ret = Client.getAttribute("service:jmx:rmi: "test", "Test", "booleanFlag"); Assert.assertEquals(Boolean.TRUE, ret); String prop = (String) Client.getAttribute("service:jmx:rmi: "test", "Test", "propKey"); Assert.assertEquals("caca", prop); Assert.assertEquals("caca", props.get("propKey")); CompositeData cd = (CompositeData) Client.getAttribute("service:jmx:rmi: "test", "Test", "columnDef"); LOG.debug("CD={}", cd); Assert.assertEquals("bla", cd.get("name")); CompositeData cd2 = (CompositeData) Client.callOperation("service:jmx:rmi: "test", "Test", "getColumnDef", "bubu"); LOG.debug("CD2={}", cd2); Assert.assertEquals("bubu", cd2.get("name")); CompositeData cd3 = (CompositeData) Client.callOperation("service:jmx:rmi: "test", "Test", "echo", cd2); LOG.debug("CD3={}", cd3); Assert.assertEquals("bubu", cd3.get("name")); Client.callOperation("service:jmx:rmi: "test", "Test", "print", 3, Boolean.TRUE, "caca", cd2); Client.setAttribute("service:jmx:rmi: "test", "Test", "stringVal", "bla bla"); Object ret2 = Client.getAttribute("service:jmx:rmi: "test", "Test", "stringVal"); Assert.assertEquals("bla bla", ret2); try { Client.setAttribute("service:jmx:rmi: "test", "Test", "doubleVal", 0.0); Assert.fail(); } catch (RuntimeMBeanException e) { Throwables.writeTo(e, System.err, Throwables.PackageDetail.SHORT); } }