some refactoring to make it clear what is required to add jmx support.