Class: JMX::MBeanServerConnectionProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/jmx4r.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connector) ⇒ MBeanServerConnectionProxy

Adds a connector attribute to Java’s native MBeanServerConnection class.

The connector attribute can be used to manage the connection (e.g, to close it). Why this isn’t included in the native MBeanServerConnection class is beyond me.

connector

JMXConnector instance as returned by JMXConnectorFactory.connect.



33
34
35
36
# File 'lib/jmx4r.rb', line 33

def initialize(connector)
  @connector = connector
  @connection = connector.getMBeanServerConnection
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Forward all other method messages to the underlying MBeanServerConnection instance.



44
45
46
# File 'lib/jmx4r.rb', line 44

def method_missing(method, *args, &block)
  @connection.send method, *args, &block
end

Instance Attribute Details

#connectorObject (readonly)

Returns the value of attribute connector.



25
26
27
# File 'lib/jmx4r.rb', line 25

def connector
  @connector
end

Instance Method Details

#closeObject

Close the connection (an unfortunate omission from the MBeanServerConnection class, imho)



39
40
41
# File 'lib/jmx4r.rb', line 39

def close
  @connector.close
end