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.



41
42
43
44
# File 'lib/jmx4r.rb', line 41

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.



52
53
54
# File 'lib/jmx4r.rb', line 52

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

Instance Attribute Details

#connectorObject (readonly)

Returns the value of attribute connector.



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

def connector
  @connector
end

Instance Method Details

#closeObject

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



47
48
49
# File 'lib/jmx4r.rb', line 47

def close
  @connector.close
end