Continuing the discussion of another issue :
See Spring documentation on beans scope for dependencies .
.
I mean <aop:scoped-proxy/> , which the link points to. Each time an auto-reinforcement field is referenced, the user-defined get() method is called to find an instance based on some criteria.
.
I understand that I can look for dependencies (although I don’t know how the scope is not a bean, maybe I need to pass the application context during instance creation?). I do not understand how to insert these dependencies into my bean if they are @Autowired marked? Or are you saying that the bean user area should not have @Autowired dependencies?
It works automatically; Spring introduces a proxy for the bean, and scope.get() is called every time the method on that bean is called, returning the specific instance you want in the context of the current call.
Take a look at AbstractRequestAttributesScope to see how it works (in this case it gets an instance from an HTTP request and, if it does not exist, creates it).
So your code calls foo() on the proxy; the structure calls the region to get the desired instance, and then calls foo() on that instance.
The discovered methods that you want to call must either be on the interface or not declared final .
source share