Results 1 to 4 of 4

Thread: Spring JMX General questions

  1. #1
    Join Date
    Jul 2005
    Posts
    29

    Default Spring JMX General questions

    Hello,

    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.
    bgOnline

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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?
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Jul 2005
    Posts
    29

    Default

    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.
    bgOnline

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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).
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •