List of usage examples for org.springframework.jmx.support MBeanServerConnectionFactoryBean setEnvironmentMap
public void setEnvironmentMap(@Nullable Map<String, ?> environment)
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);//from www .ja v a2 s. c o m
Map environment = new HashMap();
environment.put("jmx.remote.credentials", new String[] { this.jmxServerUser, this.jmxServerPasswd });
factory.setEnvironmentMap(environment);
factory.afterPropertiesSet();
return new MBeanServerConnFactoryExtend(factory);
}