View Full Version : Spring JMX General questions
Oct 25th, 2005, 01:53 AM
I'm just testing Spring JMX in my JBoss AS, and it works perfect.
Nevertheless, I have some questions : when I modify a MBean, for which instance is it available ?
I mean, I have a JSF webapp in which I have declared a managed-bean as a MBean.
I change a value, but when I go back to my webapp, I don't see the modification has been done.
So, what have I got to do for that ?
Should I declare my bean not as a singleton but as a prototype ? Can I do this ?
Can someone help me ?
Thanks in advance.
Oct 25th, 2005, 02:38 AM
What do you mean by modifying an mbean? Remember that jmx beans are in most cases wrapper for your beans - they just expose your actual objects; when you modify something on the mbean you are actually modifying your objects.
You mentioned that you are using a webapp. Is your bean stateless or stateful, do you refresh the webpage or not?
Oct 25th, 2005, 11:51 AM
I have a MBean that I have declared in my applicationConfig.xml.
In this bean, I have an attribute that I would like to manipulate with JMX.
So, by modifying, I mean : modify an attribute of this MBean.
I solve the problem by declaring my attribute as a static attribute.
If I don't do that, and even if I refresh my web page, I can't see the modification.
So, how does JMX work ?
I mean : I have an object that I declared as an MBean.
But an instance of this object is created at each request on the server ? So, which instance of my object does JMX "modify" ?
There is maybe one aspect of JMX that I don't really understand...
Just let me know so... ;-)
Thanks in advance.
Oct 25th, 2005, 01:53 PM
I think the problem that you are working with a stateless bean - put on some logging so you see that when you change the mbean the change propagates to your actual object.
When you go back (as you say) the page is reloaded and the old state is lost. By using a static field you have add a stateful aspect to your code. Use either a singleton inside your application or persist this code somewhere else (in a registry, database or smth else).
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.