1 16 17 package org.springframework.beans.factory.xml; 18 19 import org.w3c.dom.Element ; 20 21 import org.springframework.beans.factory.support.AbstractBeanDefinition; 22 import org.springframework.beans.factory.support.BeanDefinitionBuilder; 23 import org.springframework.util.Assert; 24 25 44 public abstract class AbstractSingleBeanDefinitionParser extends AbstractBeanDefinitionParser { 45 46 57 protected final AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { 58 Class beanClass = getBeanClass(element); 59 Assert.state(beanClass != null, "Class returned from getBeanClass(Element) must not be null"); 60 BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(beanClass); 61 builder.setSource(parserContext.extractSource(element)); 62 if (parserContext.isNested()) { 63 builder.setSingleton(parserContext.getContainingBeanDefinition().isSingleton()); 65 } 66 if (parserContext.isDefaultLazyInit()) { 67 builder.setLazyInit(true); 69 } 70 doParse(element, parserContext, builder); 71 return builder.getBeanDefinition(); 72 } 73 74 81 protected abstract Class getBeanClass(Element element); 82 83 93 protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { 94 doParse(element, builder); 95 } 96 97 104 protected void doParse(Element element, BeanDefinitionBuilder builder) { 105 } 106 107 } 108 | Popular Tags |