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