[jboss-cvs] JBossCache/src/org/jboss/cache/jmx ...

Brian Stansberry brian.stansberry at jboss.com
Wed May 9 14:27:33 EDT 2007


  User: bstansberry
  Date: 07/05/09 14:27:33

  Modified:    src/org/jboss/cache/jmx   CacheLegacyJmxWrapperMBean.java
                        CacheLegacyJmxWrapper.java
  Log:
  [JBCACHE-934] Remove ChannelFactory JMX lookup from CacheImpl
  [JBCACHE--1044] RuntimeConfig's channel factory should by type ChannelFactory, not JChannelFactoryMBean
  
  Revision  Changes    Path
  1.5       +4 -19     JBossCache/src/org/jboss/cache/jmx/CacheLegacyJmxWrapperMBean.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheLegacyJmxWrapperMBean.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/jmx/CacheLegacyJmxWrapperMBean.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- CacheLegacyJmxWrapperMBean.java	5 Jan 2007 14:27:15 -0000	1.4
  +++ CacheLegacyJmxWrapperMBean.java	9 May 2007 18:27:33 -0000	1.5
  @@ -22,7 +22,7 @@
   package org.jboss.cache.jmx;
   
   import org.jboss.cache.Region;
  -import org.jgroups.jmx.JChannelFactoryMBean;
  +import org.jgroups.ChannelFactory;
   import org.w3c.dom.Element;
   
   import javax.transaction.TransactionManager;
  @@ -31,7 +31,7 @@
    * StandardMBean interface for {@link CacheLegacyJmxWrapper}.
    *
    * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public interface CacheLegacyJmxWrapperMBean extends CacheJmxWrapperMBean
   {
  @@ -277,21 +277,6 @@
      Element getBuddyReplicationConfig();
   
      /**
  -    * Retrieves the JGroups multiplexer service name if defined.
  -    *
  -    * @return the multiplexer service name
  -    */
  -   String getMultiplexerService();
  -
  -   /**
  -    * Sets the JGroups multiplexer service name.
  -    * This attribute is optional; if not provided, a JGroups JChannel will be used
  -    *
  -    * @param serviceName the multiplexer service name
  -    */
  -   void setMultiplexerService(String serviceName);
  -
  -   /**
       * Retrieves the JGroups multiplexer stack name if defined.
       *
       * @return the multiplexer stack name
  @@ -306,8 +291,8 @@
       */
      void setMultiplexerStack(String stackName);
   
  -   JChannelFactoryMBean getMuxChannelFactory();
  +   ChannelFactory getMuxChannelFactory();
   
  -   void setMuxChannelFactory(JChannelFactoryMBean factory);
  +   void setMuxChannelFactory(ChannelFactory factory);
   
   }
  
  
  
  1.6       +71 -13    JBossCache/src/org/jboss/cache/jmx/CacheLegacyJmxWrapper.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheLegacyJmxWrapper.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/jmx/CacheLegacyJmxWrapper.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- CacheLegacyJmxWrapper.java	24 Jan 2007 16:33:57 -0000	1.5
  +++ CacheLegacyJmxWrapper.java	9 May 2007 18:27:33 -0000	1.6
  @@ -21,30 +21,36 @@
    */
   package org.jboss.cache.jmx;
   
  +import javax.management.MBeanServer;
  +import javax.management.NotificationBroadcaster;
  +import javax.management.ObjectName;
  +import javax.transaction.TransactionManager;
  +
  +import org.jboss.cache.CacheException;
   import org.jboss.cache.config.BuddyReplicationConfig;
   import org.jboss.cache.config.CacheLoaderConfig;
   import org.jboss.cache.config.Configuration;
   import org.jboss.cache.config.EvictionConfig;
  +import org.jboss.cache.config.RuntimeConfig;
   import org.jboss.cache.factories.XmlConfigurationParser;
  -import org.jgroups.jmx.JChannelFactoryMBean;
  +import org.jgroups.Channel;
  +import org.jgroups.ChannelFactory;
   import org.w3c.dom.Element;
   
  -import javax.management.NotificationBroadcaster;
  -import javax.transaction.TransactionManager;
  -
   /**
    * {@link CacheJmxWrapper} subclass that supports building the
    * {@link Configuration} from MBean attribute injection.  Allows
    * configuration of the cache using the JBoss AS 4.x JMX microkernel.
    *
    * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    */
   public class CacheLegacyJmxWrapper extends CacheJmxWrapper implements CacheLegacyJmxWrapperMBean, NotificationBroadcaster
   {
      private Element buddyReplConfig;
      private Element evictionConfig;
      private Element cacheLoaderConfig;
  +   private ObjectName multiplexerService;
   
      public CacheLegacyJmxWrapper()
      {
  @@ -63,6 +69,48 @@
         return result;
      }
   
  +   @Override
  +   protected void constructCache() throws Exception
  +   {
  +      super.constructCache();
  +      if (multiplexerService != null)
  +      {
  +         injectMuxChannel();
  +      }
  +   }
  +   
  +   private void injectMuxChannel() throws CacheException
  +   {
  +      Configuration cfg = getConfiguration();
  +      RuntimeConfig rtcfg = cfg.getRuntimeConfig();
  +      
  +      // Only inject if there isn't already a channel or factory
  +      if (rtcfg.getMuxChannelFactory() != null && rtcfg.getChannel() != null)
  +      {
  +         MBeanServer mbs = getMBeanServer();
  +         if (mbs != null)
  +         {
  +            Channel ch;
  +            try
  +            {
  +               ch = (Channel) mbs.invoke(multiplexerService, "createMultiplexerChannel", new Object[] { cfg.getMultiplexerStack(), cfg.getClusterName() }, new String[] { String.class.getName(), String.class.getName() });
  +            }
  +            catch (Exception e)
  +            {
  +               throw new CacheException("Exception creating multiplexed channel", e);
  +            }
  +            rtcfg.setChannel(ch);
  +         }
  +         else
  +         {
  +            throw new CacheException("Cannot access " + multiplexerService + 
  +                  " as no MBeanServer is available. Register this MBean with " +
  +                  "the JMX server before calling create()");
  +         }
  +      }
  +      
  +   }
  +
      public Element getBuddyReplicationConfig()
      {
         return buddyReplConfig;
  @@ -118,9 +166,14 @@
         return getConfiguration().getLockAcquisitionTimeout();
      }
   
  -   public String getMultiplexerService()
  +   /**
  +    * 
  +    * 
  +    * @deprecated directly inject the ChannelFactory via {@link #setMuxChannelFactory(ChannelFactory)}
  +    */
  +   public ObjectName getMultiplexerService()
      {
  -      return getConfiguration().getMultiplexerService();
  +      return multiplexerService;
      }
   
      public String getMultiplexerStack()
  @@ -128,7 +181,7 @@
         return getConfiguration().getMultiplexerStack();
      }
   
  -   public JChannelFactoryMBean getMuxChannelFactory()
  +   public ChannelFactory getMuxChannelFactory()
      {
         return getConfiguration().getRuntimeConfig().getMuxChannelFactory();
      }
  @@ -278,9 +331,14 @@
         getConfiguration().setLockAcquisitionTimeout(timeout);
      }
   
  -   public void setMultiplexerService(String serviceName)
  +   /**
  +    * 
  +    * 
  +    * @deprecated directly inject the ChannelFactory via {@link #setMuxChannelFactory(ChannelFactory)}
  +    */
  +   public ObjectName setMultiplexerService(ObjectName muxService)
      {
  -      getConfiguration().setMultiplexerService(serviceName);
  +      return multiplexerService = muxService;
      }
   
      public void setMultiplexerStack(String stackName)
  @@ -288,7 +346,7 @@
         getConfiguration().setMultiplexerStack(stackName);
      }
   
  -   public void setMuxChannelFactory(JChannelFactoryMBean factory)
  +   public void setMuxChannelFactory(ChannelFactory factory)
      {
         getConfiguration().getRuntimeConfig().setMuxChannelFactory(factory);
      }
  
  
  



More information about the jboss-cvs-commits mailing list