Skip to content

Document registration recommendations for BeanPostProcessor and BeanFactoryPostProcessor #34964

Open
@wilkinsona

Description

@wilkinsona

I believe that it's generally recommended for a BeanPostProcessor that's defined as a @Bean to use a static method and for the method to, ideally, have no dependencies. The goal being to minimise the chances of the BPP triggering eager initialization that makes other beans ineligible for full post-processing.

I thought this was mentioned in the reference documentation but I have been unable to find it. https://docs.spring.io/spring-framework/reference/core/beans/factory-extension.html#beans-factory-extension-bpp talks a little about it, but only in the context of AOP auto-proxying as far as I can see. I think the advice should apply more broadly. There's also no Java example of registering a BPP, instead XML is used which missed the opportunity to recommend the use of static when a @Bean method is involved.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: documentationA documentation task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions