ObjectName name = new ObjectName("domain:key=value");
LocalService mbean = new LocalService();
server.registerMBean(mbean, name);
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost");
JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
cntorServer.start();
JMXConnector cntor = JMXConnectorFactory.connect(cntorServer.getAddress());
MBeanServerConnection mbsc = cntor.getMBeanServerConnection();
LocalServiceMBean remoteMBean = (LocalServiceMBean)MBeanServerInvocationHandler.newProxyInstance(mbsc, name, LocalServiceMBean.class, false);
try
{