How to use jmx to update wro cache/model?

23 views
Skip to first unread message

Александр Соколов

unread,
Apr 7, 2015, 9:52:06 AM4/7/15
to wr...@googlegroups.com
I'm not strong with JMX.
1. Could you please give me an example how can I programmatically invoke the WroConfiguration.reloadCache()  method?

2. How can I be sure, that MBean is registred?
You know, I've tried:
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName name = new ObjectName("ro.isdc.wro.config.jmx.jmx:type=WroConfiguration");
MBeanInfo mBeanInfo = mbs.getMBeanInfo(name);
ObjectInstance objectInstance = mbs.getObjectInstance(name);

But both mBeanInfo, objectInstance are nullable. What am I doing wrong? I test it in wildfly, in startup logic of singleton ejb bean.

The property in wro.properties is:
jmxEnabled=true

Alex Objelean

unread,
Apr 7, 2015, 10:09:33 AM4/7/15
to wr...@googlegroups.com
Hi Александр,

on jmxEnabled configuragion is set to true, the mbean is registered automatically. If you open the jconsole, you should an MBean called something like "wro4j-ROOT" (the MBean name is dynamic based on the application context name). There you should find the operation called reloadModel & reloadCache which can be triggered via JMX.

Beside using JMX, I recommend using the following configuration: resourceWatcherUpdatePeriod (set this value to something bigger than 0). This is useful during development, when any change will be detected out of the box within the specified interval.

Let me know if that helps.

Cheers,
Alex




On Tuesday, 7 April 2015 16:52:06 UTC + 3, Александр Соколов wrote:
I'm not strong with JMX.
1. Could you please give me an example how can I programmatically invoke the WroConfiguration.reloadCache () method?

2. How can I be sure, that MBean is registred?
You know, I've tried:
. MBeanServer mbs = ManagementFactory getPlatformM BeanServer (); 
ObjectName name = new ObjectName ( "ro.isdc.wro. config.jmx.jmx: type = WroConfiguration " );
MBeanInfo MBeanInfo = mbs.getMBeanInfo (name);
ObjectInstance ObjectInstance = mbs. getObjectInstance (name);
Reply all
Reply to author
Forward
0 new messages