Results 1 to 3 of 3

Thread: Writing Mbeans back to bean configuration files

  1. #1

    Default Writing Mbeans back to bean configuration files

    Hi,

    Am new to Spring JMX

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


    Code:
    <bean id="ServerConfig" class="com.ServerConfig">
     <property name="serverUrl" value="http://192.168.13.124:9001"/>
     </bean>
    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.

    Note:

    Am using Tomcat 6, Spring 2.5.4

    Thanks In Advance,
    Sudheesh

  2. #2

    Default

    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. #3

    Default

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

Posting Permissions

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