Skip to content

Passing lookup-method arguments to created bean constructor [SPR-7431] #12089

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Issue Links:

Referenced from: commits eb0ab84

44 votes, 38 watchers

Metadata

Metadata

Assignees

Labels

has: votes-jiraIssues migrated from JIRA with more than 10 votes at the time of importin: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions