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

Brian Stansberry brian.stansberry at jboss.com
Fri May 11 12:48:09 EDT 2007


  User: bstansberry
  Date: 07/05/11 12:48:09

  Modified:    src/org/jboss/cache/factories  XmlConfigurationParser.java
  Log:
  [JBCACHE-1055] Remove Configuration's serviceName property
  
  Revision  Changes    Path
  1.18      +62 -13    JBossCache/src/org/jboss/cache/factories/XmlConfigurationParser.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: XmlConfigurationParser.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/factories/XmlConfigurationParser.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -b -r1.17 -r1.18
  --- XmlConfigurationParser.java	9 May 2007 18:15:10 -0000	1.17
  +++ XmlConfigurationParser.java	11 May 2007 16:48:09 -0000	1.18
  @@ -91,19 +91,11 @@
   
         ParsedAttributes attributes = extractAttributes(mbeanElement);
   
  -      // Deal with rename of the old property that controlled MBean registration
  -      String keepStats = attributes.stringAttribs.remove("UseMbean");
  -      if (keepStats != null && attributes.stringAttribs.get("ExposeManagementStatistics") == null)
  -      {
  -         attributes.stringAttribs.put("ExposeManagementStatistics", keepStats);
  -      }
  -      String multiplexerService = attributes.stringAttribs.remove("MultiplexerService");
  -      if (multiplexerService != null)
  -      {
  -         log.warn("XmlConfigurationParser does not support the deprecated " +
  -                "attribute MultiplexerService. Inject the multiplexer directly " +
  -                "using Configuration.getRuntimeConfig().setMuxChannelFactory()");
  -      }
  +      // Deal with legacy attributes we no longer support
  +      handleRemovedAttributes(attributes);
  +      
  +      // Deal with legacy attributes that we renamed or otherwise altered
  +      handleRenamedAttributes(attributes);
   
         Configuration c = new Configuration();
         setValues(c, attributes.stringAttribs, false);
  @@ -113,6 +105,61 @@
         return c;
      }
   
  +   /**
  +    * Check for and remove any attributes that were supported in the
  +    * 1.x releases and no longer are.  Log a WARN or throw a 
  +    * {@link ConfigurationException} if any are found. Which is done depends
  +    * on the attribute:
  +    * <p>
  +    * <ul>
  +    * <li><i>MultiplexerService</i> -- throws an Exception</li>
  +    * <li><i>ServiceName</i> -- logs a WARN</li>
  +    * </ul>
  +    * 
  +    * @param attributes
  +    */
  +   protected void handleRemovedAttributes(ParsedAttributes attributes)
  +   {
  +      String multiplexerService = attributes.stringAttribs.remove("MultiplexerService");
  +      if (multiplexerService != null)
  +      {
  +         throw new ConfigurationException("XmlConfigurationParser does not " +
  +                "support the JBC 1.x attribute MultiplexerService. Inject the " +
  +                "multiplexer directly using Configuration.getRuntimeConfig().setMuxChannelFactory()");
  +      }
  +      String serviceName = attributes.stringAttribs.remove("ServiceName");
  +      if (serviceName != null)
  +      {
  +         log.warn("XmlConfigurationParser does not support the deprecated " +
  +                "attribute ServiceName. If JMX registration is needed, " +
  +                "register a CacheJmxWrapper or PojoCacheJmxWrapper in " +
  +                "JMX with the desired name");
  +      }
  +   }
  +
  +   /**
  +    * Check for any attributes that were supported in the
  +    * 1.x releases but whose name has changed.  Log a WARN if any are found, but
  +    * convert the attribute to the new name.
  +    * <p>
  +    * <ul>
  +    * <li><i>UseMbean</i> becomes <i>ExposeManagementStatistics</i></li>
  +    * </ul>
  +    * 
  +    * @param attributes
  +    */
  +   private void handleRenamedAttributes(ParsedAttributes attributes)
  +   {
  +      String keepStats = attributes.stringAttribs.remove("UseMbean");
  +      if (keepStats != null && attributes.stringAttribs.get("ExposeManagementStatistics") == null)
  +      {
  +         log.warn("Found non-existent JBC 1.x attribute 'UseMbean' and replaced " +
  +                "with 'ExposeManagementStatistics'. Please update your config " +
  +                "to use the new attribute name");
  +         attributes.stringAttribs.put("ExposeManagementStatistics", keepStats);
  +      }
  +   }
  +
      protected InputStream getAsInputStreamFromClassLoader(String filename)
      {
         return Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
  @@ -581,6 +628,8 @@
         return new ParsedAttributes(stringAttribs, xmlAttribs);
      }
   
  +   
  +
      private static String getSetterName(String propName)
      {
         StringBuffer sb = new StringBuffer("set");
  
  
  



More information about the jboss-cvs-commits mailing list