connection.createMBean(Sample.class.getName(), objName);
Object ret = connection.invoke(objName, "doSomething", new Object[] {"foo"}, new String[] {String.class.getName()});
System.out.println("Return to doSomething() is " + ret);
NotificationListener listener = new Listener();
connection.addNotificationListener(objName,listener, null, null);
ret = connection.invoke(objName, "doSomething", new Object[] {"bar"}, new String[] {String.class.getName()});
System.out.println("Return to doSomething() is " + ret);
// give time for notification to come in