-
Notifications
You must be signed in to change notification settings - Fork 38.5k
ObjectFactory lacks method for getting bean with specified constructor arguments [SPR-13956] #18529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Juergen Hoeller commented This looks like a straightforward addition to 4.3's new |
Frank Scheffler commented I am not sure SmartObjectFactory is the right place, since it is not about whether the bean is available or not. Actually, I was thinking about the equivalent of BeanFactory.getObject(Class<T>, Object... parameters), simply without providing the type, since ObjectFactory already knows the type. One could even go as far as adding the var-args parameters to the existing getObject()-method, however the JavaDoc may become a little confusing in that case. |
Juergen Hoeller commented Well, From another perspective, conceptually, Juergen |
Juergen Hoeller commented Actually, the problem is even worse: |
Frank Scheffler commented Could you explain that a little more? I don't see, why the injection of ObjectFactory itself is a problem. As far as I know, ObjectFactory can be injected for both singleton and prototype beans. How is that going to be affected by changing the method signature (or adding a method) to the injected factory itself? |
Juergen Hoeller commented It's just a problem with the current implementation arrangement. Juergen |
Juergen Hoeller commented Committed to master as Juergen |
Juergen Hoeller commented Quick note: |
Frank Scheffler opened SPR-13956 and commented
While BeanFactory supports retrieving prototyped beans with additional constructor or factory-method arguments (#15860), the org.springframework.beans.factory.ObjectFactory is still missing such method.
ObjectFactory is often used in test fixtures, where lookup-method injection et.al. cannot be used, in order to get access to prototype bean instance. Using the BeanFactory directly in such cases is currently the only way to solve this.
Affects: 4.2.4
Issue Links:
Referenced from: commits ed98393, 890819f
The text was updated successfully, but these errors were encountered: