3 Replies Latest reply on Jul 20, 2009 5:40 AM by Galder Zamarreño

    How to replace CacheJmxWrapper with JmxRegistrationManager i

    Alex De Luca Newbie

      I am using Jboss Cache Core 3.1.0 and Jboss 5.1.

      Here is what I need to do:
      1 - Deploy the cache using a xml "-jboss-beans.xml" descriptor.
      2 - This descriptor must register the cache with the MBeanServer.
      3 - Retrieve the cache in my code so I am able to use it.

      I am currently doing this as described in section of the documentation ("JMX-Based Deployment in JBoss AS (JBoss AS 5.x)").

      <!-- JMX Management -->
      <bean name="ExampleCacheJmxWrapper" class="org.jboss.cache.jmx.CacheJmxWrapper">
       <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.cache:service=myCache", exposedInterface=org.jboss.cache.jmx.CacheJmxWrapperMBean.class, registerDirectly=true)</annotation>
       <parameter><inject bean="ExampleCache"/></parameter>

      Then I retrieve the cache using the following code:

      MBeanServer server = MBeanServerLocator.locateJBoss();
      ObjectName on = new ObjectName("jboss.cache:service=myCache");
      CacheJmxWrapperMBean<Object, Object> cacheWrapper = (CacheJmxWrapperMBean<Object, Object>) MBeanServerInvocationHandler.newProxyInstance(server, on, CacheJmxWrapperMBean.class, false);
      Cache cache = cacheWrapper.getCache();

      It works, but I am using the CacheJmxWrapper and CacheJmxWrapperMBean classes, which are deprecated. The java doc says that the JmxRegistrationManager should be used instead. Can anyone help with that ? The documentation is out of date.