Announcement Announcement Module
Collapse
No announcement yet.
FilterToBeanProxy doesn't work with HierachicalBeanFactory Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • FilterToBeanProxy doesn't work with HierachicalBeanFactory

    Hi,

    I've come across a minor compatibility issue in FilterToBeanProxy and HierachicalBeanFactory. I'm posting in case anyone else runs into this issue, also its possible to fix this issue in the code.

    Line 170:

    Code:
    Map beans = ctx.getBeansOfType(targetClass, true, true);
    This method does not look up beans in any parent BeanFactory. So if you define your filter in a file that is not directly loaded by the WebApplicationContext, but somewhere within the BeanFactory hierachy, then it won't be able to find the bean.

    There are two solutions to this.

    1. instead of specifying 'targetClass' in web.xml, use 'targetBean' and use the bean name. These lookups respect the BeanFactory hierarchy.

    2. modify FilterToBeanProxy line 170 to:

    Code:
    Map beans = BeanFactoryUtils.beanOfTypeIncludingAncestors(ctx, targetClass, true, true);
    Hope this helps someone :-)

    --Alex

  • #2
    Wouldn't your change to line 170 return the single object?

    Comment


    • #3
      oops, typo...

      i meant:

      Code:
      Map beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(ctx, targetClass, true, true);
      it should be plural 'beans', not singular 'bean'

      Comment


      • #4
        Thanks, I just added the change to CVS.

        Comment

        Working...
        X