What is the Spring Framework equivalent to FactoryModuleBuilder, @AssistedInject, and @Assisted in Google Guice? In other words, what is the recommended approach using Spring t
I'm not entirely certain that this question is a dupe, (only 90% sure), but this answer:
https://stackoverflow.com/a/13243066/1768232
Seems to have the information you need. Specifically, you should do this:
I got it working by fetching an instance of the bean used in the constructor-arg out of the context and then populating it with the values that you are working with at run-time. This bean will then be used as the parameter when you get your factory-generated bean.
public class X {
public void callFactoryAndGetNewInstance() {
User user = context.getBean("user");
user.setSomethingUsefull(...);
FileValidator validator = (FileValidator)context.getBean("fileValidator");
...
}
}
I recommend reading the entire answer.