This discussion is archived
2 Replies Latest reply: Mar 18, 2013 8:08 AM by chenda RSS

Change dynamic propertie with MBean

chenda Newbie
Currently Being Moderated
Hello,
I have implemented a MBean config instead of using properties file as It allows me to change the value during runtime, without restarting the server.

For that, i used the org.springframework.jmx.export.MBeanExporter and register this bean into my spring config file.

<bean id="ConfigJMX" class="xyz.mbean.ConfigImpl">
<property name="fileName" value="/tmp/toto.txt"/>
</bean>

<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
<property name="beans">
<map>
<entry key="xyz:name=MyConfig" value-ref="ConfigJMX"/>
</map>
</property>
</bean>

I have added the following library In the MANIFEST under runtime classpath.
I have added the following JARs to satisfy classpath issue (I don't know if it is the right way of doing with CEP ?)
- lib/org.springframework.spring-context_2.5.6.jar
- lib/org.springframework.spring-core_2.5.6.jar
- lib/org.springframework.spring-aop_2.5.6.jar
Compilation is fine, but during the deployment, i have the following exception:
../..
Caused By: org.springframework.beans.FatalBeanException: Could not create service reference; nested exception is java.lang.IllegalArgumentException: interface org.springframework.aop.IntroductionInfo is not visible from class loader
     at com.bea.wlevs.spring.support.ServiceInjectionBeanPostProcessor.postProcessPropertyValues(ServiceInjectionBeanPostProcessor.java:128)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:998)
../..
Seems that cep engine refuse to 'register' thoses libraries.

Could you provide the right way of dealing with this issue ?
Or
Do we have a better mecanism to implement what i'm trying to do in CEP (loading and changing properties value during runtime without restarting the server)?

Regards,
chenda
  • 1. Re: Change dynamic propertie with MBean
    chenda Newbie
    Currently Being Moderated
    Hello,

    I managed to made it works.

    1/ Remove the jars in the lib folders
    *lib/org.springframework.spring-context_2.5.6.jar
    *lib/org.springframework.spring-core_2.5.6.jar
    *lib/org.springframework.spring-aop_2.5.6.jar
    Theses exist from CEP installation.

    2/ Open META-INF, dependencies tabs, and add the complaining missing package during deployment
    ../..
    org.springframework.jmx.export;version="2.5.6"
    ... (more)
    ../..

    3/ Reference the EPN.xml, as following

         <wlevs:adapter id="FileReaderAdapter"
              class="com.oracle.fr.ocs.cep.filereaderconfigdyn.adapter.FileReaderAdapter">
              <wlevs:instance-property name="configMBean" ref="configJMX"/>
              <wlevs:listener ref="inputFileReaderChannel" />          
         </wlevs:adapter>

    Then you are able to change dynamically through JConsole, the value define in your MBean and it works like a charm.

    We can probably use "ConfigurationPropertyPlaceholderConfigurer" class to achive the same goal and this is probably a better integration with CEP mecanism (if properties are writable at runtime).
    http://docs.oracle.com/cd/E23943_01/dev.1111/e14301/overview.htm#CEGGDFEI
    For the moment, i'm not able to made it work (yet) ;-)

    Regards,
    chenda
  • 2. Re: Change dynamic propertie with MBean
    chenda Newbie
    Currently Being Moderated
    Using "ConfigurationPropertyPlaceholderConfigurer" class is pretty easy
    http://docs.oracle.com/cd/E23943_01/dev.1111/e14301/overview.htm#CEGGDFEI

    1/ Create a properties file in your CEP eclipse project : properties/app.properties
    2/ Add to your EPN
         <bean id="configPropertyBean"
              class="com.bea.wlevs.spring.support.ConfigurationPropertyPlaceholderConfigurer">
              <property name="location" value="properties/app.properties"/>          
         </bean>
         <wlevs:adapter id="FileReaderAdapter"
              class="com.oracle.fr.ocs.cep.filereader.adapter.FileReaderAdapter">
              <wlevs:instance-property name="fileName" value="${cep.app.filename}"/>
              <wlevs:listener ref="inputFileReaderChannel" />
         </wlevs:adapter>

    where properties/app.properties contains
    cep.app.filename=/home/oracle/poesie.txt

    The class ConfigurationPropertyPlaceholderConfigurer does all the job for you. Then you can reference this bean to acces the property.
    However, this solution does not give me the possibility to dynamically change the values define in properties file via JConsole.
    I was not able to see the properties in JConsole/MBean panel.

    Regards,
    chenda

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points