Spring3.2 The bean definition based on annotation and Java code configuration method of source code analysis

Source: Internet
Author: User
Tags definition

Interpretation of source code based on Annotation configuration Bean Definition

The first part of this series analyzes the source code of the <bean/> element in the spring parsing XML configuration file, which is the original configuration of spring and also makes the nodes in XML have namespace attributes. Refer to the Spring related documentation if you have the following configuration: <context:component-scan base-package= "Com.colorcc.spring.sample"/>: First, the element uses the " Http://www.springframework.org/schema/context how the namespace is configured. Second, for each object in the "Com.colorcc.spring.sample" package, spring may configure and resolve the corresponding object based on a Annotation approach. This may be because it is also necessary to use annotations such as @Component and its child Annotation in the relevant Java code.

Annotation-based Bean parsing portal

As shown in Figure 2 above, the last Loop sequence diagram in the lower-right corner is the entry for the parse Bean for the Annotation configuration, so its detailed steps refer to the analysis in Figure 2 above. XML Context Namespace Bean element parsing is shown in listing 6 above, and if you take the "Http://www.springframework.org/schema/context" namespace, execute the The Delegate.parsecustomelement (Ele) method parses the Bean element, as shown in Figure 1 and Figure 2.

Figure 1. Sequence diagram for parsing beans based on Annotation –part1

Figure 2. Sequence diagram for parsing beans based on Annotation –part2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.