Make JMX registration optional

This patch is a modification of [patch.txt](https://issues.apache.org/jira/secure/attachment/12509655/patch.txt), which is attached to [ZOOKEEPER-1350](https://issues.apache.org/jira/browse/ZOOKEEPER-1350), that can be applied to branch "branch-3.4".