<?xml version="1.0" encoding="UTF-8"?>
<config
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:jsr107='http://www.ehcache.org/v3/jsr107'
xmlns='http://www.ehcache.org/v3'
xsi:schemaLocation="
http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.1.xsd
http://www.ehcache.org/v3/jsr107 http://www.ehcache.org/schema/ehcache-107-ext-3.1.xsd">
<service>
<jsr107:defaults enable-management="false" enable-statistics="true"/>
</service>
<cache alias="mySlidingExpiryJCache">
<key-type>java.lang.Long</key-type>
<expiry>
<tti unit="seconds">2</tti>
</expiry>
<resources>
<heap unit="entries">200</heap>
</resources>
<jsr107:mbeans enable-statistics="true"/>
</cache>
</config>
我想通过提取 MBean 来显示统计信息,但是我不知道如何,因为在网上我只能看到以编程方式注入的 bean(另请参见这个SO question)。
StatisticsService statisticsService = new DefaultStatisticsService();
CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
.using(statisticsService)
.build();
cacheManager.init();
有什么建议吗?