[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...

Peter Muir peter at bleepbleep.org.uk
Wed Sep 26 18:02:36 EDT 2007


  User: pmuir   
  Date: 07/09/26 18:02:36

  Modified:    src/main/org/jboss/seam/core  Init.java
  Log:
  Better checks for duplicate factories
  
  Revision  Changes    Path
  1.55      +29 -4     jboss-seam/src/main/org/jboss/seam/core/Init.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Init.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Init.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -b -r1.54 -r1.55
  --- Init.java	25 Sep 2007 15:31:05 -0000	1.54
  +++ Init.java	26 Sep 2007 22:02:36 -0000	1.55
  @@ -1,4 +1,4 @@
  -//$Id: Init.java,v 1.54 2007/09/25 15:31:05 pmuir Exp $
  +//$Id: Init.java,v 1.55 2007/09/26 22:02:36 pmuir Exp $
   package org.jboss.seam.core;
   
   
  @@ -173,15 +173,40 @@
      
      private void checkDuplicateFactory(String variable)
      {
  -      if ( factories.containsKey(variable) || factoryMethodExpressions.containsKey(variable) || factoryValueExpressions.containsKey(variable) )
  +      if ( factories.containsKey(variable) )
         {
  -         throw new IllegalStateException("duplicate factory for: " + variable);
  +          throw new IllegalStateException("duplicate factory for: " + variable + " (duplicate is specified in a component)");
         }
  +      checkDuplicateFactoryExpressions(variable);
  +   }
  +   
  +   private void checkDuplicateFactoryExpressions(String variable)
  +   {
  +       if ( factoryMethodExpressions.containsKey(variable) || factoryValueExpressions.containsKey(variable) )
  +       {
  +           throw new IllegalStateException("duplicate factory for: " + variable + " (duplicate is specified in components.xml)");
  +       }
  +   }
  +   
  +   private void checkDuplicateFactory(String variable, Component component)
  +   {
  +       if (factories.containsKey(variable))
  +       {
  +           String otherComponentName = factories.get(variable).getComponent().getName();
  +           Class otherComponentClass = factories.get(variable).getComponent().getBeanClass();
  +           String componentName = component.getName();
  +           Class componentClass = component.getBeanClass();
  +           if (componentName != null && !componentName.equals(otherComponentName))
  +           {
  +               throw new IllegalStateException("duplicate factory for: " + variable + " (duplicates are specified in " + componentName + " and " + otherComponentName + ")");
  +           }
  +       }
  +       checkDuplicateFactoryExpressions(variable);
      }
      
      public void addFactoryMethod(String variable, Method method, Component component)
      {
  -      checkDuplicateFactory(variable);
  +      checkDuplicateFactory(variable, component);
   	   factories.put( variable, new FactoryMethod(method, component) );
      }
   
  
  
  



More information about the jboss-cvs-commits mailing list