8000 Add an extension point to process bean definitions - BeanDefinitionPostProcessor [SPR-3315] · Issue #8000 · spring-projects/spring-framework · GitHub
[go: up one dir, main page]

Skip to content
Add an extension point to process bean definitions - BeanDefinitionPostProcessor [SPR-3315] #8000
@spring-projects-issues

Description

@spring-projects-issues

Ben Rowlands opened SPR-3315 and commented

Often its desirable to modify a bean definition, for example detecting annotations and updating the definition.

This can almost be done using a BeanFactoryPostProcessor and the getBeanDefintionNames() and getBeanDefintion(String) API on the application context, however this doesn't handle inner beans.

A BeanDefinitionVisitor could be used but this is very inefficent if multiple of these are involved.

Could a BeanDefinitionPostProcessor be added? It would be invoked during the bean creation lifecycle with the merged bean definition, following a similar pattern to the other BeanPostProcessors (ie, auto-detection in container etc).

// applied to all bean definitions before creation (including inner beans)
public interface BeanDefinitionPostProcessor
{
public BeanDefinition postProcessBeanDefinition( BeanDefinition definition, .... )
}

Some other interesting context to pass into the callback would be the bean definition registry in which the definition is contained? A flag indicating if the definition is for an inner bean or not?

An example where this could be used is in #7998. Alternativly the new @Required annotation could be implemented as one of these? Or for cases where the context given to the callbacks in InstantiationAwareBeanPostProcessor don't suffice.


Affects: 2.0.3

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0