MBeanServerHandler implements MBeanServerHandlerMBean, MBeanRegistration { public final ObjectName registerMBean(Object pMBean,String ... pOptionalName) throws MalformedObjectNameException, NotCompliantMBeanException, InstanceAlreadyExistsException { synchronized (mBeanHandles) { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); try { String name = pOptionalName != null && pOptionalName.length > 0 ? pOptionalName[0] : null; ObjectName registeredName = serverHandle.registerMBeanAtServer(server, pMBean, name); mBeanHandles.add(new MBeanHandle(server,registeredName)); return registeredName; } catch (RuntimeException exp) { throw new IllegalStateException("Could not register " + pMBean + ": " + exp, exp); } catch (MBeanRegistrationException exp) { throw new IllegalStateException("Could not register " + pMBean + ": " + exp, exp); } } } MBeanServerHandler(Configuration pConfig, LogHandler pLogHandler); Object dispatchRequest(JsonRequestHandler pRequestHandler, JmxRequest pJmxReq); final ObjectName registerMBean(Object pMBean,String ... pOptionalName); final void destroy(); MBeanServerExecutorLocal getMBeanServerManager(); ServerHandle getServerHandle(); static List<ServerDetector> lookupDetectors(); String mBeanServersInfo(); ObjectName preRegister(MBeanServer server, ObjectName name); final String getObjectName(); void postRegister(Boolean registrationDone); void preDeregister(); void postDeregister();  }
@Test(expectedExceptions = IllegalStateException.class,expectedExceptionsMessageRegExp = ".*not register.*") public void mbeanRegistrationFailed() throws JMException { handler.registerMBean(new Dummy(true, "test:type=dummy")); }