-1

Trying to write custom BeanPostProcessor i found many tutorials that showing simple way to create proxy object from my bean and throw it back to be handled by another BeanPostProcessors. I wonder, doesn't this approach break the further BPP chain because next BPP will not see the class metadata? Are there some additional tricks to avoid breaking chain that hasn't been shown in those tutorials? Also, how does spring itself handle such cases when creating @Transactional, @Async, etc. proxies of same bean?

Flo Pec
  • 9
  • 2

1 Answers1

0

If you put a breakpoint in DefaultSingletonBeanRegistry::getSingleton, you will be able to introspect this.beanPostProcessors and see the processors and their order. Transaction postprocessors are APO, so they will use CGLib to extended you original bean, for transactions you can put a breakpoint in AbstractBeanFactoryAwareAdvisingPostProcessor::prepareProxyFactory to see which beans are wrapped for @Trancational.

As with most things in Spring @Ordered can be use to control the order in which postprocessors are applied, a classical example is how (spring integrations) @Retry and @Transactional are handled, Spring Retry with Transactional.

Klaus Groenbaek
  • 4,820
  • 2
  • 15
  • 30