I have JMX working with Spring but I do not see ehcache in the list of MBeans. Is there something I must put in my application context to expose the ehcache mbean? Or do I have to write some code?
I have JMX working with Spring but I do not see ehcache in the list of MBeans. Is there something I must put in my application context to expose the ehcache mbean? Or do I have to write some code?
I have tried pasting this code into my class which uses the cache:
but I still don't see it..Code:try { CacheManager manager = new CacheManager(); MBeanServer mBeanServer = ManagementFactory .getPlatformMBeanServer(); ManagementService.registerMBeans(manager, mBeanServer, false, false, false, true); } catch (RuntimeException e) { e.printStackTrace(); }
Found on
http://wiki.burnayev.com/thread/1455...uration?t=anon
and just copied here for further reference. It helped me a lot.
Code:<bean id="hibernateStatisticsMBean" class="org.hibernate.jmx.StatisticsService"> <property name="statisticsEnabled" value="true"/> <property name="sessionFactory" ref="sessionFactory"/> </bean> <bean id="ehCacheMBeanRegistration" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="staticMethod" value="net.sf.ehcache.management.ManagementService.registerMBeans"/> <property name="arguments"> <list> <ref bean="cacheManager"/> <ref bean="mbeanServer"/> <value>true</value> <value>true</value> <value>true</value> <value>true</value> </list> </property> </bean> <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean"> <property name="locateExistingServerIfPossible" value="true"/> </bean> <bean id="mbeanExporter" class="org.springframework.jmx.export.MBeanExporter"> <property name="beans"> <map> <entry key="category=statistics,name=hibernate" value-ref="hibernateStatisticsMBean"/> </map> </property> <property name="server" ref="mbeanServer"/> </bean> <bean id="sessionFactory" class="..." > <property name="hibernateProperties"> <props> ... <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop> <prop key="hibernate.generate_statistics">true</prop> ... </props> </property> </bean> <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> <property name="configLocation" value="classpath:ehcache-hibernate.xml"/> <property name="shared" value="true"/> </bean>