The beanfactory of Spring source Reading

Source: Internet
Author: User

1. The structural system of the beanfactory is as follows:

2. Xmlbeanfactory, loading spring configuration information

 PackageOrg.springframework.beans.factory.xml;Importorg.springframework.beans.BeansException;Importorg.springframework.beans.factory.BeanFactory;Importorg.springframework.beans.factory.support.DefaultListableBeanFactory;ImportOrg.springframework.core.io.Resource; Public classXmlbeanfactoryextendsDefaultlistablebeanfactory {Private FinalXmlbeandefinitionreader reader =NewXmlbeandefinitionreader ( This); /*** Create A new xmlbeanfactory with the given resource, * which must is parsable using DOM. * @paramResource XML resource to load beans definitions from *@throwsBeansexception in case of loading or parsing errors*/     PublicXmlbeanfactory (Resource Resource)throwsbeansexception { This(Resource,NULL); }    /*** Create A new xmlbeanfactory with the given input stream, * which must is parsable using DOM. * @paramResource XML resource to load beans definitions from *@paramparentbeanfactory Parent Bean Factory *@throwsBeansexception in case of loading or parsing errors*/     PublicXmlbeanfactory (Resource Resource, Beanfactory parentbeanfactory)throwsbeansexception {Super(parentbeanfactory);  This. Reader.loadbeandefinitions (Resource); }}

3. Beanfactory interface

 Packageorg.springframework.beans.factory;Importorg.springframework.beans.BeansException; Public Interfacebeanfactory {String factory_bean_prefix= "&"; Object Getbean (String name)throwsbeansexception; <T> T Getbean (String name, class<t> requiredtype)throwsbeansexception; <T> T Getbean (class<t> requiredtype)throwsbeansexception; Object Getbean (String name, Object ... args)throwsbeansexception; BooleanContainsbean (String name); BooleanIssingleton (String name)throwsnosuchbeandefinitionexception; BooleanIsprototype (String name)throwsnosuchbeandefinitionexception; BooleanIstypematch (String name, Class targetType)throwsnosuchbeandefinitionexception; Class<?> GetType (String name)throwsnosuchbeandefinitionexception; String[] Getaliases (String name);}

4. Application Examples:

null; // Load Spring Configure file New xmlbeanfactory (Reource); Bf.getbean ("Beanname");

The beanfactory of Spring source Reading

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.