能否请您举个例子,我如何通过 JMX 调用 WroConfiguration.reloadCache()
方法?
我使用 Wildfly,单例启动 ejb,以防万一。
JMX 开启:jmxEnabled=true
最佳答案
这是 Java EE 环境中的示例和要求:
- 在 wro.properties 中应用了以下属性:
cacheUpdatePeriod=0 modelUpdatePeriod=0 debug=false disableCache=true jmxEnabled=true ...
- 不要尝试在带有@PostConstruct 注释的初始方法中应用@Singleton/@Startup 注释来更新ejb bean 中的wro 缓存模型。 Wro MBean 尚未注册,因此,它不会工作。
- 示例本身:
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); }
关于java - 如何通过 JMX 以编程方式更新 wro 缓存/模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29493108/