Method: JMX::MBeanServer#initialize

Defined in:
lib/jmx/server.rb

#initialize(location = nil, username = nil, password = nil) ⇒ MBeanServer

when creatinga new MBeanServer you can optionally specify a location, username, and password if specify these values (or at least the location) the MBeanServer instance will connect to an existing (and remote ) MBean server and register the mbeans there. otherwise the server will connect to to the local Platform MBean Server.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/jmx/server.rb', line 24

def initialize(location=nil, username=nil, password=nil)
  if (location)
    env = username ? 
      {"jmx.remote.credentials" => [username, password].to_java(:string)} :
      nil
    url = JMXServiceURL.new location
    @server = JMXConnectorFactory.connect(url, env).getMBeanServerConnection
  else
    @server = java.lang.management.ManagementFactory.getPlatformMBeanServer
    #@server = MBeanServerFactory.createMBeanServer
  end
end