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

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

Introduction

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

Prototype

public void setEnvironmentMap(@Nullable Map<String, ?> environment) 

Source Link

Document

Set the environment properties used to construct the JMXConnector as a Map of String keys and arbitrary Object values.

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);//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);
}