DWR

Incorrect handling of beans that have a parent with Spring 2.5

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.0.1, 2.0.2
  • Fix Version/s: 3.0.M1
  • Component/s: Spring
  • Description:
    Hide
    When using Spring 2.5 the DwrNamespaceHandler can no longer find the class for beans that rely on a parent's bean definition to set the class to use.
    Spring 2.5 does not create ChildBeanDefinition for such beans, but creates a GenericBeanDefinition (that also has a getParentName() method).

    To work around this I changed the resolveBeanClassname method for the RemoteBeanDefinitionDecorator (see below). Basically I just use the top level method instead of checking what instance it is. This addressed the problem for me...

            private String resolveBeanClassname(BeanDefinition definition, BeanDefinitionRegistry registry)
            {
                String beanClassName = definition.getBeanClassName();
                if (!StringUtils.hasText(beanClassName))
                {
                    String parentName = definition.getParentName();
                    while (parentName != null)
                    {
                        BeanDefinition parentDefinition = findParentDefinition(parentName, registry);
                        if (parentDefinition == null)
                        {
                            if (log.isDebugEnabled())
                            {
                                log.debug("No parent bean named '" + parentName + "' could be found in the " +
                                          "hierarchy of BeanFactorys. Check you've defined a bean called '" + parentName + "'");
                            }
                            break;
                        }
                        beanClassName = parentDefinition.getBeanClassName();
                        if (StringUtils.hasText(beanClassName ))
                        {
                            // found the class name we were looking for
                            break;
                        }
                        parentName = parentDefinition.getParentName();
                    }
                }
               
                return beanClassName;
            }
    Show
    When using Spring 2.5 the DwrNamespaceHandler can no longer find the class for beans that rely on a parent's bean definition to set the class to use. Spring 2.5 does not create ChildBeanDefinition for such beans, but creates a GenericBeanDefinition (that also has a getParentName() method). To work around this I changed the resolveBeanClassname method for the RemoteBeanDefinitionDecorator (see below). Basically I just use the top level method instead of checking what instance it is. This addressed the problem for me...         private String resolveBeanClassname(BeanDefinition definition, BeanDefinitionRegistry registry)         {             String beanClassName = definition.getBeanClassName();             if (!StringUtils.hasText(beanClassName))             {                 String parentName = definition.getParentName();                 while (parentName != null)                 {                     BeanDefinition parentDefinition = findParentDefinition(parentName, registry);                     if (parentDefinition == null)                     {                         if (log.isDebugEnabled())                         {                             log.debug("No parent bean named '" + parentName + "' could be found in the " +                                       "hierarchy of BeanFactorys. Check you've defined a bean called '" + parentName + "'");                         }                         break;                     }                     beanClassName = parentDefinition.getBeanClassName();                     if (StringUtils.hasText(beanClassName ))                     {                         // found the class name we were looking for                         break;                     }                     parentName = parentDefinition.getParentName();                 }             }                         return beanClassName;         }

Activity

Jose Noheda made changes - 06/Feb/08 8:10 AM
Field Original Value New Value
Assignee Joe Walker [ joe ] Jose Noheda [ xmaniac ]
Jose Noheda made changes - 06/Feb/08 8:11 AM
Status Open [ 1 ] In Progress [ 3 ]
Jose Noheda made changes - 06/Feb/08 4:33 PM
Status In Progress [ 3 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Fix Version/s 2.1 [ 10022 ]
Joe Walker made changes - 07/Feb/08 2:38 PM
Fix Version/s 3.0 [ 10025 ]
Fix Version/s 3.0.M1 [ 10042 ]

People

Dates

  • Created:
    12/Dec/07 3:18 PM
    Updated:
    07/Feb/08 2:38 PM
    Resolved:
    06/Feb/08 4:33 PM