Spring Framework
  1. Spring Framework
  2. SPR-7431

Passing lookup-method arguments to created bean constructor

    Details

    • Type: Improvement Improvement
    • Status: Investigating
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.0.3
    • Fix Version/s: 4.1 RC1
    • Component/s: Core
    • Last commented by a User:
      true

      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.

        Issue Links

          Activity

          Hide
          Carlos Rodarte added a comment - - edited

          Has anything happened on this issue? It seems like a pretty handy feature. If Tomasz didn't take action on the code review comments, maybe I can address them

          Show
          Carlos Rodarte added a comment - - edited Has anything happened on this issue? It seems like a pretty handy feature. If Tomasz didn't take action on the code review comments, maybe I can address them
          Hide
          Tomasz Nurkiewicz added a comment -

          I am terribly sorry for the delay, I promise to address all the issues by the end of next week.

          Show
          Tomasz Nurkiewicz added a comment - I am terribly sorry for the delay, I promise to address all the issues by the end of next week.
          Hide
          Chris Beams added a comment -

          No problem, thanks Tomasz. Note that you'll want to work against 3.2.x at this point, i.e. rebase your current branch against 3.2.x, as master now represents work toward Spring Framework 4.0. You may need to resubmit your pull request; I'm not sure if you can change the target branch midflight like that.

          As for timing, please note that we plan to release 3.2.1 on Thursday the 24th. So if you'd like the functionality to make it in by then, you'll want to get it in at least a day before.

          Show
          Chris Beams added a comment - No problem, thanks Tomasz. Note that you'll want to work against 3.2.x at this point, i.e. rebase your current branch against 3.2.x , as master now represents work toward Spring Framework 4.0. You may need to resubmit your pull request; I'm not sure if you can change the target branch midflight like that. As for timing, please note that we plan to release 3.2.1 on Thursday the 24th. So if you'd like the functionality to make it in by then, you'll want to get it in at least a day before.
          Hide
          Tomasz Nurkiewicz added a comment -

          Please have a look at my comment on this pull request. Apparently this change introduces minor backward incompatibility. Not sure how important this is.

          Show
          Tomasz Nurkiewicz added a comment - Please have a look at my comment on this pull request . Apparently this change introduces minor backward incompatibility. Not sure how important this is.
          Hide
          Tomasz Nurkiewicz added a comment -

          Any updates or thoughts on this issue? Having this feature would stop people from doing hacks like this.

          Show
          Tomasz Nurkiewicz added a comment - Any updates or thoughts on this issue? Having this feature would stop people from doing hacks like this .

            People

            • Assignee:
              Juergen Hoeller
              Reporter:
              Tomasz Nurkiewicz
              Last updater:
              Juergen Hoeller
            • Votes:
              42 Vote for this issue
              Watchers:
              35 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                46 weeks, 6 days ago