Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-7431

Passing lookup-method arguments to created bean constructor

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 3.0.3
    • Fix Version/s: 4.1 RC2
    • Component/s: Core
    • Last commented by a User:
      false

      Description

      <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 SPR-3017 has been reported and rejected, but its author wanted the lookup-method parameters to be ignored.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                juergen.hoeller Juergen Hoeller
                Reporter:
                nurkiewicz Tomasz Nurkiewicz
                Last updater:
                St├ęphane Nicoll
              • Votes:
                44 Vote for this issue
                Watchers:
                38 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  3 years, 41 weeks, 5 days ago