Announcement Announcement Module
Collapse
No announcement yet.
Dynamic lookup method Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamic lookup method

    Hi,
    I've got a factory object that uses lookup method injection to create instances.

    Code:
    <bean id="CONNECTION" class="ConnectionImpl" singleton="false">
    ...
    </bean>	
    <bean id="CONNECTION_FACTORY" class="ConnectionFactoryImpl" singleton="true">
    <lookup-method name="createConnection"  bean="CONNECTION"/>
    </bean>
    I'd like to reuse the ConnectionFactoryImpl object in a new project but in this new context, ConnectionFactoryImpl can't be a singleton anymore and I'd like to switch between several implementations of Connection in the lookup method. Since the bean name is hard-coded in the lookup method, I wonder if there is a workarround to set this property dynamically without implementing ApplicationContextAware.

    Code:
    <bean id="CONNECTION" class="ConnectionImpl" singleton="false">
    ...
    </bean>	
    <bean id="ANOTHER_CONNECTION" class="AnotherConnectionImpl" singleton="false">
    ...
    </bean>	
    <bean id="CONNECTION_FACTORY" class="ConnectionFactoryImpl" singleton="false">
    <lookup-method name="createConnection"  bean="??property_of_CONNECTION_FACTORY??"/>
    </bean>
    Thanks for help
    Last edited by loobiecore; May 13th, 2006, 02:25 AM.
Working...
X