Announcement Announcement Module
Collapse
No announcement yet.
How can you find the names of beans used as properties ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

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

    Comment


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

      Comment


      • #4
        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

        Comment

        Working...
        X