ObjectName cntorServerName = ObjectName.getInstance(":service=" + JMXConnectorServer.class.getName() + ",protocol=" + url.getProtocol());
MBeanServer server = MBeanServerFactory.createMBeanServer("remote.security.example");
server.registerMBean(cntorServer, cntorServerName);
// Setup the rmiregistry to bind in JNDI the RMIConnectorServer stub.
NamingService naming = new NamingService();
ObjectName namingName = ObjectName.getInstance(":service=" + NamingService.class.getName());
server.registerMBean(naming, namingName);
naming.start();
// Setup the interception
SubjectTrackingMBeanServer interceptor = new SubjectTrackingMBeanServer();
cntorServer.setMBeanServerForwarder(interceptor);