Closed
Description
Tomasz Nurkiewicz opened SPR-7431 and commented
<lookup-method/> should allow specifying any number of parameters. These parameters should be passed directly to the constructor of the newly created bean. For example:
<bean id="flightValidator" class="com.blogspot.nurkiewicz.lookup.FlightValidator" scope="prototype" lazy-init="true"/>
<bean id="someBean" class="com.blogspot.nurkiewicz.lookup.SomeSpringBean">
<lookup-method name="createValidator" bean="flightValidator"/>
</bean>
public class SomeSpringBean {
protected abstract FlightValidator createValidator(Flight flight);
}
public class FlightValidator {
public FlightValidator(Flight flight) {
//...
}
}
This configuration should be valid and flight
instance given to createValidator() lookup method should be passed automatically to FlighValidator
constructor.
Very rough implementation of this feature (only two lines of code modified!) is discussed here. Similar issue #7703 has been reported and rejected, but its author wanted the lookup-method parameters to be ignored.
Affects: 3.0.3
Attachments:
- SPR-7431-patch.diff (7.54 kB)
Issue Links:
- @LookupMethod annotation for use with component scanning [SPR-5192] #9865
@LookupMethod
annotation for use with component scanning - BeanFactory lacks method for getting bean by type with specified constructor arguments [SPR-11235] #15860 BeanFactory lacks method for getting bean by type with specified constructor arguments
- Context startup should fail when lookup-method has arguments [SPR-7426] #12084 Context startup should fail when lookup-method has arguments ("supersedes")
Referenced from: commits eb0ab84
44 votes, 38 watchers