@@ -0,0 +1,1849 @@
+package com.journaldev.spring.main;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0A%0Aimport org.springframework.beans.factory.BeanDefinitionStoreException;%0Aimport org.springframework.beans.factory.support.DefaultListableBeanFactory;%0Aimport org.springframework.beans.factory.xml.XmlBeanDefinitionReader;%0Aimport org.springframework.core.io.ClassPathResource;%0Aimport org.springframework.core.io.support.EncodedResource;%0Aimport org.xml.sax.InputSource;%0A%0Aimport com.journaldev.spring.service.MyAwareService;%0A%0Apublic class ProgramBeanFactory %7B%0A%09public static void main(String%5B%5D args)%7B%0A%09%09System.out.println(%22create resource%22);%0A%09%09ClassPathResource resource = new ClassPathResource(%22spring-aware.xml%22);%0A%09%09System.out.println(%22create bean factory%22);%0A%09%09DefaultListableBeanFactory factory = new DefaultListableBeanFactory();%0A%09%09System.out.println(%22create xml file reader %22);%0A%09%09XmlBeanDefinitionReader reader  = new XmlBeanDefinitionReader(factory);%0A%09%09System.out.println(%22use the xmlBeanDefinitionReader to load the resource%22);%0A%09%09EncodedResource encodedResource = new EncodedResource(resource);%0A%09%09try %7B%0A%09%09%09InputStream inputStream = encodedResource.getResource().getInputStream();%0A%09%09%09try %7B%0A%09%09%09%09InputSource inputSource = new InputSource(inputStream);%0A%09%09%09%09if (encodedResource.getEncoding() != null) %7B%0A%09%09%09%09%09inputSource.setEncoding(encodedResource.getEncoding());%0A%09%09%09%09%7D%0A%09%09%09%09reader.doLoadBeanDefinitions(inputSource, encodedResource.getResource());%0A%09%09%09%7D%0A%09%09%09finally %7B%0A%09%09%09%09inputStream.close();%0A%09%09%09%7D%0A%09%09%7D%0A%09%09catch (IOException ex) %7B%0A%09%09%09throw new BeanDefinitionStoreException(%0A%09%09%09%09%09%22IOException parsing XML document from %22 + encodedResource.getResource(), ex);%0A%09%09%7D%0A%09%09reader.loadBeanDefinitions(resource);%0A%09%09%0A%0A%09%09System.out.println(%22get bean%22);%0A%09%09//MyAwareService service = factory.getBean(%22myAwareService%22,MyAwareService.class);%0A%09%09//service.showDescription();%0A%09%09%0A%09%7D%0A%7D%0A

add program bean factory