Results 1 to 2 of 2

Thread: Calling bean method run-time : Possible?

  1. #1
    Join Date
    Sep 2005
    Location
    India
    Posts
    22

    Default 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. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 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
  •