I have a @Controller
with @Autowired
fields and handler methods that I want to annotate with custom annotations.
For example,
InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation
will short-circuit the bean creation approach. The only processing applied is postProcessAfterInitialization
. Which means that, autowiring won't happen because AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues
will never be called. Therefore, you should manually inject or autowire the properties of the proxied beans in postProcessAfterInitialization
method.
Question: Does moving the proxying logic in postProcessAfterInitialization
method have an impact to your business requirements? If none, I suggest you do the proxying there.
FYI: If you are not building an API, do the annotation approach as suggested by @nicholas.hauschild.