Hi,
I've got a factory object that uses lookup method injection to create instances.
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="CONNECTION_FACTORY" class="ConnectionFactoryImpl" singleton="true"> <lookup-method name="createConnection" bean="CONNECTION"/> </bean>
Thanks for helpCode:<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>


Reply With Quote