1) Application context in springbeanfactory
Beanfactory interface, the common implementation class is: Xmlbeanfactory.
ApplicationContext
The ApplicationContext interface, which inherits the Beanfactory interface, is more commonly used.
Among the more commonly used implementations are:
Classpathxmlapplicationcontext
Filesystemxmlapplicationcontext
Xmlwebapplicationcontext
Webapplicationcontext
The interface inherits from ApplicationContext and is applied to spring's web environment.
2) Several special bean interfaces in spring
A) Beanfactoryaware interface, let the bean get the spring container.
b) Applicationcontextaware interface, the role of ibid.
c) Beannameaware interface to get the ID of the bean itself.
d) Initializingbean interface, dependent upon injected behavior.
e) Disposablebean interface, the behavior of the bean before it is destroyed.
If a bean implements all of the above interfaces, it is configured as follows:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/53/71/wKioL1RnfZ_QSec4AAB1M72XaQ4921.jpg "title=" Spring01.png "alt=" Wkiol1rnfz_qsec4aab1m72xaq4921.jpg "/>
From the bean initialization to the destruction process, the method is executed as follows:
Construction method
Method of Beannameaware interface
Method of Beanfactoryaware interface
Method of Applicationcontextaware interface
Method of Initializingbean interface
Init () method
Disposablebean interface method
Close () method
3) ApplicationContext event mechanism
If there is a applicationlistenerbean in the container (the bean that implements the Applicationlistener interface), The Applicatioinlistener bean is automatically triggered whenever ApplicationContext publishes Applicationevent (the published Bean needs to inherit the Applicationevent Class).
4) Spring get beanfactory
A) Implement the Beanfactoryaware interface.
b) obtained through Beanfactorylocator, the code is as follows:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/53/71/wKioL1Rnf1mQ8SN3AAHsFp6AoYc887.jpg "title=" Spring03.png "alt=" wkiol1rnf1mq8sn3aahsfp6aoyc887.jpg "/> parameter description: Beanfactorylocator for the XML file that needs to be loaded, if empty, Spring automatically searches for the Beanrefcontext.xml file under the Classpath, in the following format:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/53/73/wKiom1RnfwaDrDw_AAGeCzblJP4239.jpg "title=" Spring04.png "alt=" wkiom1rnfwadrdw_aageczbljp4239.jpg "/> parameter beanfactorylocatorkey is the ID in the search file, for example beanfactorylocatorkey= "AAA".
5) Instantiation Time of Springbean
A) By default, the Bean in spring is a singleton and is instantiated when the container starts.
b) If the Bean in spring is configured as prototype, it is initialized when the bean is fetched. Thereafter, the bean will not be managed by the spring container as a normal object that is recycled by the Java virtual machine after it is exhausted.
c) If, by default, the Bean is set to lazy-init= "true", it is instantiated on the first use.
This article is from the "Doctoryang" blog, make sure to keep this source http://ybchina.blog.51cto.com/8888456/1577054
Springbean of Technical Summary