Example usage for org.springframework.jmx.support MBeanServerConnectionFactoryBean setConnectOnStartup

List of usage examples for org.springframework.jmx.support MBeanServerConnectionFactoryBean setConnectOnStartup

Introduction

In this page you can find the example usage for org.springframework.jmx.support MBeanServerConnectionFactoryBean setConnectOnStartup.

Prototype

public void setConnectOnStartup(boolean connectOnStartup) 

Source Link

Document

Set whether to connect to the server on startup.

Usage

From source file:com.dianping.cache.service.impl.ServiceMonitorServiceImpl.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private MBeanServerConnFactoryExtend createMBeanConnFactory(String clientIp) throws IOException {
    MBeanServerConnectionFactoryBean factory = new MBeanServerConnectionFactoryBean();
    String jmxHost = clientIp.contains(":") ? clientIp : clientIp + ":3397";
    factory.setServiceUrl("service:jmx:rmi:///jndi/rmi://" + jmxHost + "/HawkMBeanServer");
    factory.setConnectOnStartup(false);
    Map environment = new HashMap();
    environment.put("jmx.remote.credentials", new String[] { this.jmxServerUser, this.jmxServerPasswd });
    factory.setEnvironmentMap(environment);
    factory.afterPropertiesSet();//from   www. jav a 2  s. c  om
    return new MBeanServerConnFactoryExtend(factory);
}