{
MBeanServer server = MBeanServerFactory.createMBeanServer();
ObjectName oname = new ObjectName("test:test=test");
XMBean mmbean = new XMBean();
ExtendedResource resource = new ExtendedResource();
mmbean.setManagedResource(resource, "ObjectReference");
mmbean.setModelMBeanInfo(resource.getMBeanInfo());
server.registerMBean(mmbean, oname);
MyInterface2 mbean = (MyInterface2)MBeanProxy.get(
MyInterface2.class, oname, server);