-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setAttributes is internally using invoke on MBean #10
Comments
@ksekhar I am sorry about the tardiness of this response. It got lost in a sea of tabs in my browser. I think I need a bit more detail on your problem. I think you are interacting with an already written MBean and it only persists if attributes are set through setAttributes right? Does it persist if they are set through setAttribute? The second part of what I think you are asking confuses me a little. The attributes seem to be using []= which does call setAttribute. I half wonder if perhaps you might have an operand and an attribute with the same name? Could their be an name collision? |
@enebo Thanks for the reply. I was always resigned about replies from code owners. You proved me wrong. I tried using setAttribute, but the results are the same. It would update in JVM but it won't in DB. I even checked out Twiddle (https://community.jboss.org/wiki/Twiddle) source code and it does exactly what I do I call the setAttributes method on the RMIServerConnection object that JMXConnectionFactory returns. heres my code if that helps (Pardon if its horrible) #@conn ||= JMX.connect :host => @hostname,:port => @port, :user => FreBean.user_pass1[0], :password => FreBean.user_pass1[1]
def update(name, data)
attributes = @conn[name].attributes #returns MBeanInfo object (I modified the method in gem to return type along with name)
o = ObjectName.new(name)
list = AttributeList.new
data.each do |mbean_name,att_val_hash|
att_val_hash.each do |att, val|
val = javax.management.ObjectName.new(val) if attributes.find{|a| a.first.downcase == att.camelcase.downcase}[1] == "javax.management.ObjectName" unless val.blank?
cast_val = val.to_java(attributes.find{|a| a.first.downcase == att.camelcase.downcase}[1])
a = Attribute.new(attributes.find{|a| a.first.downcase == att.camelcase.downcase}.first,cast_val)
list.add(a)
end
end
@conn.server.setAttributes(o,list)
return @conn[name]
end |
I don't know if this will help there are really only two changes I made:
#@conn ||= JMX.connect :host => @hostname,:port => @port, :user => FreBean.user_pass1[0], :password => FreBean.user_pass1[1]
def update(name, data)
attributes = @conn[name].attributes #returns MBeanInfo object (I modified the method in gem to return type along with name)
list = []
data.each do |mbean_name,att_val_hash|
att_val_hash.each do |att, val|
n, type = attributes.find{|a| a.first.downcase == att.camelcase.downcase }
val = javax.management.ObjectName.new(val) if type == "javax.management.ObjectName" unless val.blank?
list.add(Attribute.new(n, val.to_java(type)))
end
end
@conn[name].setAttributes(list)
end If this does not work I am wondering if there is something Open Sourced as a MBean which I can reproduce this issue. Looking informally at the library I feel like it should really be calling setAttributes. |
It is possible my simplification of your find is wrong too but it was difficult to tell. Still I think you should be able to to something similar. |
I tried the first and got undefined method setAttributes |
It seems the DynamicMbean class's method setAttributes is calling the invoke method on the MBean and not the setAttributes method itself.
The problem I am facing is that the server code I work with is written in such a way that only the attributes set through the setAttributes method are persisted in Database,
Is there a way I can bypass this method and directly use the Mbean's setAttributes method ?
The text was updated successfully, but these errors were encountered: