Back to index

munin  2.0.1
BasicMBeanConnection.java
Go to the documentation of this file.
00001 package org.munin.plugin.jmx;
00002 import java.io.IOException;
00003 import java.net.MalformedURLException;
00004 import java.util.Map;
00005 
00006 import javax.management.MBeanServerConnection;
00007 import javax.management.remote.JMXConnector;
00008 import javax.management.remote.JMXConnectorFactory;
00009 import javax.management.remote.JMXServiceURL;
00010 
00011 /* Inherit from this if you need another method for jboss/glassfish/etc */
00012 
00013 public class BasicMBeanConnection {
00014 
00015     public static MBeanServerConnection get(Config config) throws IOException, MalformedURLException
00016     {
00017               JMXServiceURL u = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + config.getIp() + ":" + config.getPort()+ "/jmxrmi");
00018         Map<String, Object> credentials = config.getConnectionCredentials();
00019         JMXConnector c=JMXConnectorFactory.connect(u,credentials);
00020         MBeanServerConnection connection=c.getMBeanServerConnection();
00021         return (connection);
00022     }
00023 }
00024