As far as I understood, Spring manages autowiring mechanism with AutowiredAnnotationBeanPostProcessor
on postProcessBeforeInitialization
stage. But how does it inject proxies that ought to be created on postProcessAfterInitialization
stage?
EDIT 1
Suppose I have this Spring configuration
@Service
class RegularBean {
// injected on postProcessBeforeInitialization stage
@Autowired
private TransactionBean tBean;
// invoked in between of postProcessBeforeInitialization and postProcessAfterInitialization
@PostConstruct
void init() {
tBean.transactionMethod();
}
}
@Service
class TransactionBean {
// transactional proxy is created on postProcessAfterInitialization stage
@Transactional
public void transactionMethod() { ... }
}
Transactional proxy is created on postProcessAfterInitialization
stage. But @PostConstruct
is called right before it. Is injected tBean
wrapped with transactional proxy? If it so, then why? Because it should not be. If it is not wrapped, then how transactions are going to be handled in the future?
Suppose that I replace field-injection with constructor-injection. Will it change the behavior somehow?