private void connect() throws IOException {
  JMXServiceURL jmxUrl=new JMXServiceURL(String.format(fmtUrl,host,port));
  jmxc=JMXConnectorFactory.connect(jmxUrl,null);
  MBeanServerConnection mbeanServerConn=jmxc.getMBeanServerConnection();
  try {
    ObjectName name=new ObjectName(DOMAINLIST_OBJECT_NAME);
    domainListProxy=MBeanServerInvocationHandler.newProxyInstance(mbeanServerConn,name,DomainListManagementMBean.class,true);
    name=new ObjectName(VIRTUALUSERTABLE_OBJECT_NAME);
    virtualUserTableProxy=MBeanServerInvocationHandler.newProxyInstance(mbeanServerConn,name,RecipientRewriteTableManagementMBean.class,true);
    name=new ObjectName(USERSREPOSITORY_OBJECT_NAME);
    usersRepositoryProxy=MBeanServerInvocationHandler.newProxyInstance(mbeanServerConn,name,UsersRepositoryManagementMBean.class,true);
    name=new ObjectName(MAILBOXCOPIER_OBJECT_NAME);
    mailboxCopierManagement=MBeanServerInvocationHandler.newProxyInstance(mbeanServerConn,name,MailboxCopierManagementMBean.class,true);
    name=new ObjectName(MAILBOXMANAGER_OBJECT_NAME);
    mailboxManagerManagement=MBeanServerInvocationHandler.newProxyInstance(mbeanServerConn,name,MailboxManagerManagementMBean.class,true);
    name=new ObjectName(QUOTAMANAGER_OBJECT_NAME);
    quotaManagement=MBeanServerInvocationHandler.newProxyInstance(mbeanServerConn,name,QuotaManagementMBean.class,true);
    name=new ObjectName(REINDEXER_OBJECT_NAME);
    reIndexerManagement=MBeanServerInvocationHandler.newProxyInstance(mbeanServerConn,name,ReIndexerManagementMBean.class,true);
    name=new ObjectName(SIEVEMANAGER_OBJECT_NAME);
    sieveRepositoryManagement=MBeanServerInvocationHandler.newProxyInstance(mbeanServerConn,name,SieveRepositoryManagementMBean.class,true);
  }
 catch (  MalformedObjectNameException e) {
    throw new RuntimeException("Invalid ObjectName? Please report this as a bug.",e);
  }
}

private void connect ( ) throws IOException { JMXServiceURL jmxUrl = new JMXServiceURL ( String . format ( fmtUrl , host , port ) ) ; jmxc = JMXConnectorFactory . connect ( jmxUrl , null ) ; MBeanServerConnection mbeanServerConn = jmxc . getMBeanServerConnection ( ) ; try { ObjectName name = new ObjectName ( DOMAINLIST_OBJECT_NAME ) ; domainListProxy = MBeanServerInvocationHandler . newProxyInstance ( mbeanServerConn , name , DomainListManagementMBean . class , true ) ; name = new ObjectName ( VIRTUALUSERTABLE_OBJECT_NAME ) ; virtualUserTableProxy = MBeanServerInvocationHandler . newProxyInstance ( mbeanServerConn , name , RecipientRewriteTableManagementMBean . class , true ) ; name = new ObjectName ( USERSREPOSITORY_OBJECT_NAME ) ; usersRepositoryProxy = MBeanServerInvocationHandler . newProxyInstance ( mbeanServerConn , name , UsersRepositoryManagementMBean . class , true ) ; name = new ObjectName ( MAILBOXCOPIER_OBJECT_NAME ) ; mailboxCopierManagement = MBeanServerInvocationHandler . newProxyInstance ( mbeanServerConn , name , MailboxCopierManagementMBean . class , true ) ; name = new ObjectName ( MAILBOXMANAGER_OBJECT_NAME ) ; mailboxManagerManagement = MBeanServerInvocationHandler . newProxyInstance ( mbeanServerConn , name , MailboxManagerManagementMBean . class , true ) ; name = new ObjectName ( QUOTAMANAGER_OBJECT_NAME ) ; quotaManagement = MBeanServerInvocationHandler . newProxyInstance ( mbeanServerConn , name , QuotaManagementMBean . class , true ) ; name = new ObjectName ( REINDEXER_OBJECT_NAME ) ; reIndexerManagement = MBeanServerInvocationHandler . newProxyInstance ( mbeanServerConn , name , ReIndexerManagementMBean . class , true ) ; name = new ObjectName ( SIEVEMANAGER_OBJECT_NAME ) ; sieveRepositoryManagement = MBeanServerInvocationHandler . newProxyInstance ( mbeanServerConn , name , SieveRepositoryManagementMBean . class , true ) ; } catch ( MalformedObjectNameException e ) { throw new RuntimeException ( "Invalid ObjectName? Please report this as a bug." , e ) ; } }
create a connection to the jmx agent and setup the m [ x ] bean proxies .
