Announcement Announcement Module
Collapse
No announcement yet.
Calling bean method run-time : Possible? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calling bean method run-time : Possible?

    Hi All,
    I've following requirement:
    Method A1 of Bean A needs to call method B1 of bean B. But this should happen without putting call to "getBean ('B') and calling B.B1().
    I tried the following in the context xml file :

    <bean id="TestFactory" class="org.springframework.beans.factory.config.Me thodInvokingFactoryBean">
    <property name="targetObject"><ref local="refOfBeanB"/></property>
    <property name="targetMethod"><value>B1</value></property>
    </bean>

    But the call to B.B1 happens when I read the XML by "ClassPathXmlApplicationContext". (i.e. at the start time)
    I need the control to call "B.B1()" in the method "A.A1()".

    Can this be achieved with context xml?(in declarative fashion)
    Or I need to get the bean reference explicitely in A1() like this :
    getBean("B");
    call to B1();

    Any help is appreciated.
    thanks,
    anagha

  • #2
    If you are doing it declaratively it will happen only after you have initialized the context. You can force it to be run after a.a1() by using depends-on.

    Comment

    Working...
    X