Hello,
I am trying to follow Domain-Driven Design paradigm in my Spring projects. For it I am using prototype beans quiet extensively. Often I meet the situation, when for prototype initialization I require both runtime and singleton parameters, for example, if bean is supposed to represent some database entity it initializes with its ID and some database service during.
There are several ways to create beans in Spring, however, I find that @Lookup
methods is the most convenient way to create prototype beans. However, now they can either try to find all bean dependencies in context and autowire them or all parameters should be provided to them explicitly. So, to create bean with both runtime and singleton parameters all singletons should present in the scope of caller of @Lookup
method. This is very inconvenient and leads to abstraction leaks.
Please see https://github.com/gzoom13/spring-lookup-enhancement. Here I reproduce the issue.
24530 should was created to fix that. I am sorry for creating issue with existing PR, but latter is not reviewed for 2 months already. Specified reproducer project above build just fine with these changes.
Comment From: snicoll
Sorry this got overlooked, #24530 has been declined as we don't think the extra complexity is worth it, so I'll close for consistency.
Duplicate of #24530.