Announcement Announcement Module
Collapse
No announcement yet.
Factory identified by reference Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Factory identified by reference

    I have bean (A) that is produced from a factory. I'd like to specify that factory (B) as another bean, and have A's definition identify the factory instance by reference.

    Is this possible?

    Thanks
    David

  • #2
    If you want to make a bean aware of its creating factory you might just implement the "BeanFactoryAware" interface.

    Besides that, referencing a factory (instead of a bean it produces) can be achieved by prepending its name with "&". Note that you might need to escape the name due to XML restrictions (-> &amp.

    Regards,
    Andreas

    Comment


    • #3
      Originally posted by dcorbin
      I have bean (A) that is produced from a factory. I'd like to specify that factory (B) as another bean, and have A's definition identify the factory instance by reference.

      Is this possible?

      Thanks
      David
      See this chapter.

      I don`t know if it can be used within the ApplicationContext.

      Comment


      • #4
        Factory reference example

        I think you misunderstood me.

        I want to have something like this:
        <bean id="fooFactory" class="com.foo.FooFactory" singleton="false">
        <constructor-args value="17" />
        <bean>

        <bean id="foo" factory-ref="fooFactory" factory-method="createFoo" singleton="false"/>

        I don't really want to access the factory object itself, except as part of another bean's definition. The factory is not spring-aware, and I would like to avoid spring-specific interfaces here if possible.

        Comment


        • #5
          Maybe you are looking for this?

          Regards,
          Andreas

          Comment


          • #6
            Yes. Thanks.

            I knew it had to be there somewhere....

            Comment

            Working...
            X