Results 1 to 2 of 2

Thread: Multiple Bean factories

  1. #1

    Post Multiple Bean factories

    If I create bean instances from 2 bean factories, is there a way that I can invoke a method on the instance created by other bean factory?

    to make it clear, if I have bean factory 1 creating bean 1 and bean factory 2 creating bean 2, is it possible to access bean 2 from bean 1.

  2. #2
    Join Date
    Sep 2009
    Location
    Vilnius, Lithuania
    Posts
    118

    Default

    Beans are just plain objects, so you can always take an object instantiated by BeanFactory 1 and pass it to a method of an object instantiated by BeanFactory 2.

    If, on the other hand, you want to have configuration for XmlBeanFactory 2 like this:
    Code:
    <bean name="bean2" class="Bean2">
        <property name="field" ref="bean1"/>
    </bean>
    where "bean1" is defined in XmlBeanFactory 1, then this kind of configuration will only work if XmlBeanFactory 1 is a parent to XmlBeanFactory 2. That is, if XmlBeanFactory 2 was created like this:
    Code:
    XmlBeanFactory beanFactory2 = new XmlBeanFactory(xmlConfig2, beanFactory1);
    For details, see http://static.springsource.org/sprin...ns-ref-element

Posting Permissions

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