Could you please give an example, how I can invoke the WroConfiguration.reloadCache()
method via JMX?
I use Wildfly, singleton startup ejb, in case it does matter.
JMX is switched on: jmxEnabled=true
Here is an example and requirements in Java EE environment:
cacheUpdatePeriod=0 modelUpdatePeriod=0 debug=false disableCache=true jmxEnabled=true ...
try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = new ObjectName("wro4j-ROOT:type=WroConfiguration"); mbs.invoke(name, "reloadCache", null, null); mbs.invoke(name, "reloadModel", null, null); } catch (InstanceNotFoundException e) { logger.warn("Could not find wro4j MBean. It has not been initiated yet"); } catch (Exception e) { logger.error(e); }
When jmxEnabled configuration is set to true, the MBean is registered automatically. If you open the jconsole, you should see 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.