Announcement Announcement Module
No announcement yet.
Writing Mbeans back to bean configuration files Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Writing Mbeans back to bean configuration files


    Am new to Spring JMX

    I have exposed a Spring bean as MBEAN using following configuration
    <bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
        <property name="beans">
               <entry key="bean:name=ServerConfig" value-ref="ServerConfig"/>
        <property name="assembler">
            <bean class="org.springframework.jmx.export.assembler.MethodNameBasedMBeanInfoAssembler">
                <property name="managedMethods">
    where ServerConfig is a bean. serverUrl is a property of the bean.

    <bean id="ServerConfig" class="com.ServerConfig">
     <property name="serverUrl" value=""/>
    is the bean config

    I am able to connect to the JMX Server using Jconsole.

    and able to see setServerUrl method.

    Now I have set a value to the serverUrl and a message "method succuessfully invoked " came.

    But when I shutdown my server the BEAN CONFIG file is not updated.

    How can I write the MBEAN RUNTIME VALUE back to its bean configuration file?

    Any help is greatly appreciated.


    Am using Tomcat 6, Spring 2.5.4

    Thanks In Advance,

  • #2
    I'm not certain what you're trying to do. Are you trying to have your code dynamically update your Spring bean XML configuration file? It seems like this is different than the usual paradigm of using a Spring configuration file to provide the static context information to bootstrap a Spring container and initialize it correctly.

    What do you do in your code for the setServerUrl method? Even if you change the Spring-configured value for your server URL, that likely won't change the XML configuration which was read at start-up time.


    • #3
      This bean is a CONFIG BEAN and to be exposed as an MBEAN.
      So If somebody edit the properties of this bean it is to be persisted and the
      values need to be available even after context shutdown and a restart.

      Eventhough this is not a usual practice I need this.
      Otherwise I may need to implement a custom xml writer or a OBJECT CAHE..

      I suspect , if I do like that , am unknowingly missing some Spring facility...