Results 1 to 4 of 4

Thread: How can you find the names of beans used as properties ?

  1. #1
    Join Date
    Sep 2004
    Posts
    5

    Default How can you find the names of beans used as properties ?

    Is there any way for a 'bean' to find out the 'names/ids' of other beans that have been used as properties (including beans set by autowiring) ? For example :

    <bean id="service" class="MyService">
    <property name="dataSource">
    <ref bean="dataSource" />
    </property>
    <property name="interceptor">
    <ref bean="interceptor" />
    </property>
    </bean>

    Is there some mecahnism by which sessionFactory would be able to find out that it's dataSource property was set using the 'dataSource' bean ? Im also looking to try and do this with anonymous 'inner' beans as well....

    Thanks

    Lawrie
    Lawrie Nichols

  2. #2
    Join Date
    Oct 2004
    Location
    Herndon, VA, US
    Posts
    648

    Default

    Not sure I understand the exact problem you are trying to solve - maybe ConfigurableListableBeanFactory.BeanDefinition is what you are looking for?
    --Jing Xue

  3. #3
    Join Date
    Aug 2004
    Location
    Atlanta, GA
    Posts
    129

    Default

    What's your use case? You could implement BeanNameAware in your classes, but that's normally tying them too tightly to the container.
    Randy

  4. #4
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default

    It's not possible for the session factory to know the bean name of its dependencies (unless you would be implementing BeanNameAware in the dependency and cast the dependency in the session factory).

    regards,
    Alef
    Alef Arendsen
    SpringSource
    http://www.springsource.com

Posting Permissions

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