should allow specifying any number of parameters. These parameters should be passed directly to the constructor of the newly created bean.

Previously had to be parameterless. Now if you provide any parameters to that method, they are passes directly (1 to 1) to the bean constructor, just like if they were declared using . The idea was originally suggested here:

http://nurkiewicz.blogspot.com/2010/08/creating-prototype-spring-beans-on.html

This change is based entirely on a patch provided by Karl Pietrzak.

I submitted CLA.

Issue: SPR-7431

Comment From: cbeams

Thanks, Tomasz. Will take a look!

Comment From: nurkiewicz

Unfortunately my pull request causes testReplaceMethodOverrideWithSetterInjection() in org.springframework.beans.factory.xml.XmlBeanFactoryTests to fail. It's this assertion:

TestBean notJenny = oom.getPrototypeDependency("someParam");
assertTrue(!"Jenny".equals(notJenny.getName()));

it makes sure that overloaded getPrototypeDependency(String) method is not modified by Spring and only parameterless getPrototypeDependency() is overriden by lookup-method mechanism. This behavior changes after applying this patch. Now all methods, no matter if they have parameters or not, are overriden by lookup-method mechanism.

This means that lookup-method with parameters is not really backward compatible - in case there was more than one overloaded method. I am not sure how big this is. Applying lookup-method only if target bean has matching constructor (not always, what this pull request does) will help a little, but won't get rid of incompatibility completely.

My reviewed code is available at SPR-7431b branch.

Comment From: pivotal-issuemaster

@nurkiewicz Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: snicoll

@nurkiewicz sorry that this PR got overlooked. This is implemented in the meantime, and for quite a while already.