3 Replies Latest reply on Jul 20, 2009 5:40 AM by galder.zamarreno

    How to replace CacheJmxWrapper with JmxRegistrationManager i

    alex-jboss69

      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 5.4.2.2 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>
      
       <constructor>
       <parameter><inject bean="ExampleCache"/></parameter>
       </constructor>
      </bean>
      


      Then I retrieve the cache using the following code:

      MBeanServer server = MBeanServerLocator.locateJBoss();
      ObjectName on = new ObjectName("jboss.cache:service=myCache");
      @SuppressWarnings("unchecked")
      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.

      Thanks

        • 1. Re: How to replace CacheJmxWrapper with JmxRegistrationManag
          galder.zamarreno

          See my comment in http://www.jboss.org/index.html?module=bb&op=viewtopic&t=156458&start=10

          I believe your method is still valid in spite of the deprecation. I'm trying to get further clarification on this and will let u know.

          • 2. Re: How to replace CacheJmxWrapper with JmxRegistrationManag
            simon_temple

            Has any progress been made with this?

            I'm using Cache 3.1.0.GA as bundled with JBAS5.1

            I'm trying to use the JmxRegistrationManager instead of the CacheJmxWrapper as its deprecated. My cache starts and I see this message in the log:

            2009-07-15 17:17:56,731 INFO [org.jboss.cache.jmx.PlatformMBeanServerRegistration](main) JBossCache MBeans were successfully registered to the platform mbean server.
            


            But I can't see any jboss.cache MBeans using the jmx-console.

            Is the solution to stick with the deprecated classes in JBAS5.1?

            Here's the last part of my jboss-beans.xml

            <!-- The cache itself -->
             <bean name="VCSTreeCache" class="org.jboss.cache.Cache">
             <constructor factoryMethod="createCache">
             <factory bean="VCSCacheFactory"/>
             <parameter class="org.jboss.cache.config.Configuration">
             <inject bean="VCSTreeCacheConfig"/>
             </parameter>
             <parameter class="boolean">false</parameter>
             </constructor>
             </bean>
            
             <!-- JMX Management -->
             <bean name="VCSTreeCacheJmxWrapper"
             class="org.jboss.cache.jmx.JmxRegistrationManager">
             <constructor>
             <parameter>
             <inject bean="VCSTreeCache"/>
             </parameter>
             </constructor>
             </bean>
            


            • 3. Re: How to replace CacheJmxWrapper with JmxRegistrationManag
              galder.zamarreno

              We agreed undeprecate the CacheJmxWrapper method for JBoss Cache 3.2 since it's still a valid method and we're not planning to do further changes to the JMX layer in JBoss Cache.