Carlos Jaime C. De Leon Carlos Jaime C. De Leon -4 years ago 130
Java Question

How does Spring's context namespace work?

For example if I declare in my application-context.xml:

<context:annotation-config/>


I read from the official documentation:


The implicitly registered post-processors include
AutowiredAnnotationBeanPostProcessor,
CommonAnnotationBeanPostProcessor,
PersistenceAnnotationBeanPostProcessor, as well as the aforementioned
RequiredAnnotationBeanPostProcessor.


But I was wondering how Spring does this work under the hood, I would think that this 1-liner is converted into several bean definitions for the post-processors mentioned by the documentation.

However, my question is, which Spring component/class implements this 'conversion from 1-liner to multiple bean definitions' functionality?

Answer Source

If you want to know what the annotation-config tag does behind the scenes look into the AnnotationConfigBeanDefinitionParser

If you want to know more about the general mechanism used to define such tags check out this section of the spring reference documentation.

You need a schema definition, a NameSpaceHandler and a BeanDefinitionParser

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download