0

I am working on OSGI based application which runs on Karaf. We use JPA and Hibernate to connect to mysql . Have enabled Level 2 cache using Ehcache. I want to enable JMX monitoring of Ehcache. I found an article which tells how to enable on JMX monitoring of Ehcache on Spring application (http://www.codesenior.com/en/tutorial/How-to-monitor-Ehcache-in-JMX-with-Spring-Configuration).

Is there a way to configure JMX monitoring of EHcache on OSGI application running on Karaf similar to example above ?

preetham
  • 36
  • 4

1 Answers1

0

From what I understand, you do not create the CacheManager yourself, Hibernate does. So you have to either:

  • Plug into the Hibernate second level cache initialisation to get at the CacheManager and run the ManagementService.registerMBeans that the article talks about. You may be able to do that by extending the Hibernate Ehcache provider so that it adds that initialisation step. See org.hibernate.cache.ehcache.EhCacheRegionFactory.
  • Find a logical place in your application startup where the CacheManager has already been created by Hibernate, get at it using the net.sf.ehcache.CacheManager#ALL_CACHE_MANAGERS map, and perform the MBeans initialisation as in the article.
Louis Jacomet
  • 13,661
  • 2
  • 34
  • 43