MBeanServer server = MBeanServerFactory.createMBeanServer("Mail");
ObjectName beanName = new ObjectName("Test:name=test");
server.registerMBean(new TestClass("original"), beanName);
ObjectName monitorName = new ObjectName("Test:name=monitor");
server.createMBean("javax.management.monitor.StringMonitor", monitorName, null);
server.setAttribute(monitorName, new Attribute("ObservedObject", beanName));
server.setAttribute(monitorName, new Attribute("ObservedAttribute", "Str"));
server.setAttribute(monitorName, new Attribute("StringToCompare", "original"));
server.setAttribute(monitorName, new Attribute("GranularityPeriod", new Integer(100)));