Sha256: 0398b631270ee898dc6d7c1881fbec7cf47a482c71c078d03ff3e3fc3ee4b021

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require 'java'

class MBeanBase < java.lang.Object
  include_package 'javax.management'
  include DynamicMBean

  attr_reader :attributes

  def initialize
    @attributes = []
  end 
  
  def getMBeanInfo
    begin
      mbean_attrs = @attributes.map do |attr|
        MBeanAttributeInfo.new attr.to_s, attr.to_s, "java.lang.String", true, false, false
      end
      MBeanInfo.new(self.class.to_s, self.class.to_s,
                  mbean_attrs.to_java('javax.management.MBeanAttributeInfo'),
                  #[].to_java('javax.management.MBeanAttributeInfo'), 
                  [].to_java('javax.management.MBeanConstructorInfo'),
                  [].to_java('javax.management.MBeanOperationInfo'),
                  [].to_java('javax.management.MBeanNotificationInfo'))
    rescue 
      puts $!
    end
  end
end

class TestMBean < MBeanBase
  #mbean_attr_reader :hello

  def initialize
    super
    @hello = "world"
  end
end

require 'remote_server'
server = RemoteServer.new
server.start
mbean = TestMBean.new
mbean.attributes << :hello
server.connector_server.getMBeanServer.register_mbean mbean, ObjectName.new("jmx4r:type=Test")

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jmx4r-0.0.2 test/mbean_base.rb