Announcement Announcement Module
Collapse
No announcement yet.
Find FactoryBeans that implement a specific interface Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Find FactoryBeans that implement a specific interface

    Hello,
    I need to find FactoryBeans in my ApplicationContext that implement a certain interface. There doesn't seem to be any way of accomplishing this from the ApplicationContext interface? I can get all non-factory beans that implement a certain interface, and I can get all beans that are created by a factory bean that implement a certain interface - but I cannot get factory beans themselves that implement a certain interface. Is there any way around this?

    Thanks,
    Andy

  • #2
    Not directly. However, there is a way of doing it. You could get all bean names, and for each (say it's called "ted"), you could get the FactoryBean, not the object it creates, by doing

    getBean("&ted")

    The & prefix means that you get back the FactoryBean, not a created object.

    Rgds
    Rod

    Comment


    • #3
      Thanks for the workaround! I wonder how much (if any) less effecient this is than getBeansOfType? At the very least, it will be creating a new String for every bean name.

      - Andy

      Comment

      Working...
      X