Diff
Modified: trunk/jmx/Manifest.txt (1134 => 1135)
--- trunk/jmx/Manifest.txt 2008-11-19 14:12:26 UTC (rev 1134)
+++ trunk/jmx/Manifest.txt 2008-11-20 14:05:29 UTC (rev 1135)
@@ -11,5 +11,6 @@
samples/memory.rb
test/jmx_attribute_test.rb
test/jmx_client_test.rb
+test/jmx_notification_test.rb
test/jmx_server_test.rb
-test/test.rb
+test/object_name_test.rb
Modified: trunk/jmx/lib/jmx/dynamic_mbean.rb (1134 => 1135)
--- trunk/jmx/lib/jmx/dynamic_mbean.rb 2008-11-19 14:12:26 UTC (rev 1134)
+++ trunk/jmx/lib/jmx/dynamic_mbean.rb 2008-11-20 14:05:29 UTC (rev 1135)
@@ -83,17 +83,20 @@
# "shutdown requests more time"
# end
# end
-# Once you have defined your bean class you can start declaring attributes and operations. Attributes come in three flavors:
-# read, write, and read write. Simmilar to the <tt>attr*</tt> helpers, there are helpers that are used to create management
-# attributes. Use +r_attribute+, +w_attribute+, and +rw_attribute+ to declare attributes, and the +operation+, +returns+, and +parameter+
-# helpers to define a management operation.
+# Once you have defined your bean class you can start declaring attributes and operations.
+# Attributes come in three flavors: read, write, and read write. Simmilar to the <tt>attr*</tt>
+# helpers, there are helpers that are used to create management attributes. Use +r_attribute+,
+# +w_attribute+, and +rw_attribute+ to declare attributes, and the +operation+, +returns+,
+# and +parameter+ helpers to define a management operation.
# Creating attributes with the *_attribute convention ALSO creates ruby accessors
-# (it invokes the attr_accessor/attr_reader/attr_writer ruby helpers) to create ruby methods like: user_name= and username.
-# So in your ruby code you can treat the attributes as "regular" ruby accessors
+# (it invokes the attr_accessor/attr_reader/attr_writer ruby helpers) to create ruby methods
+# like: user_name= and username. So in your ruby code you can treat the attributes
+# as "regular" ruby accessors
class RubyDynamicMBean
import javax.management.MBeanOperationInfo
import javax.management.MBeanAttributeInfo
import javax.management.DynamicMBean
+ import javax.management.MBeanInfo
include JMX::JavaTypeAware
#NOTE this will not be needed when JRuby-3164 is fixed.
@@ -223,7 +226,8 @@
@info = MBeanInfo.new name, description, attributes, nil, operations, nil
end
- # Retrieve the value of the requested attribute (where attribute is a javax.management.Attribute class)
+ # Retrieve the value of the requested attribute (where attribute is a
+ # javax.management.Attribute class)
def getAttribute(attribute)
send("jmx_get_"+attribute.downcase)
end
Modified: trunk/jmx/lib/jmx/server.rb (1134 => 1135)
--- trunk/jmx/lib/jmx/server.rb 2008-11-19 14:12:26 UTC (rev 1134)
+++ trunk/jmx/lib/jmx/server.rb 2008-11-20 14:05:29 UTC (rev 1135)
@@ -69,12 +69,16 @@
@server.query_names(object_name, query)
end
+
+ def unregister_mbean(object_name)
+ name = make_object_name object_name
+ @server.unregisterMBean(name)
+
+ end
def register_mbean(object, object_name)
name = make_object_name object_name
-
@server.registerMBean(object, name)
-
MBeanProxy.generate(@server, name)
end
Modified: trunk/jmx/lib/jmx.rb (1134 => 1135)
--- trunk/jmx/lib/jmx.rb 2008-11-19 14:12:26 UTC (rev 1134)
+++ trunk/jmx/lib/jmx.rb 2008-11-20 14:05:29 UTC (rev 1135)
@@ -7,16 +7,18 @@
import java.util.ArrayList
import javax.management.Attribute
import javax.management.MBeanInfo
-import javax.management.ObjectName
import javax.management.DynamicMBean
-class ObjectName
- def [](key)
- get_key_property(key.to_s)
- end
+module JMX
+ import javax.management.ObjectName
+ class ObjectName
+ def [](key)
+ get_key_property(key.to_s)
+ end
- def info(server)
- server.getMBeanInfo(self)
+ def info(server)
+ server.getMBeanInfo(self)
+ end
end
end
Modified: trunk/jmx/test/jmx_server_test.rb (1134 => 1135)
--- trunk/jmx/test/jmx_server_test.rb 2008-11-19 14:12:26 UTC (rev 1134)
+++ trunk/jmx/test/jmx_server_test.rb 2008-11-20 14:05:29 UTC (rev 1135)
@@ -68,4 +68,17 @@
assert_equal("hehheh", bean.string_double("heh"))
assert_equal("123", bean.concat([1,2,3]))
end
+ def test_ruby_mbean_twice
+ dyna = MyDynamicMBean.new("domain.MySuperBean", "Heh")
+ domain = @server.default_domain
+ @server.unregister_mbean "#{domain}:type=MyDynamicMBean"
+ @server.register_mbean dyna, "#{domain}:type=MyDynamicMBean"
+ # Get bean from client connector connection
+ bean = @client["#{domain}:type=MyDynamicMBean"]
+ assert_equal("foo", bean.foo)
+ assert_equal(6, bean.double(3))
+ assert_raise(TypeError) { puts bean.double("HEH") }
+ assert_equal("hehheh", bean.string_double("heh"))
+ assert_equal("123", bean.concat([1,2,3]))
+ end
end