Results 1 to 3 of 3

Thread: Find FactoryBeans that implement a specific interface

  1. #1
    Join Date
    Aug 2004
    Posts
    229

    Default 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. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    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
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  3. #3
    Join Date
    Aug 2004
    Posts
    229

    Default

    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

Similar Threads

  1. Beandoc crashing (on its samples!)
    By aaime in forum Container
    Replies: 17
    Last Post: Oct 7th, 2005, 07:21 AM
  2. JBoss 3.2.6 & Spring Deployment issues
    By difranr in forum Container
    Replies: 2
    Last Post: Sep 18th, 2005, 10:08 PM
  3. Replies: 3
    Last Post: Sep 4th, 2005, 11:11 PM
  4. Replies: 2
    Last Post: Apr 12th, 2005, 08:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •